https://bugs.llvm.org/show_bug.cgi?id=47090

            Bug ID: 47090
           Summary: icmp gives inconsistent result for unnamed functions
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: post+l...@ralfj.de
                CC: llvm-bugs@lists.llvm.org

A Rust user found a case where comparison with icmp is non-deterministic:
https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=8affd2a65b02a35e16dbab4682cb8886.

What this does is it take pointers to two functions that are marked as
"unnamed", casts those pointers to integers, and then compares them twice --
once after passing them through a "black box" noinline function, and once
immediately. The compiler seemingly optimized the latter comparison to "false",
but later makes the two function's addresses identical.

If we describe the semantics of this program at the LLVM IR level, then I think
we have to either accept that "icmp" can produce different results for the same
input (it is non-deterministic), or the program has to have UB.  But it's not
UB to compare "unnamed function" pointers, right?  My expectation was that
unnamed function can end up having the same or different addresses depending on
optimizer decisions etc, but whether it is one or the other has to be
consistent throughout a single execution of the program.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to