LLVM Discussion Forums

LLC -view-dag-combine1-dags

when I run llc -view-dag-combine1-dags test.ll Iam getting error as Unknown command line argument ‘-view-dag-combine1-dags’. Why I am not able to see the following passes under llc?

  • -view-dag-combine1-dags displays the DAG after being built, before the first optimization pass.
  • -view-legalize-dags displays the DAG before Legalization.
  • -view-dag-combine2-dags displays the DAG before the second optimization pass.
  • -view-isel-dags displays the DAG before the Select phase.
  • -view-sched-dags displays the DAG before Scheduling.

I have LLVM version 10.0.0
Thank You

These options are only available in Debug / Release+Assertions build. You’re likely having just plain Release build.

1 Like

Thank You.I able to run the following command
llvm-project/build/bin/llc -view-dag-combine1-dags test.ll

But I am not able to see the graph.

By default at no optimization llc select fast-isel instead of going with selectionDAG way so dags are not available. So in order to see them, you need to disable fast-isel by passing -fast-isel=false option.

Note: LLVM have three type of instruction selectors.

  1. selectionDAG
  2. FastIsel
  3. GlobalIsel
1 Like

When I run llvm-project/build/bin/llc -stop-after=isel test.ll -o a.mir I am getting error as LLVM ERROR: “isel” pass is not registered.

Actually I want to follow the following steps : IR → SelectionDAG → MachineDAG → MachineInstr → MCInst

How can I proceed and what are the instructions I have to use ?

Thank You

There is no such pass as “isel”.
To know all the passes that run from IR to assembly use
llc -debug-pass=Structure add.ll

I tried all steps a while ago so searching on the internet you will also find solutions if the following steps do not go well.

You can dump the AST with
clang -Xclang -ast-dump -fsyntax-only add.c -o add.ast

IR is generated with
clang -emit-llvm -S add.c -o add.ll

Transformations from IR to MachineDAG
llc -fast-isel=false -view-dag-combine1-dags add.ll displays the DAG after being built
llc -fast-isel=false -view-legalize-dags add.ll displays the DAG before Legalization
llc -fast-isel=false -view-dag-combine2-dags add.ll displays the DAG before the second optimization pass
llc -fast-isel=false -view-isel-dags add.ll displays the DAG before the Select phase
llc -fast-isel=false -view-sched-dags add.ll displays the DAG before Scheduling
llc -fast-isel=false -view-sunit-dags add.ll displays the Scheduler’s dependency graph

To print machine instruction (MachineInstr)
llc -print-machineinstr add.ll >output >2&1

To see machine instruction after register allocation(basic, greedy, PBQP, fast)
llc add.ll -print-after=greedy -o add.s

Print MCInst as comments to the assembly
llc add.ll -asm-show-inst -o -

Binary encoding along with assembly
llc add.ll -show-mc-encoding -o -

To dump after each pass the transformation from LLVM IR to Machine specific IR(uses fast-isel)
clang -S -mllvm -print-after-all add.c 2> add.mir

1 Like

Thank You.
llc -debug-pass=Structure add.ll
When I run the above command I got list of passes.But when I run that argument in llc I am getting error as Unknown command line argument

Some passes, which are machine-independent, are invoked by opt.
Other passes, which are machine-dependent, are invoked by llc.
You can run llc --help-list-hidden and opt --help-list-hidden to know them.

As I see the slide of “Welcome to the Back End” they use the above command so may be I missing something. (My knowledge is limited to just learning basics)
Instead you can use --print-after-isel which works well on my system.