Difference between revisions of "DebugLLVM"
(→Cannot select) |
(→Typical errors) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
LLVM is provided with a debug infrastructure. If you want to debug the compiler, you only need to build LLVM and Clang in debug mode. | LLVM is provided with a debug infrastructure. If you want to debug the compiler, you only need to build LLVM and Clang in debug mode. | ||
+ | |||
+ | == Manual compiler debug == | ||
+ | If you want to print some variable values inside the compiler, LLVM provides the ''outs()'' and ''errs()'' functions that return a reference to a raw_ostream for respectively the standard output and the standard error. These functions are defined inside the /lib/raw_osstream.cpp file and can be used just as the standard C++ output stream object ''cout'' using the insertion operator (<<). | ||
+ | In the following, an example: | ||
+ | <syntaxhighlight lang="c" line='line'> | ||
+ | errs() << "Could not find host " << HostName << "\n"; | ||
+ | </syntaxhighlight> | ||
== Typical errors == | == Typical errors == | ||
Line 14: | Line 21: | ||
This error occurs when the backend lacks a rule to perform the instruction selection of a certain SelectionDAG node. | This error occurs when the backend lacks a rule to perform the instruction selection of a certain SelectionDAG node. | ||
In such a case, you have a look at the [[NuPlusInstrFormats.td | NuPlusInstrFormats.td]], [[NuPlusInstrInfo.td | NuPlusInstrInfo.td]] and [[NuPlusISelLowering.cpp | NuPlusISelLowering.cpp]] files to understand why this node cannot be lowered. | In such a case, you have a look at the [[NuPlusInstrFormats.td | NuPlusInstrFormats.td]], [[NuPlusInstrInfo.td | NuPlusInstrInfo.td]] and [[NuPlusISelLowering.cpp | NuPlusISelLowering.cpp]] files to understand why this node cannot be lowered. | ||
+ | |||
+ | === undefined reference to '__cxa_guard_acquire' and undefined reference to '__cxa_guard_release' === | ||
+ | If you have this error during the linking phase, it's probably a flag missing in the invocation of the linker. | ||
+ | A workaround could be to remove some static identifier from variables inside the function where the linker gets stuck. |
Latest revision as of 17:21, 3 July 2018
LLVM is provided with a debug infrastructure. If you want to debug the compiler, you only need to build LLVM and Clang in debug mode.
Contents
Manual compiler debug
If you want to print some variable values inside the compiler, LLVM provides the outs() and errs() functions that return a reference to a raw_ostream for respectively the standard output and the standard error. These functions are defined inside the /lib/raw_osstream.cpp file and can be used just as the standard C++ output stream object cout using the insertion operator (<<). In the following, an example:
errs() << "Could not find host " << HostName << "\n";
Typical errors
Cannot select
fatal error: error in backend: Cannot select:
...
...
...
In function: function name
clang-3.9: error: clang frontend command failed with exit code 70 (use -v to see invocation)
This error occurs when the backend lacks a rule to perform the instruction selection of a certain SelectionDAG node. In such a case, you have a look at the NuPlusInstrFormats.td, NuPlusInstrInfo.td and NuPlusISelLowering.cpp files to understand why this node cannot be lowered.
undefined reference to '__cxa_guard_acquire' and undefined reference to '__cxa_guard_release'
If you have this error during the linking phase, it's probably a flag missing in the invocation of the linker. A workaround could be to remove some static identifier from variables inside the function where the linker gets stuck.