[Lldb-commits] [PATCH] D26295: Change UnwindAssemblyInstEmulation to remove a register location instead of marking it as IsSame()

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 4 15:41:22 PDT 2016


jasonmolenda added a comment.

Ah, interesting point, I didn't think of that.  However, this touches on another thing I've been thinking about as I look at the assembly inspection unwind plan generators.  In the x86 unwind inspector, I've hardcoded the SysV-x86_64 ABI and the unwind plan generator ignores any saves/restores of volatile registers.  It's a poor choice and it's the kind of thing that surely won't be correct when a Windows port is up & running.

I'm thinking the unwind plan generators should treat all registers as non-volatile.  When UnwindLLDB / RegisterContextLLDB run the UnwindPlan, they can ask the ABI if a register is volatile or not - and refuse to retrieve a volatile register for a stack frame in the middle of the stack.  (it SHOULD be doing that already)

The problem with tracking a register that is volatile is that as soon as the function makes a call into another function, we have to assume the register value is overwritten.  So if we have

  0xfffffff021f7bd80 <+0>:    stp    x28, x27, [sp, #-0x60]!
  0xfffffff021f7bd84 <+4>:    stp    x26, x25, [sp, #0x10]
  0xfffffff021f7bd88 <+8>:    stp    x24, x23, [sp, #0x20]
  0xfffffff021f7bd8c <+12>:   stp    x22, x21, [sp, #0x30]
  0xfffffff021f7bd90 <+16>:   stp    x20, x19, [sp, #0x40]
  0xfffffff021f7bd94 <+20>:   stp    x29, x30, [sp, #0x50]
  0xfffffff021f7bd98 <+24>:   add    x29, sp, #0x50            ; =0x50 
  0xfffffff021f7bd9c <+28>:   sub    sp, sp, #0xe0             ; =0xe0 
  0xfffffff021f7bdd4 <+84>:   bl     0xfffffff021f8af70  
  
  0xfffffff021f7c334 <+1460>: str    w9, [sp, #0x60]

x9 is volatile in the AAPCS64 ABI, so at this offset in the assembly the value has already been overwritten by the call instruction at +84.  If I later see a load of x9 and mark the register as "IsSame", now we've got a problem because we're saying it has the original value.

If we were going to follow the IsSame-means-unmodified thinking through, we'd want to mark every register as IsSame on function entry and only remove that markup when the register is modified.

I guess I'm trying to say two things.  (1) I'd really like to get rid of IsSame so that the unwind plan dumps are easier for me to read ;) and (2) I think the instruction profiler unwind plan generators should track all registers without knowledge of the ABI, and leave it to the runtime code to decide which registers we will allow to be looked up.


Repository:
  rL LLVM

https://reviews.llvm.org/D26295





More information about the lldb-commits mailing list