[LLVMdev] Can simplifycfg kill llvm.lifetime intrinsics?

Krzysztof Parzyszek kparzysz at codeaurora.org
Wed Dec 26 12:28:51 PST 2012

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".


Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

More information about the llvm-dev mailing list