AnyDSL / artic

The AlteRnaTive Impala Compiler
MIT License
25 stars 6 forks source link

Storing intrinsics to local variables overwrites their names. #26

Open m-kurtenacker opened 1 month ago

m-kurtenacker commented 1 month ago

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.

madmann91 commented 1 month ago

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.