[clang] [llvm] [ValueLattice][SCCP] Do not track undefs (PR #107105)
Yingwei Zheng via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 3 07:29:27 PDT 2024
https://github.com/dtcxzyw commented:
Crash reproducer:
```
; bin/opt -passes=sccp reduced.ll -S
define void @debug_send_line1() {
%1 = load ptr, ptr null, align 8
%2 = load ptr, ptr %1, align 8
call void %2()
ret void
}
define void @debug_send_line2() {
%1 = load ptr, ptr undef, align 8
%2 = load ptr, ptr %1, align 8
call void %2()
ret void
}
define void @debug_send_line3() {
%1 = load ptr, ptr undef, align 8
%2 = load ptr, ptr %1, align 8
call void %2()
ret void
}
```
```
opt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/Transforms/Utils/SCCPSolver.cpp:826: const llvm::ValueLatticeElement& llvm::SCCPInstVisitor::getLatticeValueFor(llvm::Value*) const: Assertion `I != ValueState.end() && "V not found in ValueState nor Paramstate map!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: bin/opt -passes=sccp reduced.ll -S
1. Running pass "function(sccp)" on module "reduced.ll"
2. Running pass "sccp" on function "debug_send_line1"
#0 0x000077578b812c32 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x212c32)
#1 0x000077578b80faff llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x20faff)
#2 0x000077578b80fc45 SignalHandler(int) Signals.cpp:0:0
#3 0x000077578b242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000077578b2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x000077578b2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x000077578b2969fc pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x000077578b242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x000077578b2287f3 abort ./stdlib/abort.c:81:7
#9 0x000077578b22871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x000077578b239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x0000775784c5ba0d llvm::SCCPInstVisitor::getLatticeValueFor(llvm::Value*) const (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMTransformUtils.so.20.0git+0x25ba0d)
#12 0x0000775784c6bfc8 llvm::SCCPInstVisitor::getConstantOrNull(llvm::Value*) const (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMTransformUtils.so.20.0git+0x26bfc8)
#13 0x0000775784c6c630 llvm::SCCPSolver::tryToReplaceWithConstant(llvm::Value*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMTransformUtils.so.20.0git+0x26c630)
#14 0x0000775784c6cc08 llvm::SCCPSolver::simplifyInstsInBlock(llvm::BasicBlock&, llvm::SmallPtrSetImpl<llvm::Value*>&, llvm::TrackingStatistic&, llvm::TrackingStatistic&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMTransformUtils.so.20.0git+0x26cc08)
#15 0x000077578533fa02 llvm::SCCPPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMScalarOpts.so.20.0git+0x33fa02)
#16 0x0000775786cd4145 llvm::detail::PassModel<llvm::Function, llvm::SCCPPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.20.0git+0xd4145)
#17 0x0000775783f51d0d llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x351d0d)
#18 0x000077578a2d7f95 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.20.0git+0xd7f95)
#19 0x0000775783f50876 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x350876)
#20 0x000077578a2d8955 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.20.0git+0xd8955)
#21 0x0000775783f4e83a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x34e83a)
#22 0x000077578b972fc7 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) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x2cfc7)
#23 0x000077578b97e962 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x38962)
#24 0x000077578b229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#25 0x000077578b229e40 call_init ./csu/../csu/libc-start.c:128:20
#26 0x000077578b229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#27 0x000063ae8b28e095 _start (bin/opt+0x1095)
Aborted (core dumped)
```
https://github.com/llvm/llvm-project/pull/107105
More information about the cfe-commits
mailing list