<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jun 9, 2012, at 2:43 PM, Dmitry N. Mikushin wrote:</div><blockquote type="cite">Dear colleagues,<br><br>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<br>
<br>extern __attribute__((device)) int var;<br><br>__attribute__((always_inline)) void kernel()<br>{<br> var = 2;<br>}<br><br>with<br><br>clang -cc1 <a href="http://test.cu/">test.cu</a> -emit-llvm -triple ptx64-unknown-unknown -fcuda-is-device <a href="http://test.cu/">test.cu</a> -o -<br>
<br>reasonably produces empty module: the only function is inline and not used.<br><br>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?<br>
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?<br></blockquote></div><br><div>IIRC, LLVM's IR printer never prints types that aren't actually used. Types aren't really contained in a module like that.</div><div><br></div><div>__attribute__(("used")) should force the emission of a function even if it isn't called. I don't believe we have a "emit every function definition you see" mode.</div><div><br></div><div>John.</div></body></html>