artic icon indicating copy to clipboard operation
artic copied to clipboard

Storing intrinsics to local variables overwrites their names.

Open m-kurtenacker opened this issue 1 year ago • 1 comments

Simple way to reproduce this issue:

#[import(cc = "device", name = "llvm.exp.f32")] fn cpu_expf(_: f32) -> f32;

#[export]
fn foo (n : f32) -> f32 {
    let bar = cpu_expf;

    cpu_expf(n)
}

Defining bar overwrites the name of cpu_expf, which results in broken code being produced in thorin.

We should probably not rely on the names of continuations as much as we currently do.

m-kurtenacker avatar Jul 22 '24 11:07 m-kurtenacker

The name is only here for debugging purposes, so I think it is fine to add a check that it is not already set before setting it.

madmann91 avatar Jul 22 '24 19:07 madmann91