[LLVMdev] llvm.lifetime.start; what does it do exactly?

Duncan Sands baldrick at free.fr
Fri Jul 13 09:40:20 PDT 2012


Hi Ryan,

On 13/07/12 17:58, ryan baird wrote:
> Esentially, I'm working on a translator someone started building for llvm2.9
> that translates an optimized .lln file to another intermediate language, and I'm
> porting it to 3.1.
>
> There is a new intrinsic that pops up in our test cases' lln files that never
> used to, llvm.lifetime.start.  I looked up the description: "The
> 'llvm.lifetime.start' intrinsic specifies the start of a memory object's
> lifetime."  However, it's still not clear to me what exactly i should do;
>   should this actually be translated to anything (like a call to malloc or
> something), or is it just used to keep information about the memory object?

you can safely ignore it.  The basic use case is this: function A calls function
B, and the optimizers inline the call.  Local variables of (the inlined) B now
get a declaration at the start of A, but they are only actually used in the
inlined B code, not before nor after.  Adding a lifetime.start just before the
inlined code, and a lifetime.end just after, explains this to the optimizers
and code generators, which makes it easier for them to exploit this information.

Ciao, Duncan.



More information about the llvm-dev mailing list