Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable debug output for optimization passes from clang

I am trying to understand an existing pass in LLVM and thus trying to print the nicely written debug messages in the pass. I am doing so by using clang -debug -some-other-flags. However while compiling it says:

clang: warning: argument unused during compilation: '-debug'

How to enable the debug output?

like image 211
shrm Avatar asked Mar 25 '13 12:03

shrm


People also ask

What is clang ++ command?

clang is a C, C++, and Objective-C compiler which encompasses preprocessing, parsing, optimization, code generation, assembly, and linking.

What is clang command line?

Introduction. The Clang Compiler is an open-source compiler for the C family of programming languages, aiming to be the best in class implementation of these languages. Clang builds on the LLVM optimizer and code generator, allowing it to provide high-quality optimization and code generation support for many targets.

What is clang Linux?

The Clang tool is a front end compiler that is used to compile programming languages such as C++, C, Objective C++ and Objective C into machine code. Clang is also used as a compiler for frameworks like OpenMP, OpenCL, RenderScript, CUDA and HIP.


2 Answers

Clang does not have a "debug" command-line option; you need to either build the IR from clang and then run opt -debug separately, or run clang -mllvm -debug.

In general, the -mllvm flag passes whatever appears afterwards on to LLVM itself. Use multiple -mllvm flags if you want to pass multiple options onwards.

like image 115
Oak Avatar answered Sep 27 '22 19:09

Oak


In case the accepted answer does not work for you: apart from adding -mllvm -debug, you need clang which is built with debug assertions enabled, which is done by adding -DLLVM_ENABLE_ASSERTIONS=On to cmake options when compiling clang (ref).

like image 27
gluk47 Avatar answered Sep 27 '22 19:09

gluk47