[PATCH] Allocate stack storage for .block_descriptor and captured self.

Adrian Prantl aprantl at apple.com
Wed Feb 27 10:39:04 PST 2013


On Feb 27, 2013, at 10:12 AM, Manman Ren <mren at apple.com> wrote:

> 
> On Feb 26, 2013, at 9:36 AM, John McCall wrote:
> 
>> On Feb 26, 2013, at 9:16 AM, Adrian Prantl <aprantl at apple.com> wrote:
>>> On Feb 25, 2013, at 5:02 PM, John McCall <rjmccall at apple.com> wrote:
>>>> On Feb 25, 2013, at 4:55 PM, Adrian Prantl <aprantl at apple.com> wrote:
>>>>> here’s another patch for review:
>>>>> 
>>>>> Allocate stack storage for .block_descriptor and captured self.
>>>>> This way the register allocator will not optimize away the the
>>>>> debug info for captured variables.
>>>> 
>>>> Allocating stack storage is not the right way to fix this problem.
>>>> The frontend is emitting the right intrinsics to say that the argument
>>>> is being kept in an LLVM value, not in memory.  If that's not working,
>>>> then basically all optimized debug info is useless.
>>> 
>>> Just to provide you with more details: The problem manifested itself even at -O0 because the DebugValue would be kicked out by RegAllocFast.cpp:855 under high register pressure (I think). Is there another, better way to force the DebugValue to survive register allocation?
>> 
>> Is the value being lost completely (because it's no longer live), or is it just being moved between registers or spilled?  Because it seems to me that it's a perfectly reasonable request to make of register allocation that it not drop debug info for live values.
> Here is what happened in the backend:
> %vreg23<def> = COPY %vreg5;
> %vreg22<def, tied 1> = ADD64ri32 %vreg23<tied0> …
> DBG_VALUE %vreg23, 0, !"self"
> 
> The last usage of %vreg23 is in DBG_VALUE. When processing ADD64ri32, since %vreg23 was only used in DBG_VALUE afterwards, its content was not spilled to stack.
> At DBG_VALUE, %vreg23 is lost, it is not in a physical register, nor in a spill slot. And we will see error message "Unable to allocate vreg used by DBG_VALUE".

FYI, this is what this looks like in RegAllocFast.cpp:851 :

          if (LRI != LiveVirtRegs.end())
            setPhysReg(MI, i, LRI->PhysReg);
          else {
            int SS = StackSlotForVirtReg[Reg];
            if (SS == -1) {
              // We can't allocate a physreg for a DebugValue, sorry!
              DEBUG(dbgs() << "Unable to allocate vreg used by DBG_VALUE");
              MO.setReg(0);
            }
 
— adrian



More information about the cfe-commits mailing list