AnyDSL / thorin

The Higher-Order Intermediate Representation
https://anydsl.github.io
GNU Lesser General Public License v3.0
150 stars 15 forks source link

calling cuda()/nvvm() intrinsics with empty body triggers assertion… #127

Open michael-kenzel opened 2 years ago

michael-kenzel commented 2 years ago

…when called from exported function if there is a variable in scope that is initialized to a different lambda depending on function parameter.

repro:

#[import(cc = "thorin")] fn nvvm(_dev: i32, _grid: (i32, i32, i32), _block: (i32, i32, i32), _body: fn() -> ()) -> ();

#[export]
fn test(b: bool) -> () {
    let fun = if b { @||{} } else { @||{} };

    nvvm(0, (1, 1, 1), (1, 1, 1), @||{});
}

compilation via artic with --emit-llvm results in

src/thorin/be/codegen.cpp:39: thorin::get_kernel_configs(thorin::Importer&, const std::vector<thorin::Continuation*>&, thorin::Cont2Config&, std::function<std::unique_ptr<thorin::KernelConfig>(thorin::Continuation*, thorin::Continuation*)>)::<lambda(thorin::Continuation*)>: Assertion `p.second && "single kernel config entry expected"' failed.
Hugobros3 commented 2 years ago

Most likely related to https://github.com/AnyDSL/thorin/issues/128, let's consolidate discussion there