[llvm-bugs] [Bug 43129] New: exhaustive switch with unreachable defaultdest should get cleaned up

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 27 15:48:05 PDT 2019


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

            Bug ID: 43129
           Summary: exhaustive switch with unreachable defaultdest should
                    get cleaned up
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: ndesaulniers at google.com
                CC: llvm-bugs at lists.llvm.org, srhines at google.com
            Blocks: 4068

Created attachment 22437
  --> https://bugs.llvm.org/attachment.cgi?id=22437&action=edit
x.c

Consider the following test case: https://godbolt.org/z/xLKkbK

There's a switch that LLVM deduces to be exhaustive.  During SimplifyCFG, LLVM
transforms the default case to a label with an unreachable IR instruction. 
This never gets removed, which gets lowered to jump to an empty basic block
(usually off the end of the function with no return).  This isn't a bug per se,
but it leaves behind garbage in the object file which confuses the Linux
kernel's object file validator, objtool.

It seems this is only an issue when the case is exhaustive.  Adding additional
cases will just get removed at some point by opt.

It seems like the comparison that would have been used for the default case can
at least be skipped.


Referenced Bugs:

https://bugs.llvm.org/show_bug.cgi?id=4068
[Bug 4068] [Meta] Compiling the Linux kernel with clang
-- 
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/20190827/1a485a0d/attachment.html>


More information about the llvm-bugs mailing list