Shane Lin via llvm-dev
2021-Nov-16 09:11 UTC
[llvm-dev] Get Error by using the pass "-targetpassconfig" with opt
I have a IR file, and I want to reproduce the O3 pass manually. I use the following command to get the O3 pass: opt -enable-new-pm=0 -O3 -debug-pass=Arguments main.ll The pass I get: Pass Arguments: -tti -tbaa -scoped-noalias-aa -assumption-cache-tracker -targetlibinfo -verify -lower-expect -simplifycfg -domtree -sroa -early-cse Pass Arguments: -targetlibinfo -tti -targetpassconfig -tbaa -scoped-noalias-aa -assumption-cache-tracker -profile-summary-info -annotation2metadata -forceattrs -inferattrs -domtree -callsite-splitting -ipsccp -called-value-propagation -globalopt -domtree -mem2reg -deadargelim -domtree -basic-aa -aa -loops -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -simplifycfg -basiccg -globals-aa -prune-eh -inline -openmp-opt-cgscc -function-attrs -argpromotion -domtree -sroa -basic-aa -aa -memoryssa -early-cse-memssa -speculative-execution -aa -lazy-value-info -jump-threading -correlated-propagation -simplifycfg -domtree -aggressive-instcombine -basic-aa -aa -loops -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -libcalls-shrinkwrap -loops -postdomtree -branch-prob -block-freq -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -pgo-memop-opt -basic-aa -aa -loops -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -tailcallelim -simplifycfg -reassociate -domtree -basic-aa -aa -memoryssa -loops -loop-simplify -lcssa-verification -lcssa -scalar-evolution -lazy-branch-prob -lazy-block-freq -licm -loop-rotate -licm -loop-unswitch -simplifycfg -domtree -basic-aa -aa -loops -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -loop-simplify -lcssa-verification -lcssa -scalar-evolution -loop-idiom -indvars -loop-deletion -loop-unroll -sroa -aa -mldst-motion -phi-values -aa -memdep -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -gvn -sccp -demanded-bits -bdce -basic-aa -aa -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -lazy-value-info -jump-threading -correlated-propagation -postdomtree -adce -basic-aa -aa -memoryssa -memcpyopt -loops -dse -loop-simplify -lcssa-verification -lcssa -aa -scalar-evolution -lazy-branch-prob -lazy-block-freq -licm -simplifycfg -domtree -basic-aa -aa -loops -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -barrier -elim-avail-extern -basiccg -rpo-function-attrs -globalopt -globaldce -basiccg -globals-aa -domtree -float2int -lower-constant-intrinsics -loops -loop-simplify -lcssa-verification -lcssa -basic-aa -aa -scalar-evolution -loop-rotate -loop-accesses -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -loop-distribute -postdomtree -branch-prob -block-freq -scalar-evolution -basic-aa -aa -loop-accesses -demanded-bits -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -inject-tli-mappings -loop-vectorize -loop-simplify -scalar-evolution -aa -loop-accesses -lazy-branch-prob -lazy-block-freq -loop-load-elim -basic-aa -aa -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -simplifycfg -domtree -loops -scalar-evolution -basic-aa -aa -demanded-bits -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -inject-tli-mappings -slp-vectorizer -vector-combine -opt-remark-emitter -instcombine -loop-simplify -lcssa-verification -lcssa -scalar-evolution -loop-unroll -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instcombine -memoryssa -loop-simplify -lcssa-verification -lcssa -scalar-evolution -lazy-branch-prob -lazy-block-freq -licm -opt-remark-emitter -transform-warning -alignment-from-assumptions -strip-dead-prototypes -globaldce -constmerge -cg-profile -domtree -loops -postdomtree -branch-prob -block-freq -loop-simplify -lcssa-verification -lcssa -basic-aa -aa -scalar-evolution -block-freq -loop-sink -lazy-branch-prob -lazy-block-freq -opt-remark-emitter -instsimplify -div-rem-pairs -simplifycfg -annotation-remarks -verify Pass Arguments: -domtree Pass Arguments: -targetlibinfo -domtree -loops -postdomtree -branch-prob -block-freq Pass Arguments: -targetlibinfo -domtree -loops -postdomtree -branch-prob -block-freq Pass Arguments: -targetlibinfo -domtree -loops -lazy-branch-prob -lazy-block-freq But when I use the second sequence, I got an error message: LLVM ERROR: Trying to construct TargetPassConfig without a target machine. Scheduling a CodeGen pass without a target triple set? PLEASE submit a bug report to https://bugs.llvm.org/ <https://bugs.llvm.org/> and include the crash backtrace. #0 0x00007f5a4503010c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/shane/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:0 #1 0x00007f5a450301c3 PrintStackTraceSignalHandler(void*) /home/shane/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:0 #2 0x00007f5a4502de70 llvm::sys::RunSignalHandlers() /home/shane/llvm-project/llvm/lib/Support/Signals.cpp:97:0 #3 0x00007f5a4502fa8c SignalHandler(int) /home/shane/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:0 #4 0x00007f5a4444b4c0 (/lib/x86_64-linux-gnu/libc.so.6+0x354c0) #5 0x00007f5a4444b438 raise /build/glibc-S7Ft5T/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0 #6 0x00007f5a4444d03a abort /build/glibc-S7Ft5T/glibc-2.23/stdlib/abort.c:91:0 #7 0x00007f5a44ebd97a llvm::install_bad_alloc_error_handler(void (*)(void*, char const*, bool), void*) /home/shane/llvm-project/llvm/lib/Support/ErrorHandling.cpp:126:0 #8 0x00007f5a44ebd771 llvm::report_fatal_error(llvm::StringRef, bool) /home/shane/llvm-project/llvm/lib/Support/ErrorHandling.cpp:86:0 #9 0x00007f5a4b12f51d /home/shane/llvm-project/llvm/lib/CodeGen/TargetPassConfig.cpp:662:0 #10 0x00007f5a4b137206 llvm::Pass* llvm::callDefaultCtor<llvm::TargetPassConfig>() /home/shane/llvm-project/llvm/include/llvm/PassSupport.h:80:0 #11 0x00000000004dc41a main /home/shane/llvm-project/llvm/tools/opt/opt.cpp:933:0 #12 0x00007f5a44436840 __libc_start_main /build/glibc-S7Ft5T/glibc-2.23/csu/../csu/libc-start.c:325:0 #13 0x00000000004a1689 _start (/home/shane/llvm-project/build/bin/opt+0x4a1689) Below is the command I use: Step 1. clang -O3 -Xclang -disable-llvm-optzns main.c -S -emit-llvm -o main.ll Step 2. opt -S -enable-new-pm=0 $theSeqenceAbove main.ll -o O3.ll Then I got the error message. I remove the pass “targetpasscongfig” and it didn’t show any error message anymore, but the IR is not same as -O3 flag. ( opt -S -enable-new-pm=0 -O3 main.ll -o O3.ll) Is that a bug? I’m using LLVM 14.0.0. Thank you all!!! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211116/7165cdf3/attachment-0001.html>