[LLVMdev] Prevent instruction elimination

Duncan Sands baldrick at free.fr
Mon Oct 25 08:43:00 PDT 2010


Hi John,

> As for instructions, I don't know of an instruction which does nothing,
> won't be removed by optimization, and yet does not inhibit
> optimization.  Perhaps a local alloca and a volatile load or store would
> do the trick?  Being volatile, the compiler won't remove it (or if it
> does, it's a bug, and you should file a bug report), and since it loads
> from a memory object not used for anything else, alias analysis should
> be able to see that it doesn't interefere with any other load/store.

LLVM certainly will remove volatile loads and stores to local variables
(at least in simple situations).  I suggest using an empty asm statement.

Ciao,

Duncan.



More information about the llvm-dev mailing list