2013-07-28 14 views
12

gccの-fdump-tree-all-all-fdump-rtl-all-all-fdump-ipa-all-allのように動作するclang/LLVMのデバッグオプションをいくつか探したいと思います。各llvm最適化(各パス)の後にIRをダンプし、llvm irのパスとバックエンドのデバッグ

基本的には、各最適化パスの前後にLLVM IRダンプが必要です。また、clangやコード生成のすべての段階(バックエンド段階、選択DAG、ISEL-SDNodeなど)からASTのすべてのダンプを持つと便利です。レジスタ割り当て、MCInsts)。

clangの-ccc-print-phasesしか見つかりませんでしたが、ハイレベルのフェーズ名しか表示されません。 preprocess-compile-assemble-link; IRのダンプはありません。

また、clang ASTをダンプするオプションがあるLife of an instruction in LLVMペーパーがありますが、特にcodegenの方が望ましいです。

+3

うーん:

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

はあなたのようなものが表示されます"-print-after-all" - 各パスの後にIRを印刷する; -print-before-all - IRフェーズの場合は '各パスの前にIRを出力する '、bどのようにバックエンドからダンプを取得するのですか? – osgx

+0

バックエンドフェーズからデバッグ情報を自分で印刷することができます。 codegenの 'CGDebugInfo'オブジェクトです。 – shrm

+0

mishr、llvmバックエンドからではなく、clang IRエミッタからのCGDebugInfoですか?私は、LLVM IR-to-machineコードバックエンド(codegen) – osgx

答えて

13

すでにClang ASTレベルとLLVM IRレベルでダンプを行う方法を発見したようです。 codegenの場合、次のように便利です。

-debug命令の選択と後の段階の詳細なテキストダンプ。また、-view*-dagsショー(ポップアップ)のDAG:あなたはgraphvizのサポート付きでコンパイルさ& LLVMを設定していない場合

$ 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 

をこれらは表示されない場合があります。

+0

Eli、clangとIRダンプに関する情報もあなたの答えに追加できますか? – osgx

+0

と-print-machineinstrsが便利かもしれません。 llvm 3.2の私のllcは、 '-view - * - dags'を持っていません。 – osgx

+0

@osgx:私の編集w.r.tを参照してください。 '-view- * 'を持たない。他のダンプについては、質問とコメントに貼り付けた情報で私の答えを自由に編集してください:) –

-3

私はマウンテンライオンでllvm-gcc-4.2-fdump-tree-allを使用しています。ない完全にあなたの質問について

gcc -fdump-tree-all -o test file1.c file2.c file1.h -I . 
+0

LLVM IRコア、またはGCCの内部表現だけを出力しますか? – osgx

2

が、パスが適用される参照してください、あなたが行うことができますが、

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

+0

ジノビ、ありがとう、それはあまりにも役立つことができます。 '' -debug-pass = Arguments'を使うためのclang/llvmのミニバージョンは何ですか? – osgx

+2

'-mllvm -debug-pass = Structure'はさらに良いです。 '-debug-pass = Arguments'の出力を含みますが、人間が読める名前で適用された最適化のツリーをダンプします。 – gluk47

関連する問題