Issue 87441
Summary [Inline] Assert getOperand() out of range! failed.
Labels new issue
Assignees
Reporter patrick-rivos
    Reduced LLVM IR
```llvm ir
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "riscv64-unknown-linux-gnu"

define fastcc void @w() {
entry:
 br label %if.then

land.end.thread:                                  ; No predecessors!
  br label %if.then

if.then: ; preds = %land.end.thread, %entry
  %conv246 = phi i8 [ 0, %land.end.thread ], [ 0, %entry ]
  %0 = load i32, ptr null, align 4
  %.fr = freeze i32 %0
  %conv17 = trunc i32 %.fr to i8
  %cmp21 = icmp eq i8 %conv246, %conv17
  ret void
}

define noundef i32 @main() {
entry:
  call fastcc void @w()
  ret i32 0
}
```

Backtrace:
```
opt: /scratch/tc-testing/tc-apr-2/llvm/llvm/include/llvm/IR/User.h:170: llvm::Value* llvm::User::getOperand(unsigned int) const: Assertion `i < NumUserOperands && "getOperand() out of range!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt --passes=inline reduced.ll
 #0 0x0000596575f89b60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d84b60)
 #1 0x0000596575f86f6f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2d81f6f)
 #2 0x0000596575f870c5 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007c2e96442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007c2e964969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007c2e964969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007c2e964969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007c2e96442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007c2e964287f3 abort ./stdlib/abort.c:81:7
 #9 0x00007c2e9642871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007c2e96439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00005965756eb338 (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x24e6338)
#12 0x00005965756f45a5 bool handleGuaranteedNonPoisonOps<llvm::mustTriggerUB(llvm::Instruction const*, llvm::SmallPtrSetImpl<llvm::Value const*> const&)::'lambda'(llvm::Value const*)>(llvm::Instruction const*, llvm::mustTriggerUB(llvm::Instruction const*, llvm::SmallPtrSetImpl<llvm::Value const*> const&)::'lambda'(llvm::Value const*) const&) ValueTracking.cpp:0:0
#13 0x00005965756f593c programUndefinedIfUndefOrPoison(llvm::Value const*, bool) ValueTracking.cpp:0:0
#14 0x0000596575703516 isGuaranteedNotToBeUndefOrPoison(llvm::Value const*, llvm::AssumptionCache*, llvm::Instruction const*, llvm::DominatorTree const*, unsigned int, UndefPoisonKind) ValueTracking.cpp:0:0
#15 0x000059657570ac94 computeKnownBits(llvm::Value const*, llvm::APInt const&, llvm::KnownBits&, unsigned int, llvm::SimplifyQuery const&) ValueTracking.cpp:0:0
#16 0x000059657570e278 llvm::computeKnownBits(llvm::Value const*, llvm::KnownBits&, unsigned int, llvm::SimplifyQuery const&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2509278)
#17 0x000059657570bcee computeKnownBits(llvm::Value const*, llvm::APInt const&, llvm::KnownBits&, unsigned int, llvm::SimplifyQuery const&) ValueTracking.cpp:0:0
#18 0x0000596575706dda isKnownNonZeroFromOperator(llvm::Operator const*, llvm::APInt const&, unsigned int, llvm::SimplifyQuery const&) ValueTracking.cpp:0:0
#19 0x0000596575708b34 isKnownNonZero(llvm::Value const*, llvm::APInt const&, unsigned int, llvm::SimplifyQuery const&) ValueTracking.cpp:0:0
#20 0x000059657571809f isKnownNonZero(llvm::Value const*, unsigned int, llvm::SimplifyQuery const&) ValueTracking.cpp:0:0
#21 0x0000596575718f44 llvm::isKnownNonZero(llvm::Value const*, llvm::DataLayout const&, unsigned int, llvm::AssumptionCache*, llvm::Instruction const*, llvm::DominatorTree const*, bool) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2513f44)
#22 0x00005965754f9cae simplifyICmpInst(unsigned int, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, unsigned int) InstructionSimplify.cpp:0:0
#23 0x00005965754f59c8 simplifyInstructionWithOperands(llvm::Instruction*, llvm::ArrayRef<llvm::Value*>, llvm::SimplifyQuery const&, unsigned int) InstructionSimplify.cpp:0:0
#24 0x000059657550765a llvm::simplifyInstruction(llvm::Instruction*, llvm::SimplifyQuery const&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x230265a)
#25 0x0000596575186e0b llvm::CloneAndPruneIntoFromInst(llvm::Function*, llvm::Function const*, llvm::Instruction const*, llvm::ValueMap<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false>>>&, bool, llvm::SmallVectorImpl<llvm::ReturnInst*>&, char const*, llvm::ClonedCodeInfo*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1f81e0b)
#26 0x0000596575187069 llvm::CloneAndPruneFunctionInto(llvm::Function*, llvm::Function const*, llvm::ValueMap<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false>>>&, bool, llvm::SmallVectorImpl<llvm::ReturnInst*>&, char const*, llvm::ClonedCodeInfo*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1f82069)
#27 0x00005965751f39ff llvm::InlineFunction(llvm::CallBase&, llvm::InlineFunctionInfo&, bool, llvm::AAResults*, bool, llvm::Function*) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1fee9ff)
#28 0x000059657480a100 llvm::InlinerPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x1605100)
#29 0x0000596573f11426 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::InlinerPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd0c426)
#30 0x00005965753ea04d llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x21e504d)
#31 0x0000596573f0deb6 llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd08eb6)
#32 0x00005965753ebdad llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x21e6dad)
#33 0x0000596573f0de66 llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0xd08e66)
#34 0x0000596575daccb1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x2ba7cb1)
#35 0x0000596573787ce5 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) (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x582ce5)
#36 0x000059657377a316 optMain (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x575316)
#37 0x00007c2e96429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#38 0x00007c2e96429e40 call_init ./csu/../csu/libc-start.c:128:20
#39 0x00007c2e96429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#40 0x000059657376ff95 _start (/scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt+0x56af95)
zsh: IOT instruction (core dumped) /scratch/tc-testing/tc-apr-2/build-rv64gcv/build-llvm-linux/bin/opt
```
Godbolt: https://godbolt.org/z/WoaEY7heK

>From some basic printf debugging: The `%.fr = freeze i32 %0` insn triggers this assert.

Found via fuzzer.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to