19

我想找到一些类似于 gcc 的 clang/LLVM 调试选项-fdump-tree-all-all -fdump-rtl-all-all -fdump-ipa-all-all

基本上我希望在每次优化通过之前和之后都有一个 LLVM IR 转储,从 clang 和代码生成的所有阶段(后端阶段、选择 DAG、ISEL-SDNode、寄存器分配、MCInsts )。

我只能找到 clang 的-ccc-print-phases,但它只会打印高级阶段名称,例如 preprocess-compile-assemble-link;但没有任何 IR 转储。

LLVM论文中还有一条指令的生命周期,-cc1-ast-dump可以选择转储 clang AST,但我想要更多,尤其是对于 codegen。

4

3 回答 3

16

您似乎已经发现了如何在 Clang AST 级别和 LLVM IR 级别进行转储。对于 codegen,以下内容很有用:

-debug有关指令选择和后续阶段的详细文本转储。此外,-view*-dags显示(弹出)DAG:

$ llc -help-hidden|grep dags
  -view-dag-combine-lt-dags                      - Pop up a window to show dags before the post legalize types dag combine pass
  -view-dag-combine1-dags                        - Pop up a window to show dags before the first dag combine pass
  -view-dag-combine2-dags                        - Pop up a window to show dags before the second dag combine pass
  -view-isel-dags                                - Pop up a window to show isel dags as they are selected
  -view-legalize-dags                            - Pop up a window to show dags before legalize
  -view-legalize-types-dags                      - Pop up a window to show dags before legalize types
  -view-misched-dags                             - Pop up a window to show MISched dags after they are processed
  -view-sched-dags                               - Pop up a window to show sched dags as they are processed
  -view-sunit-dags                               - Pop up a window to show SUnit dags after they are processed

如果您没有配置和编译带有 graphviz 支持的 LLVM,这些可能不会显示。

于 2013-07-29T17:05:47.927 回答
6

不完全关于您的问题,但要查看应用的通行证,您可以执行以下操作:

clang test.c -Ofast -march=core-avx2 -mllvm -debug-pass=Arguments

你会看到类似的东西:

Pass Arguments: -datalayout -notti -basictti -x86tti -targetlibinfo -jump-instr-table-info -targetpassconfig -no-aa -tbaa -scoped-noalias -basicaa -collector-metadata -machinemoduleinfo -machine-branch-prob -jump-instr-tables -verify -verify-di -domtree -loops -loop-simplify -scalar-evolution -iv-users -loop-reduce -gc-lowering -unreachableblockelim -consthoist -partially-inline-libcalls -codegenprepare -verify-di -stack-protector -verify -domtree -loops -branch-prob -machinedomtree -expand-isel-pseudos -tailduplication -opt-phis -machinedomtree -slotindexes -stack-coloring -localstackalloc -dead-mi-elimination -machinedomtree -machine-loops -machine-trace-metrics -early-ifcvt -machinelicm -machine-cse -machine-sink -peephole-opts -dead-mi-elimination -processimpdefs -unreachable-mbb-elimination -livevars -machinedomtree -machine-loops -phi-node-elimination -twoaddressinstruction -slotindexes -liveintervals -simple-register-coalescing -misched -machine-block-freq -livedebugvars -livestacks -virtregmap -liveregmatrix -edge-bundles -spill-code-placement -virtregrewriter -stack-slot-coloring -machinelicm -edge-bundles -prologepilog -machine-block-freq -branch-folder -tailduplication -machine-cp -postrapseudos -machinedomtree -machine-loops -post-RA-sched -gc-analysis -machine-block-freq -block-placement2 -stackmap-liveness -machinedomtree -machine-loops

于 2014-08-25T10:54:34.813 回答
-4

llvm-gcc-4.2在山狮上使用并-fdump-tree-all工作。

gcc  -fdump-tree-all -o test file1.c file2.c file1.h -I  . 
于 2013-08-09T15:00:22.427 回答