[PATCH] D158097: Support for signed def_cfa_offset instruction
Arjun Shah via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 16 09:42:14 PDT 2023
20ashah created this revision.
20ashah added reviewers: respindola, friss, MaskRay.
Herald added a subscriber: hiraditya.
Herald added a project: All.
20ashah requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Support for signed def_cfa_offset instruction
When writing dwarf information for the debug frame section, the signed version of the def_cfa_offset instruction is required since our stack grows up (adding to the SP to allocate more space). Currently, only the unsigned version is being emitted, and it encodes the offset as a ULEB instead of an SLEB.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D158097
Files:
llvm/lib/MC/MCDwarf.cpp
Index: llvm/lib/MC/MCDwarf.cpp
===================================================================
--- llvm/lib/MC/MCDwarf.cpp
+++ llvm/lib/MC/MCDwarf.cpp
@@ -1365,14 +1365,20 @@
const bool IsRelative =
Instr.getOperation() == MCCFIInstruction::OpAdjustCfaOffset;
- Streamer.emitInt8(dwarf::DW_CFA_def_cfa_offset);
+ int Offset = Instr.getOffset();
if (IsRelative)
- CFAOffset += Instr.getOffset();
+ CFAOffset += Offset;
else
- CFAOffset = Instr.getOffset();
+ CFAOffset = Offset;
- Streamer.emitULEB128IntValue(CFAOffset);
+ if (Offset < 0) {
+ Streamer.emitInt8(dwarf::DW_CFA_def_cfa_offset_sf);
+ Streamer.emitSLEB128IntValue(CFAOffset / dataAlignmentFactor);
+ } else {
+ Streamer.emitInt8(dwarf::DW_CFA_def_cfa_offset);
+ Streamer.emitULEB128IntValue(CFAOffset);
+ }
return;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158097.550786.patch
Type: text/x-patch
Size: 879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230816/2e33d1b7/attachment.bin>
More information about the llvm-commits
mailing list