[llvm] [X86,SimplifyCFG] Use passthru to reduce select (PR #108754)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 15 19:58:41 PDT 2024


phoebewang wrote:

> ```
> ; bin/opt -mtriple=x86_64 -mattr=+cf -passes='simplifycfg<hoist-loads-stores-with-cond-faulting>' reduced.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-pc-linux-gnu"
> 
> define i32 @str_transcode0(i1 %0, ptr %1, i1 %.not135, ptr %p) {
> rb_check_arity.exit:
>   br i1 %0, label %.thread, label %2
> 
> 2:                                                ; preds = %rb_check_arity.exit
>   br i1 %.not135, label %3, label %.thread
> 
> 3:                                                ; preds = %2
>   %4 = load i64, ptr %p, align 8
>   br label %.thread
> 
> .thread:                                          ; preds = %3, %2, %rb_check_arity.exit
>   %5 = phi i64 [ %4, %3 ], [ 0, %2 ], [ 0, %rb_check_arity.exit ]
>   store i64 %5, ptr %1, align 8
>   ret i32 0
> }
> ```
> 
> ```
> Instruction does not dominate all uses!
>   %5 = bitcast <1 x i64> %4 to i64
>   store i64 %5, ptr %1, align 8
> LLVM ERROR: Broken module found, compilation aborted!
> 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 -mtriple=x86_64 -mattr=+cf -passes=simplifycfg<hoist-loads-stores-with-cond-faulting> reduced.ll -S
> 1.      Running pass "verify" on module "reduced.ll"
>  #0 0x00007e6a03014742 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x214742)
>  #1 0x00007e6a0301160f llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x21160f)
>  #2 0x00007e6a03011755 SignalHandler(int) Signals.cpp:0:0
>  #3 0x00007e6a02a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
>  #4 0x00007e6a02a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
>  #5 0x00007e6a02a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
>  #6 0x00007e6a02a969fc pthread_kill ./nptl/pthread_kill.c:89:10
>  #7 0x00007e6a02a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
>  #8 0x00007e6a02a287f3 abort ./stdlib/abort.c:81:7
>  #9 0x00007e6a02e6d70f llvm::report_fatal_error(llvm::Twine const&, bool) (.cold) ErrorHandling.cpp:0:0
> #10 0x00007e6a02f1cc90 unsigned long std::uniform_int_distribution<unsigned long>::operator()<std::random_device>(std::random_device&, std::uniform_int_distribution<unsigned long>::param_type const&) (.isra.0) ExponentialBackoff.cpp:0:0
> #11 0x00007e69fb996428 (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x396428)
> #12 0x00007e6a0323b645 llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x1f645)
> #13 0x00007e69fb95386a 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+0x35386a)
> #14 0x00007e6a032491b1 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+0x2d1b1)
> #15 0x00007e6a03254934 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x38934)
> #16 0x00007e6a02a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
> #17 0x00007e6a02a29e40 call_init ./csu/../csu/libc-start.c:128:20
> #18 0x00007e6a02a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
> #19 0x000060da02e96095 _start (bin/opt+0x1095)
> Aborted (core dumped)
> ```

Thanks for the test case! Fixed.

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


More information about the llvm-commits mailing list