Skip to content

[SimplifyCFG] Assertion `IterCnt++ < 1000 && "Iterative simplification didn't converge!"' failed. #165088

@dtcxzyw

Description

@dtcxzyw

Reproducer: https://godbolt.org/z/6q17cxYWh

; bin/opt -passes="simplifycfg<switch-range-to-icmp>" test.ll -S
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define fastcc i32 @func_209(i8 %conv74) {
entry:
  %cmp.i.i = icmp eq i8 %conv74, 0
  %cond = icmp ne i8 %conv74, 0
  %cmp.i44.i.old = icmp ugt i8 %conv74, 0
  %or.cond = and i1 %cond, %cmp.i44.i.old
  br i1 %or.cond, label %safe_mod_func_int16_t_s_s.exit.i, label %cond.false.i45.i

safe_div_func_uint16_t_u_u.exit.i:                ; preds = %safe_mod_func_int16_t_s_s.exit.i
  %cmp.i44.i.old.old = icmp ugt i8 %conv74, 1
  br i1 %cmp.i44.i.old.old, label %safe_mod_func_int16_t_s_s.exit.i, label %cond.false.i45.i

cond.false.i45.i:                                 ; preds = %safe_div_func_uint16_t_u_u.exit.i, %entry
  br label %safe_mod_func_int16_t_s_s.exit.i

safe_mod_func_int16_t_s_s.exit.i:                 ; preds = %cond.false.i45.i, %safe_div_func_uint16_t_u_u.exit.i, %entry
  br i1 %cmp.i.i, label %func_238.exit, label %safe_div_func_uint16_t_u_u.exit.i

func_238.exit:                                    ; preds = %safe_mod_func_int16_t_s_s.exit.i
  ret i32 0
}
opt: /root/llvm-project/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:247: bool iterativelySimplifyCFG(llvm::Function&, const llvm::TargetTransformInfo&, llvm::DomTreeUpdater*, const llvm::SimplifyCFGOptions&): Assertion `IterCnt++ < 1000 && "Iterative simplification didn't converge!"' 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: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=simplifycfg<switch-range-to-icmp> <source>
1.	Running pass "function(simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;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 "<source>"
2.	Running pass "simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;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 "func_209"
 #0 0x0000000005965e58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5965e58)
 #1 0x0000000005962d04 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x000075fcf1c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x000075fcf1c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x000075fcf1c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x000075fcf1c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x000075fcf1c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x000075fcf1c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x00000000048445bc iterativelySimplifyCFG(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DomTreeUpdater*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0
 #9 0x0000000004845304 simplifyFunctionCFGImpl(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DominatorTree*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0
#10 0x0000000004846485 simplifyFunctionCFG(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DominatorTree*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0
#11 0x00000000048465ca llvm::SimplifyCFGPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x48465ca)
#12 0x00000000016da59e llvm::detail::PassModel<llvm::Function, llvm::SimplifyCFGPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x16da59e)
#13 0x0000000005740571 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5740571)
#14 0x0000000000efabfe llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xefabfe)
#15 0x000000000573eada llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x573eada)
#16 0x000000000097af4e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x97af4e)
#17 0x000000000573e491 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x573e491)
#18 0x00000000009850ea 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) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x9850ea)
#19 0x0000000000979361 optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x979361)
#20 0x000075fcf1c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x000075fcf1c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#22 0x0000000000970775 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x970775)
Program terminated with signal: SIGSEGV
Compiler returned: 139

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions