[llvm] [X86, SimplifyCFG] Support hoisting load/store with conditional faulting (Part I) (PR #96878)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 4 00:28:50 PDT 2024


https://github.com/dtcxzyw requested changes to this pull request.

```
; bin/llc -mattr=+cf reduced.ll -o -
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 i32 @main(i1 %tobool118.not.3.i, ptr %p) {
entry:
  store i1 false, ptr %p, align 2
  br i1 %tobool118.not.3.i, label %cleanup425.thread.3.i, label %func_109.exit

cleanup425.thread.3.i:                            ; preds = %entry
  store i32 0, ptr %p, align 8
  store i1 false, ptr %p, align 2
  br label %func_109.exit

func_109.exit:                                    ; preds = %cleanup425.thread.3.i, %entry
  ret i32 0
}
```
```
llc: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/include/llvm/IR/Instructions.h:1583: void llvm::SelectInst::init(llvm::Value*, llvm::Value*, llvm::Value*): Assertion `!areInvalidOperands(C, S1, S2) && "Invalid operands for select"' 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/llc -mattr=+cf out.ll
1.      Running pass 'Function Pass Manager' on module 'out.ll'.
2.      Running pass 'Simplify the CFG' on function '@main'
 #0 0x00007ffff040fc62 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x20fc62)
 #1 0x00007ffff040cb2f llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x20cb2f)
 #2 0x00007ffff040cc75 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fffefa42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007fffefa969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007fffefa969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007fffefa969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007fffefa42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007fffefa287f3 abort ./stdlib/abort.c:81:7
 #9 0x00007fffefa2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007fffefa39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00007ffff0897672 llvm::IRBuilderBase::CreateSelect(llvm::Value*, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMCore.so.20.0git+0x297672)
#12 0x00007ffff18a709a (anonymous namespace)::SimplifyCFGOpt::speculativelyExecuteBB(llvm::BranchInst*, llvm::BasicBlock*) SimplifyCFG.cpp:0:0
#13 0x00007ffff18bde03 llvm::simplifyCFG(llvm::BasicBlock*, llvm::TargetTransformInfo const&, llvm::DomTreeUpdater*, llvm::SimplifyCFGOptions const&, llvm::ArrayRef<llvm::WeakVH>) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMTransformUtils.so.20.0git+0x2bde03)
#14 0x00007ffff1fb60ee iterativelySimplifyCFG(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DomTreeUpdater*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0
#15 0x00007ffff1fb7402 simplifyFunctionCFGImpl(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DominatorTree*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0
#16 0x00007ffff1fb7c05 simplifyFunctionCFG(llvm::Function&, llvm::TargetTransformInfo const&, llvm::DominatorTree*, llvm::SimplifyCFGOptions const&) SimplifyCFGPass.cpp:0:0
#17 0x00007ffff08fbf88 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMCore.so.20.0git+0x2fbf88)
#18 0x00007ffff08fc591 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMCore.so.20.0git+0x2fc591)
#19 0x00007ffff08fb257 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMCore.so.20.0git+0x2fb257)
#20 0x0000555555574bae compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#21 0x0000555555567fdd main (bin/llc+0x13fdd)
#22 0x00007fffefa29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#23 0x00007fffefa29e40 call_init ./csu/../csu/libc-start.c:128:20
#24 0x00007fffefa29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#25 0x0000555555568e15 _start (bin/llc+0x14e15)
Aborted (core dumped)
```


https://github.com/llvm/llvm-project/pull/96878


More information about the llvm-commits mailing list