[LLVMdev] lifetime.start/end clarification
Reid Kleckner
rnk at google.com
Wed Nov 5 13:48:46 PST 2014
On Wed, Nov 5, 2014 at 11:17 AM, Philip Reames <listmail at philipreames.com>
wrote:
>
> On 11/05/2014 10:54 AM, Reid Kleckner wrote:
>
> This seems fine to me. The optimizer can (soundly) conclude that %p is
>> dead after the "lifetime.end" (for the two instructions), and dead before
>> the "lifetime.start" (for the *single* instruction in that basic block,
>> *not* for the previous BB). This seems like the proper result for this
>> example, am I missing something?
>>
>
> What if I put that in a loop, unroll it once, and prove that the
> lifetime.start is unreachable? We would end up with IR like:
>
> loop:
> ... use %p
> call void @lifetime.end( %p )
> ... use %p
> call void @lifetime.end( %p )
> br i1 %c, label %loop, label %exit
>
> Are the second uses of %p uses of dead memory?
>
> It's hard to discuss this without being specific about the starting IR and
> transforms. My general response is that either a) such a transform
> wouldn't be valid or b) the behaviour of the original program was
> undefined.
>
The starting IR would be something that jumps into the middle of a lifetime
region, like the example that Arnaud gave. This was assuming the current
state of the world where we haven't added a second lifetime start call
prior to the goto branch.
Start with something like:
void f(int x) {
while (x) {
goto skip_start;
{
int y; // lifetime.start
skip_start:
y = g();
x -= y;
// lifetime.end
}
}
}
The block containing the lifetime start of y is unreachable and can be
deleted.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141105/d8004b30/attachment.html>
More information about the llvm-dev
mailing list