[PATCH] D18046: [X86] Providing correct unwind info in function epilogue
Violeta Vukobrat via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 23 08:39:07 PDT 2017
violetav added inline comments.
================
Comment at: lib/CodeGen/CFIInstrInserter.cpp:43
+ // needed. The negated value is needed when creating CFI instructions that set
+ // absolute offset.
+ int getCorrectCFAOffset(MachineBasicBlock &MBB) {
----------------
iteratee wrote:
> I'm still not sure I get the negatives. Do the CFI instructions return the negative of what they're created with? That doesn't seem to make any sense.
The thing is, they are created with the negative of what you pass to the create* method:
static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, int Offset) {
return MCCFIInstruction(OpDefCfa, L, Register, -Offset, "");
}
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset) {
return MCCFIInstruction(OpDefCfaOffset, L, 0, -Offset, "");
}
So, if you want to create a '.cfi_def_cfa_offset 16' you would pass -16 to the createDefCfaOffset() method.
This is true for def_cfa and def_cfa_offset, but not for adjust_cfa_offset:
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment) {
return MCCFIInstruction(OpAdjustCfaOffset, L, 0, Adjustment, "");
}
And here, for in/out cfa offset, I am storing these positive values that end up in cfi directives, and then creating def_cfa or def_cfa_offset instruction, hence the '-MBB.getIncomingCFAOffset()'.
Repository:
rL LLVM
https://reviews.llvm.org/D18046
More information about the llvm-commits
mailing list