[LLVMdev] lifetime.start/end clarification

Arnaud A. de Grandmaison arnaud.degrandmaison at arm.com
Wed Nov 5 11:08:21 PST 2014


 

 

From: Philip Reames [mailto:listmail at philipreames.com] 
Sent: 05 November 2014 19:25
To: Reid Kleckner
Cc: Arnaud De Grandmaison; Nick Lewycky; Rafael Ávila de Espíndola; LLVM Developers Mailing List
Subject: Re: [LLVMdev] lifetime.start/end clarification

 

 

On 11/05/2014 10:10 AM, Reid Kleckner wrote:

On Wed, Nov 5, 2014 at 10:01 AM, Philip Reames <listmail at philipreames.com> wrote:

Would one of you mind taking a step back and explaining what you believe the "stack colouring problem" to be?  I'm familiar with the general meaning of the term and even some of LLVM's implementation; I'm just not sure what specific issue you're referring to.   Having the context would make it much easier to assess your proposals.  

 

The goal of stack coloring is to reduce stack usage by storing user data with non-overlapping lifetimes in the same stack memory.

 

C/C++ source programs usually have a naturally scoped structure, where the lifetime of data is bounded by curly braces. This information reduces the lifetime that stack coloring sees, so it saves stack memory.

 

When we go to LLVM IR, we lose all that information. We currently try to recapture it with calls to @lifetime.start / end intrinsic calls at the point of declaration and when the variable falls out of scope. Basically we're trying to figure out how to put that scoping information back into the IR without turning it back into a tree.

 

Furthermore, if we had better information about this in the IR, we could augment ASan to detect use-after-scope.

Everything you say here is general goodness.  What part of this is problematic today?  My belief is that the lifetime markers give you exactly the support you need.  Where does this break down?  Is the analysis too hard?  Is Clang getting the semantics wrong?  What's the actually blocking issue?



Here is the actually blocking issue. Today, the lifetime markers are only inserted if the alloca is big enough (32+ bytes). I tried several times to add the lifetime markers for unnamed temporaries; the patches have been reviewed each time by people knowledgeable with this part of clang. But when we remove the size limit for the lifetime marker insertion, we get miscompiles when bootstrapping clang. This is why I was asking for clarification of the specification, as this is a part I found left room for interpretation.


Philip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141105/816de24f/attachment.html>


More information about the llvm-dev mailing list