[LLVMdev] Preventing pure function declarations from being removed
Marcus Frenkel
marcus.frenkel at FernUni-Hagen.de
Wed Jul 18 01:31:41 PDT 2012
Hi Duncan,
> Hi Marcus,
>
>> is there any way to mark a non-referenced function declaration as "used"
>> in any way (by using the C++ code generator) so that it will be ignored
>> by
>> the stripDeadPrototypes and globalDCE pass (and any other pass that
>> possibly might remove seemingly unused functions)?
>
> try adding it to the llvm.used array. To see what that is, I suggest you
> compile some C code in which you have marked some function with attribute
> "used", and observe the use that clang makes of this array.
got it, thank you! I thought about using a global variable to store a
reference to the function, but for some reason my approach didn't work
(probably by some silly mistake). Using a global array will do the trick.
Greetings
Marcus
More information about the llvm-dev
mailing list