[cfe-dev] Ho to instruct the optimizer to not throw out certain constructs

mats petersson via cfe-dev cfe-dev at lists.llvm.org
Tue Nov 22 03:47:52 PST 2016


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?

--
Mats

On 22 November 2016 at 10:37, Compiler Dragon via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> 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
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161122/74fe3e78/attachment.html>


More information about the cfe-dev mailing list