Understanding SelectionDAG construction

I am trying to understand the SelectionDAG construction from LLVM IR. I have gone through the doc “The LLVM Target-Independent Code Generator” on LLVM site. This gives a great initial overview. However I am unable to catch the actual control flow for the llvm->selectionDag conversion.

The flags “-view-sched-dags”… described in the doc doesn’t seem to work. ( “llc -help” doesn’t list it ).

To understand the codeflow, I was trying to use gdb over llc. Where should I put the breakpoints where I can see llvm->selectionDag conversion happening e.g. SDNode being generated out of llvm instructions.

Any pointer to detailed level doc will also help. Doxygen doesnt help till I am a bit familiar with Codeflow.

Thanks.

I am trying to understand the SelectionDAG construction from LLVM IR. I have
gone through the doc "The LLVM Target-Independent Code Generator" on LLVM
site. This gives a great initial overview. However I am unable to catch the
actual control flow for the llvm->selectionDag conversion.

The flags "-view-sched-dags".. described in the doc doesn't seem to work. (
"llc -help" doesn't list it ).

See http://llvm.org/docs/ProgrammersManual.html#ViewGraph ... and the
option is listed in -help-hidden.

To understand the codeflow, I was trying to use gdb over llc. Where should I
put the breakpoints where I can see llvm->selectionDag conversion happening
e.g. SDNode being generated out of llvm instructions.

Setting a breakpoint on SelectionDAGISel::SelectBasicBlock wouldn't be
a bad place to start (although most of the relevant code is actually
in SelectionDAGBuilder.cpp).

Any pointer to detailed level doc will also help. Doxygen doesnt help till I
am a bit familiar with Codeflow.

There really aren't any docs more detailed than the one you mentioned.

-Eli

The -view options are only available in llvm builds with assertions. Also graphiz must be installed on your system (and in path) at configure time.

Hi Ankur,

The flags "-view-sched-dags".. described in the doc doesn't seem to work. (
"llc -help" doesn't list it ).

as far as I remember, displaying DAGs during compilation is only enabled
in "debug builds" [1] of LLVM. You probably have to re-configure and
re-compile LLVM to enable this feature.

Best regards,
Christoph

[1] http://llvm.org/docs/GettingStarted.html#compile

Hi everyone,

Thanks for the help. I did some gdbing and found some code flow which explains the formation of SelectionDAG.

I am including few of my steps which helped me understanding the code-flow. This information is aimed at someone like searching about SelectionDAG and no clue where to start looking. I hope this will help someone.
My appologies if someone finds this post annoying.