the following code will reproduce the issue:
#[import(cc = "thorin")] fn nvvm(_dev: i32, _grid: (i32, i32, i32), _block: (i32, i32, i32), _body: fn() -> ()) -> ();
#[import(cc = "device")] fn threadfence() -> ();
#[export]
fn test(b: bool) -> () {
let fun = if b { @|| { asm("nanosleep.u32 0;"); } } else { threadfence };
nvvm(0, (1, 1, 1), (1, 1, 1), @|| {
fun();
});
}
compilation via artic with --emit-llvm results in
src/thorin/util/cast.h:42: L* thorin::scast(R*) [with L = thorin::Global; R = thorin::Def]: Assertion `(!r || dynamic_cast<L*>(r)) && "cast not possible"' failed.
Various seemingly irrelevant changes to the code such as, e.g., turning the else option in the initalization into a lambda that simply forwards to the original function
let fun = if b { @|| { asm("nanosleep.u32 0;"); } } else { @|| threadfence() };
seem to resolve the issue in some cases but not others. None of these workarounds appear to be reliable in the context of a more complex codebase; something what worked in one example won't work in another.
the following code will reproduce the issue:
compilation via artic with
--emit-llvmresults inVarious seemingly irrelevant changes to the code such as, e.g., turning the else option in the initalization into a lambda that simply forwards to the original function
seem to resolve the issue in some cases but not others. None of these workarounds appear to be reliable in the context of a more complex codebase; something what worked in one example won't work in another.