[llvm-bugs] [Bug 31997] New: llvm_unreachable being reached in ARMConstantIslandPass, initializeFunctionInfo

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 17 16:57:36 PST 2017


http://bugs.llvm.org/show_bug.cgi?id=31997

            Bug ID: 31997
           Summary: llvm_unreachable being reached in
                    ARMConstantIslandPass, initializeFunctionInfo
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: ARM
          Assignee: unassignedbugs at nondot.org
          Reporter: cmtice at google.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 18003
  --> http://bugs.llvm.org/attachment.cgi?id=18003&action=edit
C file generated by clang driver for filing bug after clang crashed

The switch statements in initializeFunctionInfo, in ARMConstantPass.cpp are
supposed to handle all the ARM opcodes, but do not handle t2LDRBpci

This causes execution to reach the 'llvm_unreachable' statement at line 755,
(the default case in the 'switch (Opc)' statment) in
ARMCOnstantIslands::initializeFunctionInfo, in ARMConstantIslandPass.cpp.

We found this bug by compiling pam_handlers.c -- we were seeing some very odd
behavior out of the compiler when compiling that file.  After spending some
time tracking it down, we narrowed it down to: the Opc is NOT recognized by the
switch statement, so it goes to the default case (llvm_unreachable), which does
nothing in a Release build, but which caused unexpected/undefined behavior in
the rest of the compilation.

We verified that this was what was happening by replacing that llvm_unreachable
statement with 'abort();'.  This results in a crash when compiling
pam_handlers.c

I am attaching the two files the clang driver created, for filing bugs, when
the crash occurred.


We also examined the crash site in gdb, which is how we found the exact opcode
that is not being handled:
Breakpoint 1, 0x00007ffff0759940 in abort () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff0759940 in abort () from /lib64/libc.so.6
#1  0x00007ffff43dba4c in (anonymous
namespace)::ARMConstantIslands::initializeFunctionInfo (this=0x59a4d70,
CPEMIs=...)
    at
/var/tmp/portage/sys-devel/llvm-4.0_pre285905-r3/work/llvm-4.0_pre285905/lib/Target/ARM/ARMConstantIslandPass.cpp:756
#2  0x00007ffff43d9e2d in (anonymous
namespace)::ARMConstantIslands::runOnMachineFunction (this=0x59a4d70, mf=...)
    at
/var/tmp/portage/sys-devel/llvm-4.0_pre285905-r3/work/llvm-4.0_pre285905/lib/Target/ARM/ARMConstantIslandPass.cpp:372
#3  0x00007ffff2d1d77a in llvm::MachineFunctionPass::runOnFunction (
    this=0x59a4d70, F=...)
    at
/var/tmp/portage/sys-devel/llvm-4.0_pre285905-r3/work/llvm-4.0_pre285905/lib/CodeGen/MachineFunctionPass.cpp:62
#4  0x00007ffff2aa004d in llvm::FPPassManager::runOnFunction (this=0x5988ed0, 
    F=...)
    at
/var/tmp/portage/sys-devel/llvm-4.0_pre285905-r3/work/llvm-4.0_pre285905/lib/IR/LegacyPassManager.cpp:1509
#5  0x00007ffff2aa0213 in llvm::FPPassManager::runOnModule (this=0x5988ed0, 
    M=...)
    at
/var/tmp/portage/sys-devel/llvm-4.0_pre285905-r3/work/llvm-4.0_pre285905/lib/IR/LegacyPassManager.cpp:1530
...
(gdb) up
#1  0x00007ffff43dba4c in (anonymous
namespace)::ARMConstantIslands::initializeFunctionInfo (this=0x59a4d70,
CPEMIs=...)
    at
/var/tmp/portage/sys-devel/llvm-4.0_pre285905-r3/work/llvm-4.0_pre285905/lib/Target/ARM/ARMConstantIslandPass.cpp:756
756                 abort();
(gdb) list
751               bool IsSoImm = false;
752     
753               switch (Opc) {
754               default:
755                 //llvm_unreachable("Unknown addressing mode for CP
reference!");
756                 abort();
757     
758               // Taking the address of a CP entry.
759               case ARM::LEApcrel:
760               case ARM::LEApcrelJT:
(gdb) print Opc
$1 = 2645
(gdb) print I.dump()
  %R0<def> = t2LDRBpci <cp#1>, pred:14, pred:%noreg; mem:LD1[getelementptr
inbounds ([2 x i8], [2 x i8]* @.str.53, i32 0, i32 0)]
dbg:../../../../../../../../usr/armv7a-cros-linux-gnueabi/usr/include/bits/string3.h:99:10
@[ pam_handlers.c:741:11 ]
$2 = void
(gdb)

-- 
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/20170218/2dc49b4c/attachment.html>


More information about the llvm-bugs mailing list