4

I have llc program installed on my computer via package manager (of course I have LLVM installed, 6.0.0 version). Also, I have it built from sources. What I want is to view DAGs, generated by llvm. But, unfortunately, I don't have any of options like -debug, -view-dag-combine1-dags and etc on both versions of llc. This drives me crazy since it is written everywhere, that this flags should help me, but it is not mentioned what to do if I don't have them. In help and man, there are no such options. I have graphviz, dot and gv installed, it should not be the problem.

Version of compiled llc.

./llc -version
LLVM (http://llvm.org/):
LLVM version 7.0.0svn
Optimized build.
Default target: x86_64-unknown-linux-gnu
Host CPU: broadwell

Registered Targets:
   and targets...

I've built it with RelWithDebugInfo flag, maybe I should've built it with Debug flag? Or is there any flag in cmake, that I should enable? I believe that I've googled enough and I couldn't find any information.

compor
  • 2,239
  • 1
  • 19
  • 29
Nikita Vorobyev
  • 313
  • 2
  • 9

2 Answers2

5

Executing llc --help-hidden | grep view-dag using my debug build results in:

-filter-view-dags= - Only display the basic block whose name matches this for all view-*-dags options
-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

If you look into llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp, that command-line option is between #ifndef NDEBUG preprocessor statements, so those options are only exposed when you have a debug build.

Changing the CMAKE_BUILD_TYPE to Debug and recompiling should be enough.

compor
  • 2,239
  • 1
  • 19
  • 29
  • Thanks for your reply, although I can't check, if it is a solutions, since I can't build llvm in debug, I just don't have enough memory:) – Nikita Vorobyev Aug 26 '18 at 15:02
  • You can also use a release+asserts build, which is much smaller: http://llvm.org/docs/ProgrammersManual.html#viewing-graphs-while-debugging-code – ayke Apr 17 '20 at 16:54
  • @ayke That must be a relic from the Make part of build system. The [CMake doc](https://llvm.org/docs/CMake.html) says "Enables code assertions. Defaults to ON **if and only if** CMAKE_BUILD_TYPE is Debug." for the `LLVM_ENABLE_ASSERTIONS` variable – compor Apr 18 '20 at 10:07
  • I believe it worked the last time I checked, with a release+assert build. Maybe `LLVM_ENABLE_ASSERTIONS` does not imply `!NDEBUG`. – ayke Jun 22 '20 at 00:25
0

I did it and it works.

$ cmake -DCMAKE_BUILD_TYPE:STRING=Debug

You can check: https://github.com/llvm/llvm-project/blob/master/llvm/docs/CMake.rst#id5

and if you want to check DAGs then maybe it helps you.

here: https://stackoverflow.com/a/52095047/12365658

Kishan Mehta
  • 2,598
  • 5
  • 39
  • 61
JaeIL Ryu
  • 159
  • 10