[llvm-bugs] [Bug 33538] New: Constant hoisting crashes AddressingModeMatcher::matchOperationAddr
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jun 20 18:21:07 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33538
Bug ID: 33538
Summary: Constant hoisting crashes
AddressingModeMatcher::matchOperationAddr
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: pirama at google.com
CC: llvm-bugs at lists.llvm.org
Created attachment 18679
--> https://bugs.llvm.org/attachment.cgi?id=18679&action=edit
Repro case
The attached test case tclTest.ll crashes llc [1]:
Since Tcltest_init has optsize attribute, constant hoisting changes it to:
; Function Attrs: norecurse nounwind optsize readonly
define i32 @Tcltest_Init() local_unnamed_addr #0 {
entry:
%const = bitcast i32 256 to i32
%0 = load %struct.TclStubs*, %struct.TclStubs** @tclStubsPtr, align 4, !tbaa
!3
%const_mat = add i32 %const, 2
%tcl_GetVar2Ex = getelementptr inbounds %struct.TclStubs, %struct.TclStubs*
%0, i32 0, i32 %const_mat
%1 = load i32, i32* %tcl_GetVar2Ex, align 4, !tbaa !7
%cmp = icmp eq i32 %1, 0
br i1 %cmp, label %cleanup, label %if.then
if.then: ; preds = %entry
%tcl_ListObjGetElements = getelementptr inbounds %struct.TclStubs,
%struct.TclStubs* %0, i32 0, i32 %const
%2 = load i32, i32* %tcl_ListObjGetElements, align 4, !tbaa !10
br label %cleanup
cleanup: ; preds = %if.then, %entry
%retval.0 = phi i32 [ %2, %if.then ], [ 0, %entry ]
ret i32 %retval.0
}
This crashes AddressingModeMatcher::matchOperationAddr which doesn't handle the
case where non-constant offets for struct types. See case
Instruction::GetElementPtr" in this function.
[1]:
llc: llvm/include/llvm/Support/Casting.h:255: typename llvm::cast_retty<X,
Y*>::ret_type llvm::cast(Y*) [with X = llvm::ConstantInt; Y = llvm::Value;
typename llvm::cast_retty<X, Y*>::ret_type = llvm::ConstantInt*]: Assertion
`isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
#0 0x0000000003339799 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
llvm/lib/Support/Unix/Signals.inc:398:0
#1 0x000000000333982a PrintStackTraceSignalHandler(void*)
llvm/lib/Support/Unix/Signals.inc:462:0
#2 0x0000000003337c70 llvm::sys::RunSignalHandlers()
llvm/lib/Support/Signals.cpp:49:0
#3 0x0000000003339131 SignalHandler(int)
llvm/lib/Support/Unix/Signals.inc:252:0
#4 0x00007f1ba72e5330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#5 0x00007f1ba60ddc37 gsignal
/build/eglibc-MjiXCM/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#6 0x00007f1ba60e1028 abort
/build/eglibc-MjiXCM/eglibc-2.19/stdlib/abort.c:91:0
#7 0x00007f1ba60d6bf6 __assert_fail_base
/build/eglibc-MjiXCM/eglibc-2.19/assert/assert.c:92:0
#8 0x00007f1ba60d6ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#9 0x00000000012ec1ae llvm::cast_retty<llvm::ConstantInt,
llvm::Value*>::ret_type llvm::cast<llvm::ConstantInt,
llvm::Value>(llvm::Value*) llvm/include/llvm/Support/Casting.h:257:0
#10 0x000000000276eaa4 (anonymous
namespace)::AddressingModeMatcher::matchOperationAddr(llvm::User*, unsigned
int, unsigned int, bool*) llvm/lib/CodeGen/CodeGenPrepare.cpp:3739:0
#11 0x000000000276f615 (anonymous
namespace)::AddressingModeMatcher::matchAddr(llvm::Value*, unsigned int)
llvm/lib/CodeGen/CodeGenPrepare.cpp:3902:0
#12 0x000000000276ce1d (anonymous
namespace)::AddressingModeMatcher::Match(llvm::Value*, llvm::Type*, unsigned
int, llvm::Instruction*, llvm::SmallVectorImpl<llvm::Instruction*>&,
llvm::TargetLowering const&, llvm::TargetRegisterInfo const&,
llvm::SmallPtrSet<llvm::Instruction*, 16u> const&,
llvm::DenseMap<llvm::Instruction*, llvm::PointerIntPair<llvm::Type*, 1u, bool,
llvm::PointerLikeTypeTraits<llvm::Type*>, llvm::PointerIntPairInfo<llvm::Type*,
1u, llvm::PointerLikeTypeTraits<llvm::Type*> > >,
llvm::DenseMapInfo<llvm::Instruction*>,
llvm::detail::DenseMapPair<llvm::Instruction*,
llvm::PointerIntPair<llvm::Type*, 1u, bool,
llvm::PointerLikeTypeTraits<llvm::Type*>, llvm::PointerIntPairInfo<llvm::Type*,
1u, llvm::PointerLikeTypeTraits<llvm::Type*> > > > >&, (anonymous
namespace)::TypePromotionTransaction&)
llvm/lib/CodeGen/CodeGenPrepare.cpp:3140:0
#13 0x000000000277088a (anonymous
namespace)::CodeGenPrepare::optimizeMemoryInst(llvm::Instruction*,
llvm::Value*, llvm::Type*, unsigned int)
llvm/lib/CodeGen/CodeGenPrepare.cpp:4271:0
#14 0x0000000002777e7d (anonymous
namespace)::CodeGenPrepare::optimizeInst(llvm::Instruction*, bool&)
llvm/lib/CodeGen/CodeGenPrepare.cpp:6099:0
#15 0x000000000277864a (anonymous
namespace)::CodeGenPrepare::optimizeBlock(llvm::BasicBlock&, bool&)
llvm/lib/CodeGen/CodeGenPrepare.cpp:6203:0
#16 0x00000000027621db (anonymous
namespace)::CodeGenPrepare::runOnFunction(llvm::Function&)
llvm/lib/CodeGen/CodeGenPrepare.cpp:354:0
#17 0x0000000002c6e58a llvm::FPPassManager::runOnFunction(llvm::Function&)
llvm/lib/IR/LegacyPassManager.cpp:1519:0
#18 0x0000000002c6e71d llvm::FPPassManager::runOnModule(llvm::Module&)
llvm/lib/IR/LegacyPassManager.cpp:1540:0
#19 0x0000000002c6eab8 (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&)
llvm/lib/IR/LegacyPassManager.cpp:1596:0
#20 0x0000000002c6f208 llvm::legacy::PassManagerImpl::run(llvm::Module&)
llvm/lib/IR/LegacyPassManager.cpp:1699:0
#21 0x0000000002c6f449 llvm::legacy::PassManager::run(llvm::Module&)
llvm/lib/IR/LegacyPassManager.cpp:1731:0
#22 0x00000000012a6b0b compileModule(char**, llvm::LLVMContext&)
llvm/tools/llc/llc.cpp:611:0
#23 0x00000000012a4f5c main llvm/tools/llc/llc.cpp:350:0
#24 0x00007f1ba60c8f45 __libc_start_main
/build/eglibc-MjiXCM/eglibc-2.19/csu/libc-start.c:321:0
#25 0x00000000012a2e09 _start (llvm-build/bin/llc+0x12a2e09)
Stack dump:
0. Program arguments: llvm-build/bin/llc tclTest.ll
1. Running pass 'Function Pass Manager' on module 'tclTest.ll'.
2. Running pass 'CodeGen Prepare' on function '@Tcltest_Init'
--
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/20170621/706ee7a1/attachment.html>
More information about the llvm-bugs
mailing list