[LLVMdev] Preventing pure function declarations from being removed

Duncan Sands baldrick at free.fr
Mon Jul 16 08:49:26 PDT 2012


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.

Ciao, Duncan.



More information about the llvm-dev mailing list