I compared the llvm IR for a simple program between Roc, Rust and Zig. We were using tail call
frequently, whereas the Zig and Rust versions never used it (all were compiled unoptimized). I'm investigating a possible llvm bug and I would like to try emitting regular llvm IR call
s. Anybody know how I can do that?
I've tried changing call.set_tail_call(true);
to false
in refcounting.rs but that did not reduce the number of tail calls for my program.
I think it would be in the actual ir emission.
I think we set it too much.
no LLVM just infers those tail
annotations. they almost never turn into actual tail calls
Oh. Inferred, not explicit. Ok.
Replacing tail call
s with call
s fixed the issue :)
From my understanding the call to @"#UserApp_diffSelf...
should not be marked as a tail call right?
define internal fastcc { %str.RocStr, {} } @"#UserApp_main_f03bf86f79d121cbfd774dec4a65912e99f5f17c33852bbc45e81916e62b53b"() !dbg !52 {
entry:
%const_str_store3 = alloca %str.RocStr, align 8, !dbg !53
%const_str_store = alloca %str.RocStr, align 8, !dbg !53
%call = tail call fastcc i128 @"#UserApp_diffSelf_beb22fad19423347b2aa99b33212e862ded3f83df5d6238acb1a6a9ade3e"(i128 1), !dbg !53
%call1 = tail call fastcc i1 @Bool_structuralEq_c610e85212d0697cb161d4ba431ba63f273feee7dcb7927c9ff5d74ae6cbfa3(i128 %call, i128 0), !dbg !53
br i1 %call1, label %then_block, label %else_block, !dbg !53
it should be harmless? but yeah it's not even in tail position so there is nothing the tail
attribute can do
it should be harmless?
Uhu, yeah it should be, but it was not due to this llvm bug https://github.com/llvm/llvm-project/issues/70207
ah, cool!
Last updated: Jul 06 2025 at 12:14 UTC