[PATCH] D73901: [DebugInfo][test] Fix calculation of generated line table size
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 3 08:59:23 PST 2020
jhenderson created this revision.
jhenderson added reviewers: ikudrin, probinson, JDevlieghere, dblaikie.
Herald added a project: LLVM.
The change rG1271cde47456 <https://reviews.llvm.org/rG1271cde47456a1201c085d0402a351f722a96f2d> incorrectly calculated the size of a line table's contents, when non-byte operands were used as arguments for extended or standard opcodes. This change fixes the calculation.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73901
Files:
llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h
Index: llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h
===================================================================
--- llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h
+++ llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h
@@ -214,6 +214,9 @@
void writeProloguePayload(const DWARFDebugLine::Prologue &Prologue,
AsmPrinter &Asm) const;
+ // Calculate the number of bytes the Contents will take up.
+ size_t getContentsSize() const;
+
llvm::Optional<DWARFDebugLine::Prologue> Prologue;
std::vector<ValueAndLength> CustomPrologue;
std::vector<ValueAndLength> Contents;
Index: llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
===================================================================
--- llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
+++ llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
@@ -27,6 +27,7 @@
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
#include "llvm/PassAnalysisSupport.h"
+#include "llvm/Support/LEB128.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
@@ -175,7 +176,7 @@
P.TotalLength += 4;
P.FormParams.Format = DWARF64;
}
- P.TotalLength += Contents.size();
+ P.TotalLength += getContentsSize();
P.FormParams.Version = Version;
P.MinInstLength = 1;
P.MaxOpsPerInst = 1;
@@ -259,6 +260,24 @@
}
}
+size_t dwarfgen::LineTable::getContentsSize() const {
+ size_t Size = 0;
+ for (auto Entry : Contents) {
+ switch (Entry.Length) {
+ case ULEB:
+ Size += getULEB128Size(Entry.Value);
+ break;
+ case SLEB:
+ Size += getSLEB128Size(Entry.Value);
+ break;
+ default:
+ Size += Entry.Length;
+ break;
+ }
+ }
+ return Size;
+}
+
MCSymbol *dwarfgen::LineTable::writeDefaultPrologue(AsmPrinter &Asm) const {
MCSymbol *UnitStart = Asm.createTempSymbol("line_unit_start");
MCSymbol *UnitEnd = Asm.createTempSymbol("line_unit_end");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73901.242098.patch
Type: text/x-patch
Size: 2018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200203/91bb2e25/attachment.bin>
More information about the llvm-commits
mailing list