[LLVMdev] Can simplifycfg kill llvm.lifetime intrinsics?

Nick Lewycky nicholas at mxc.ca
Wed Dec 26 13:38:52 PST 2012


On 12/26/2012 12:28 PM, Krzysztof Parzyszek wrote:
> On 12/25/2012 1:31 PM, Alexey Samsonov wrote:
>>
>> Ok, suppose you have the following code:
>> BB1:
>> llvm.lifetime.start(%a)
>> store to %a
>> llvm.lifetime.end(%a)
>> br %BB2
>>
>> BB2:
>> <some code>
>> br %BB1
>>
>> If you remove the first "llvm.lifetime.start", then when you enter
>> %BB1 for the second time, your "store to %a" can be considered invalid,
>> as you've already called llvm.lifetime.end for this variable.
>
> The llvm.lifetime.end(%a) in your example is invalid, according to the
> lang ref:
>
> "This intrinsic indicates that after this point in the code, the value
> of the memory pointed to by ptr is dead. This means that it is known to
> never be used and has an undefined value. Any stores into the memory
> object following this intrinsic may be removed as dead."
>
> If you can re-enter the block with a still-defined value of %a, then
> it's not "known to never be used".

The intention is that if you have a loop, you could mark the memory 
lifetime.end at the end of the loop, and operations on the next run of 
the loop would see 'undef' there -- at least until you call lifetime.start.

Of course you can re-start memory that's been ended... if that isn't 
clear in the langref, please fix.

Nick



More information about the llvm-dev mailing list