[PATCH] D75188: [NFC][DebugInfo] Refactor address advancing operations to share code
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 08:42:02 PST 2020
jhenderson created this revision.
jhenderson added reviewers: labath, ikudrin, JDevlieghere, dblaikie, probinson.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
jhenderson added a child revision: D74819: [DebugInfo] Report unsupported maximum_operations_per_instruction values.
On its own, this change won't achieve much, but it provides a good place to do extra error checks that I plan on adding in D43470 <https://reviews.llvm.org/D43470>, D74819 <https://reviews.llvm.org/D74819> and another TBD patch. See the full patch series for context.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75188
Files:
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
Index: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -569,6 +569,24 @@
return LT;
}
+struct AdvanceAddrProperties {
+ uint8_t AdjustedOpcode;
+ uint8_t OperationAdvance;
+};
+
+static AdvanceAddrProperties
+getOperationAdvance(uint8_t Opcode, uint8_t OpcodeBase, uint8_t LineRange) {
+ AdvanceAddrProperties Result;
+ Result.AdjustedOpcode = Opcode - OpcodeBase;
+ Result.OperationAdvance = Result.AdjustedOpcode / LineRange;
+ return Result;
+}
+
+static uint64_t advanceAddr(uint64_t OperationAdvance,
+ const DWARFDebugLine::Prologue &Prologue) {
+ return OperationAdvance * Prologue.MinInstLength;
+}
+
Error DWARFDebugLine::LineTable::parse(
DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr,
const DWARFContext &Ctx, const DWARFUnit *U,
@@ -796,7 +814,7 @@
// result to the address register of the state machine.
{
uint64_t AddrOffset =
- DebugLineData.getULEB128(OffsetPtr) * Prologue.MinInstLength;
+ advanceAddr(DebugLineData.getULEB128(OffsetPtr), Prologue);
State.Row.Address.Address += AddrOffset;
if (OS)
*OS << " (" << AddrOffset << ")";
@@ -852,13 +870,13 @@
// than twice that range will it need to use both DW_LNS_advance_pc
// and a special opcode, requiring three or more bytes.
{
- uint8_t AdjustOpcode = 255 - Prologue.OpcodeBase;
+ AdvanceAddrProperties AdvanceAddr =
+ getOperationAdvance(255, Prologue.OpcodeBase, Prologue.LineRange);
uint64_t AddrOffset =
- (AdjustOpcode / Prologue.LineRange) * Prologue.MinInstLength;
+ advanceAddr(AdvanceAddr.OperationAdvance, Prologue);
State.Row.Address.Address += AddrOffset;
if (OS)
- *OS
- << format(" (0x%16.16" PRIx64 ")", AddrOffset);
+ *OS << format(" (0x%16.16" PRIx64 ")", AddrOffset);
}
break;
@@ -951,11 +969,11 @@
//
// line increment = line_base + (adjusted opcode % line_range)
- uint8_t AdjustOpcode = Opcode - Prologue.OpcodeBase;
- uint64_t AddrOffset =
- (AdjustOpcode / Prologue.LineRange) * Prologue.MinInstLength;
+ AdvanceAddrProperties AdvanceAddr =
+ getOperationAdvance(Opcode, Prologue.OpcodeBase, Prologue.LineRange);
+ uint64_t AddrOffset = advanceAddr(AdvanceAddr.OperationAdvance, Prologue);
int32_t LineOffset =
- Prologue.LineBase + (AdjustOpcode % Prologue.LineRange);
+ Prologue.LineBase + (AdvanceAddr.AdjustedOpcode % Prologue.LineRange);
State.Row.Line += LineOffset;
State.Row.Address.Address += AddrOffset;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75188.246743.patch
Type: text/x-patch
Size: 2890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200226/ca2a5431/attachment-0001.bin>
More information about the llvm-commits
mailing list