-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Open
Copy link
Labels
Description
When running opt on an LLVM IR file that specifies
target triple = "x86_64-unknown-linux-gnu"
opt crashes with an assertion failure. If the target triple is removed from the IR, the same command completes without crashing.
llvm version 3186ca2
test.ll
target triple = "x86_64-unknown-linux-gnu"
define void @bar(i64 %J,ptr %Q) #0 {
entry:
br label %loop.header
loop.header: ; preds = %loop.latch, %entry
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
%g = getelementptr [5 x i32], ptr %Q, i32 %iv, i32 0
%x = call i64 @foo() #1
store i64 %x, ptr %g, align 8
%iv.next = add i32 %iv, 1
%ec = icmp slt i32 %iv.next, 1000
br i1 %ec, label %loop.latch, label %loop.latch
loop.latch: ; preds = %loop.header
%0 = load ptr, ptr %Q, align 8
%1 = load i64, ptr %0, align 1
br label %loop.header
}
declare i64 @foo()
attributes #0 = { "loop-stack-measurement-repeats"="5" "target-cpu"="atom" "target-features"="avx1vex" "is-64bit-build"="true" "set-diagnostic-assert-ub"="1" }
attributes #1 = { "branched-on-count-split"="3" }
commads
./bin/opt -passes=simplifycfg test.ll -S
stacktrace
opt: llvm-project/llvm/lib/MC/MCSubtargetInfo.cpp:62: void ApplyFeatureFlag(llvm::FeatureBitset&, llvm::StringRef, llvm::ArrayRef<llvm::SubtargetFeatureKV>): Assertion `SubtargetFeatures::hasFlag(Feature) && "Feature flags should start with '+' or '-'"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: ./bin/opt -passes=simplifycfg test.ll -S
1. Running pass "function(simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-arithmetic;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>)" on module "test.ll"
2. Running pass "simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;no-switch-range-to-icmp;no-switch-to-arithmetic;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>" on function "bar"
#0 0x0000562973b3859f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./bin/opt+0x560559f)
#1 0x0000562973b3520c llvm::sys::RunSignalHandlers() (./bin/opt+0x560220c)
#2 0x0000562973b353a7 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f550cf5a420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f550c5a700b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007f550c586859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007f550c586729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
#7 0x00007f550c586729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
#8 0x00007f550c597fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#9 0x00005629735c62ce (./bin/opt+0x50932ce)
#10 0x00005629735c7e7b getFeatures(llvm::MCSubtargetInfo&, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::ArrayRef<llvm::SubtargetSubTypeKV>, llvm::ArrayRef<llvm::SubtargetFeatureKV>) (.isra.0) MCSubtargetInfo.cpp:0:0
#11 0x00005629735c882e llvm::MCSubtargetInfo::InitMCProcessorInfo(llvm::StringRef, llvm::StringRef, llvm::StringRef) (./bin/opt+0x509582e)
#12 0x000056297251a6f5 llvm::TargetSubtargetInfo::TargetSubtargetInfo(llvm::Triple const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::ArrayRef<llvm::SubtargetFeatureKV>, llvm::ArrayRef<llvm::SubtargetSubTypeKV>, llvm::MCWriteProcResEntry const*, llvm::MCWriteLatencyEntry const*, llvm::MCReadAdvanceEntry const*, llvm::InstrStage const*, unsigned int const*, unsigned int const*) (./bin/opt+0x3fe76f5)
#13 0x0000562970aa7c72 llvm::X86Subtarget::X86Subtarget(llvm::Triple const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::X86TargetMachine const&, llvm::MaybeAlign, unsigned int, unsigned int) (./bin/opt+0x2574c72)
#14 0x000056297075f99d llvm::X86TargetMachine::getSubtargetImpl(llvm::Function const&) const (./bin/opt+0x222c99d)
#15 0x000056297075fcd9 llvm::X86TargetMachine::getTargetTransformInfo(llvm::Function const&) const (./bin/opt+0x222ccd9)
#16 0x0000562972ba0b58 std::_Function_handler<llvm::TargetTransformInfo (llvm::Function const&), llvm::TargetMachine::getTargetIRAnalysis() const::'lambda'(llvm::Function const&)>::_M_invoke(std::_Any_data const&, llvm::Function const&) TargetMachine.cpp:0:0
#17 0x000056297318f3bd llvm::TargetIRAnalysis::run(llvm::Function const&, llvm::AnalysisManager<llvm::Function>&) (./bin/opt+0x4c5c3bd)
#18 0x000056297101e8c7 llvm::detail::AnalysisPassModel<llvm::Function, llvm::TargetIRAnalysis, llvm::AnalysisManager<llvm::Function>::Invalidator>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./bin/opt+0x2aeb8c7)
#19 0x0000562973903691 llvm::AnalysisManager<llvm::Function>::getResultImpl(llvm::AnalysisKey*, llvm::Function&) (./bin/opt+0x53d0691)
#20 0x00005629729956c3 llvm::SimplifyCFGPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./bin/opt+0x44626c3)
#21 0x000056296fb58b56 llvm::detail::PassModel<llvm::Function, llvm::SimplifyCFGPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./bin/opt+0x1625b56)
#22 0x0000562973904161 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./bin/opt+0x53d1161)
#23 0x000056296f320d26 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./bin/opt+0xdedd26)
#24 0x000056297390279e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./bin/opt+0x53cf79e)
#25 0x000056296ed78b56 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./bin/opt+0x845b56)
#26 0x0000562973902131 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./bin/opt+0x53cf131)
#27 0x000056296ed8357a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) (./bin/opt+0x85057a)
#28 0x000056296ed7694e optMain (./bin/opt+0x84394e)
#29 0x00007f550c588083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#30 0x000056296ed6ceae _start (./bin/opt+0x839eae)