[PATCH] [PowerPC] Fix unwind info with dynamic stack realignment

Jay Foad jay.foad at gmail.com
Thu Nov 27 23:14:31 PST 2014


>>! In D6410#11, @hfinkel wrote:
> Thanks for working on this. I know very little about the CFI directives, and so I'm afraid this might not be the end of the story; specifically, I'm worried about the meaning of the offsets used for the other registers.

The CFI directives are doing two things:
1. The createDefCfa* functions define the Canonical Frame Address, i.e. the value of SP on entry to the function, in terms of some native register.
2. The createOffset function says where a register was saved on the stack, as an offset from the CFA.

I have fixed (1) in a function that dynamically realigns the stack. This should not affect (2) in any way. Assuming the offsets passed into createOffset were correct before, they should still be correct now.

I've just had a look at all the calls to createOffset and they look OK to me, except that I don't understand all the complexities in handling CR. But like I said, my changes should not affect their correctness.

> Maybe this is all fine, but using the same offsets when calling MCCFIInstruction::createOffset for the sp/fp and the bp seems suspicious. Can you please confirm that the offsets are indeed correct in all cases, and regardless, please add some comments explaining your conclusion.

I think it's all fine, but it'd be really nice to have some end-to-end tests to verify that a debugger/unwinder can successfully debug/unwind the generated code.

How about a one-line comment before the CFI stuff for each saved register, like:

```
    // Describe where FP was saved as an offset from the CFA.
    if (HasFP) {
      unsigned Reg = MRI->getDwarfRegNum(FPReg, true);
      CFIIndex = MMI.addFrameInst(
          MCCFIInstruction::createOffset(nullptr, Reg, FPOffset));
      BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
          .addCFIIndex(CFIIndex);
    }
```

http://reviews.llvm.org/D6410






More information about the llvm-commits mailing list