[llvm-bugs] [Bug 41476] New: Segfault in llvm::ConstantFoldCompareInstruction due to reaching an llvm_unreachable.

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 11 21:43:11 PDT 2019


            Bug ID: 41476
           Summary: Segfault in llvm::ConstantFoldCompareInstruction due
                    to reaching an llvm_unreachable.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: bmoses at google.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 21765
  --> https://bugs.llvm.org/attachment.cgi?id=21765&action=edit
Reduced testcase

If we build the attached .cpp file with a version of Clang that's compiled to
warn on reaching unreachable code, and using "-O2" or higher, we get an error
like the following:

Invalid FCmp Predicate
UNREACHABLE executed at llvm/lib/IR/ConstantFold.cpp:1814!
Stack dump:
0.      Program arguments: clang -cc1 -emit-obj -O2 b130316147.cpp 
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'CallGraph Pass Manager' on module 'b130316147.cpp'.
4.      Running pass 'Early CSE w/ MemorySSA' on function '@_Z8TestBodyv'

(That line number is current as of r355685 -- it's in the implementation of

With a "normal" build, this was just silent and the compiler continued and
produced an object file that was approximately correct.

However, hans's r357067, "Re-commit r355490 "[CodeGen] Omit range checks from
jump tables when lowering switches with unreachable default"" changes the
behavior of this switch statement when it would reach the unreachable case in a
no-asserts build, and now we get a segfault instead.

It would be nice to fix the underlying bug, as this segfault is now blocking
our Google-internal releases, and I don't think rolling back r357067 is likely
to be the right answer.

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/20190412/6b9b240f/attachment.html>

More information about the llvm-bugs mailing list