[LLVMdev] lifetime.start/end clarification

Philip Reames listmail at philipreames.com
Wed Nov 5 10:24:45 PST 2014


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 <mailto: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?

Philip

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


More information about the llvm-dev mailing list