[llvm-dev] LLVM behavior different depending on function symbol name
Tom Stellard via llvm-dev
llvm-dev at lists.llvm.org
Mon Jun 19 08:58:16 PDT 2017
On 06/19/2017 11:45 AM, Andrew Kelley via llvm-dev wrote:
> Greetings,
>
> I have a Zig implementation of ceil which is emitted into LLVM IR like this:
>
> ; Function Attrs: nobuiltin nounwind
> define internal fastcc float @ceil(float) unnamed_addr #3 !dbg !644 {
> Entry:
> %x = alloca float, align 4
> store float %0, float* %x
> call void @llvm.dbg.declare(metadata float* %x, metadata !649, metadata !494), !dbg !651
> %1 = load float, float* %x, !dbg !652
> %2 = call fastcc float @ceil32(float %1) #8, !dbg !656
> ret float %2, !dbg !657
> }
>
What does the declaration of @ceil32() look like ?
> Test case:
>
> test "math.ceil" {
> assert(ceil(f32(0.0)) == ceil32(0.0));
> assert(ceil(f64(0.0)) == ceil64(0.0));
> }
>
>
> When I compile with optimizations on, this test case fails. The optimized code for the test case ends up being a call to panic (assertion failure), which means that LLVM determined the test failed at compile-time.
>
> What's strange about this is that if I change the function name from @ceil to @ceil_asdf (and change the callers) then the test passes.
>
> So I think LLVM is doing some kind of string comparison on the symbol name and detecting that it is "ceil" and then having different, undesired behavior.
>
> I tried putting `nobuiltin` in the function attributes and at the callsite, but that did not change anything.
>
> Any ideas what's going on?
>
> Downstream issue: https://github.com/zig-lang/zig/issues/393
>
> Regards,
> Andrew
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
More information about the llvm-dev
mailing list