[llvm-dev] Jit: use @llvm.lifetime.end to optimize away stores to globals used as temporaries

Nat! via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 29 09:34:45 PST 2016

Tom Aernoudt via llvm-dev schrieb:
> Hi all,
> The 'tmp' state variable is only needed during execution of the function
> 'f'.
That's what you say, because you called it 'tmp' :), but the compiler 
sees no difference to 'a' or 'b'. As soon as s->tmp would "escape" f() 
the compiler will have to write it.

I think you may want to keep external state and temporal context separate


struct State {
   int a;
   int b;

struct Temp {
   int tmp;

static void f0( State *s, Temp *t)
   t->tmp = s->a;


void f(State* s)

    Temp  tmp;

    f0( s, &tmp);
    f1( s, &tmp);

Using @llvm.lifetime.end is IMO a deadend, since this should just 
signify that the alloca is gone.


More information about the llvm-dev mailing list