[llvm-dev] Preventing LLVM from optimizing out a variable

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 11 13:49:58 PDT 2016


On 11 July 2016 at 13:45, David Jones via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Is there any way of marking a Value* as "precious", not to be optimized out?

I don't think there's any canonically supported way to do it.

> define void @foo(%A*) {
>     %2 = alloca %A*
>     store %0, %2

Perhaps mark this store as volatile? Untested, but worth a shot.

Tim.


More information about the llvm-dev mailing list