Preventing pure function declarations from being removed

Hi all,

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)?

Basically, my modules have a set of function declarations (without an actual body, just a global mapping on the C++ side) that shall not be removed during code optimization, because I need to find them again after optimization.

Greetings

Marcus

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.