[llvm-bugs] [Bug 47090] New: icmp gives inconsistent result for unnamed functions
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Aug 10 04:42:50 PDT 2020
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: unassignedbugs at nondot.org
Reporter: post+llvm at ralfj.de
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200810/00a0e3e7/attachment.html>
More information about the llvm-bugs
mailing list