Ho to instruct the optimizer to not throw out certain constructs

Hi *,

I am currently writing a clang plugin, which add to specific functions for e.g. additional arguments.

How can I instruct the optimizer not to throw out these arguments, because they are not used in the function body?

With (optnone) we can instruct the optimizer to not optimize the whole function. But this ist not what I want. The function body should be optimized like before.

Any idea or hints where to look?

Thanks

Marcel

If they are not used, why do you want them to remain? volatile can be used to ensure that the compiler doesn’t optimise something away, or “explicit use in a way that is never true - but compiler doesn’t know it is so” (e.g. if (sin(x) > 1.0) { do stuff that actually never happens } ) - calling sin is probably not the best choice, but there may be other ways to achieve something similar that is less intrusive but still “unknown to the compiler”.

Can you give an example piece of code?