[llvm-dev] How to prevent optimizing away a call + its arguments
Joerg Sonnenberger via llvm-dev
llvm-dev at lists.llvm.org
Thu Jun 22 12:10:12 PDT 2017
On Thu, Jun 22, 2017 at 11:31:41AM -0700, Kuba Mracek wrote:
> > Actually, it should be enough to use:
> >
> > __attribute__((noinline))
> > void please_do_not_optimize_me_away(int arg1, void *arg2) {
> > asm volatile("":::"memory");
> > }
> >
> > Creating a real barrier is important.
>
> This doesn't work – the call still gets turned into please_do_not_optimize_me_away(undef, undef).
If you also want it to preserve the arguments (that wasn't clear to me),
just add them as arguments to the asm statement?
Joerg
More information about the llvm-dev
mailing list