[llvm] [MachineSink] Fix missing sinks along critical edges (PR #97618)
Alexander Kornienko via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 11 09:11:44 PDT 2024
alexfh wrote:
The reduced test case is:
```
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
target triple = "aarch64-generic-linux-gnu"
define void @_f(ptr %project, i1 %cmp.i.i.not9.i) {
entry:
%bf.load.i.i.i.i = load i8, ptr %project, align 1
%tobool.i.i.i.i = icmp slt i8 %bf.load.i.i.i.i, 0
br i1 %tobool.i.i.i.i, label %cond.true.i9.i.i, label %_ZNKSt3__u12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16__get_short_sizeEv.exit.i.i.i
cond.true.i9.i.i: ; preds = %entry
%0 = load i64, ptr %project, align 8
br label %_ZNKSt3__u12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4cendEv.exit
_ZNKSt3__u12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16__get_short_sizeEv.exit.i.i.i: ; preds = %entry
%conv13.i.i.i.i = zext i8 %bf.load.i.i.i.i to i64
br label %_ZNKSt3__u12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4cendEv.exit
_ZNKSt3__u12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4cendEv.exit: ; preds = %_ZNKSt3__u12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16__get_short_sizeEv.exit.i.i.i, %cond.true.i9.i.i
%cond.i8.i.i5 = phi i64 [ %0, %cond.true.i9.i.i ], [ %conv13.i.i.i.i, %_ZNKSt3__u12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE16__get_short_sizeEv.exit.i.i.i ]
br i1 %cmp.i.i.not9.i, label %common.ret, label %for.body.i
for.cond.i: ; preds = %for.body.i
%incdec.ptr.i.i = getelementptr i8, ptr %__first.sroa.0.010.i, i64 1
%cmp.i.i.not.i = icmp eq i64 %cond.i8.i.i5, 0
br i1 %cmp.i.i.not.i, label %common.ret, label %for.body.i
for.body.i: ; preds = %for.cond.i, %_ZNKSt3__u12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4cendEv.exit
%__first.sroa.0.010.i = phi ptr [ %incdec.ptr.i.i, %for.cond.i ], [ %project, %_ZNKSt3__u12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4cendEv.exit ]
%1 = load i8, ptr %__first.sroa.0.010.i, align 1
%isdigit = icmp eq i8 %1, 0
br i1 %isdigit, label %cond.false, label %for.cond.i
common.ret: ; preds = %cond.end.i.thread.i.i72, %cond.false, %for.cond.i, %_ZNKSt3__u12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4cendEv.exit
ret void
cond.false: ; preds = %for.body.i
br i1 %tobool.i.i.i.i, label %common.ret, label %cond.end.i.thread.i.i72
cond.end.i.thread.i.i72: ; preds = %cond.false
%conv13.i.i.i.i73 = zext i8 %bf.load.i.i.i.i to i64
store i64 %conv13.i.i.i.i73, ptr %project, align 8
br label %common.ret
}
```
```
./clang-checked-bad -O2 --target=aarch64-generic-linux-gnu -mcpu=neoverse-n1 -mtune=generic -fsanitize=hwaddress -mllvm -hwasan-inline-fast-path-checks=0 -c reduced.ll -o /dev/null
assertion failed at llvm-project/llvm/lib/CodeGen/MachineBasicBlock.cpp:877 in void llvm::MachineBasicBlock::replaceSuccessor(MachineBasicBlock *, MachineBasicBlock *): OldI != E && "Old is not a successor of this block"
@ 0x556998ae3cc4 __assert_fail
@ 0x556997022219 llvm::MachineBasicBlock::replaceSuccessor()
@ 0x5569970239b6 llvm::MachineBasicBlock::SplitCriticalEdge()
@ 0x5569971558fc (anonymous namespace)::MachineSinking::runOnMachineFunction()
@ 0x55699709c590 llvm::MachineFunctionPass::runOnFunction()
@ 0x556998795cb2 llvm::FPPassManager::runOnFunction()
@ 0x55699879dbc4 llvm::FPPassManager::runOnModule()
@ 0x5569987967a3 llvm::legacy::PassManagerImpl::run()
@ 0x55699355f9fc clang::EmitBackendOutput()
@ 0x5569931b6a3c clang::CodeGenAction::ExecuteAction()
@ 0x556993e9d4c3 clang::FrontendAction::Execute()
@ 0x556993e17d8d clang::CompilerInstance::ExecuteAction()
@ 0x556992e2a6d8 clang::ExecuteCompilerInvocation()
@ 0x556992e1ead6 cc1_main()
...
```
Please fix or revert. Thanks!
https://github.com/llvm/llvm-project/pull/97618
More information about the llvm-commits
mailing list