[cfe-dev] Generating strict LLVM IR out of C/C++ headers
Dmitry N. Mikushin
maemarcus at gmail.com
Sat Jun 9 14:43:16 PDT 2012
Consider there is a need to mix sources and headers that are in two
different high-level languages. It should be possible, if both languages
are lowered down to LLVM IR and merged. But the problem is that clang is
unable to generate strict IR code for headers. For example the code
extern __attribute__((device)) int var;
__attribute__((always_inline)) void kernel()
var = 2;
clang -cc1 test.cu -emit-llvm -triple ptx64-unknown-unknown
-fcuda-is-device test.cu -o -
reasonably produces empty module: the only function is inline and not used.
So the question: is there an easy way to generate IR with clang strictly
for entire header file, with all inlined functions and unused types?
Probably one way would be to write a plugin to add a fictive call of every
function and declare fictive variable of every type, but this is stupid.
Any better solution?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev