summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp81
1 files changed, 12 insertions, 69 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 3e60f15a22d..1106b859859 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -41,8 +41,6 @@
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
-#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
-#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
@@ -163,7 +161,6 @@ static const char *const DWARFGroupName = "dwarf";
static const char *const DWARFGroupDescription = "DWARF Emission";
static const char *const DbgTimerName = "writer";
static const char *const DbgTimerDescription = "DWARF Debug Writer";
-static constexpr unsigned ULEB128PadSize = 4;
void DebugLocDwarfExpression::emitOp(uint8_t Op, const char *Comment) {
BS.EmitInt8(
@@ -179,11 +176,6 @@ void DebugLocDwarfExpression::emitUnsigned(uint64_t Value) {
BS.EmitULEB128(Value, Twine(Value));
}
-void DebugLocDwarfExpression::emitBaseTypeRef(uint64_t Idx) {
- assert(Idx < (1ULL << (ULEB128PadSize * 7)) && "Idx wont fit");
- BS.EmitULEB128(Idx, Twine(Idx), ULEB128PadSize);
-}
-
bool DebugLocDwarfExpression::isFrameRegister(const TargetRegisterInfo &TRI,
unsigned MachineReg) {
// This information is not available while emitting .debug_loc entries.
@@ -948,11 +940,6 @@ void DwarfDebug::endModule() {
assert(CurFn == nullptr);
assert(CurMI == nullptr);
- for (const auto &P : CUMap) {
- auto &CU = *P.second;
- CU.createBaseTypeDIEs();
- }
-
// If we aren't actually generating debug info (check beginModule -
// conditionalized on !DisableDebugInfoPrinting and the presence of the
// llvm.dbg.cu metadata node)
@@ -1382,7 +1369,7 @@ void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
// Finalize the entry by lowering it into a DWARF bytestream.
for (auto &Entry : Entries)
- Entry.finalize(*Asm, List, BT, TheCU);
+ Entry.finalize(*Asm, List, BT);
}
// For each InlinedEntity collected from DBG_LABEL instructions, convert to
@@ -1924,55 +1911,13 @@ void DwarfDebug::emitDebugStr() {
StringOffsetsSection, /* UseRelativeOffsets = */ true);
}
-void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer, const
- DebugLocStream::Entry &Entry,
- const DwarfCompileUnit *CU) {
+void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer,
+ const DebugLocStream::Entry &Entry) {
auto &&Comments = DebugLocs.getComments(Entry);
auto Comment = Comments.begin();
auto End = Comments.end();
-
- // The expressions are inserted into a byte stream rather early (see
- // DwarfExpression::addExpression) so for those ops (e.g. DW_OP_convert) that
- // need to reference a base_type DIE the offset of that DIE is not yet known.
- // To deal with this we instead insert a placeholder early and then extract
- // it here and replace it with the real reference.
- unsigned PtrSize = Asm->MAI->getCodePointerSize();
- DWARFDataExtractor Data(StringRef(DebugLocs.getBytes(Entry).data(),
- DebugLocs.getBytes(Entry).size()),
- Asm->getDataLayout().isLittleEndian(), PtrSize);
- DWARFExpression Expr(Data, getDwarfVersion(), PtrSize);
-
- using Encoding = DWARFExpression::Operation::Encoding;
- uint32_t Offset = 0;
- for (auto &Op : Expr) {
- assert(Op.getCode() != dwarf::DW_OP_const_type &&
- "3 operand ops not yet supported");
- Streamer.EmitInt8(Op.getCode(), Comment != End ? *(Comment++) : "");
- Offset++;
- for (unsigned I = 0; I < 2; ++I) {
- if (Op.getDescription().Op[I] == Encoding::SizeNA)
- continue;
- if (Op.getDescription().Op[I] == Encoding::BaseTypeRef) {
- if (CU) {
- uint64_t Offset = CU->ExprRefedBaseTypes[Op.getRawOperand(I)].Die->getOffset();
- assert(Offset < (1ULL << (ULEB128PadSize * 7)) && "Offset wont fit");
- Asm->EmitULEB128(Offset, nullptr, ULEB128PadSize);
- } else {
- // Emit a reference to the 'generic type'.
- Asm->EmitULEB128(0, nullptr, ULEB128PadSize);
- }
- // Make sure comments stay aligned.
- for (unsigned J = 0; J < ULEB128PadSize; ++J)
- if (Comment != End)
- Comment++;
- } else {
- for (uint32_t J = Offset; J < Op.getOperandEndOffset(I); ++J)
- Streamer.EmitInt8(Data.getData()[J], Comment != End ? *(Comment++) : "");
- }
- Offset = Op.getOperandEndOffset(I);
- }
- assert(Offset == Op.getEndOffset());
- }
+ for (uint8_t Byte : DebugLocs.getBytes(Entry))
+ Streamer.EmitInt8(Byte, Comment != End ? *(Comment++) : "");
}
static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
@@ -2006,12 +1951,11 @@ static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
void DebugLocEntry::finalize(const AsmPrinter &AP,
DebugLocStream::ListBuilder &List,
- const DIBasicType *BT,
- DwarfCompileUnit &TheCU) {
+ const DIBasicType *BT) {
assert(Begin != End && "unexpected location list entry with empty range");
DebugLocStream::EntryBuilder Entry(List, Begin, End);
BufferByteStreamer Streamer = Entry.getStreamer();
- DebugLocDwarfExpression DwarfExpr(AP.getDwarfVersion(), Streamer, TheCU);
+ DebugLocDwarfExpression DwarfExpr(AP.getDwarfVersion(), Streamer);
const DebugLocEntry::Value &Value = Values[0];
if (Value.isFragment()) {
// Emit all fragments that belong to the same variable and range.
@@ -2031,8 +1975,7 @@ void DebugLocEntry::finalize(const AsmPrinter &AP,
DwarfExpr.finalize();
}
-void DwarfDebug::emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry,
- const DwarfCompileUnit *CU) {
+void DwarfDebug::emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry) {
// Emit the size.
Asm->OutStreamer->AddComment("Loc expr size");
if (getDwarfVersion() >= 5)
@@ -2041,7 +1984,7 @@ void DwarfDebug::emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry,
Asm->emitInt16(DebugLocs.getBytes(Entry).size());
// Emit the entry.
APByteStreamer Streamer(*Asm);
- emitDebugLocEntry(Streamer, Entry, CU);
+ emitDebugLocEntry(Streamer, Entry);
}
// Emit the common part of the DWARF 5 range/locations list tables header.
@@ -2141,7 +2084,7 @@ void DwarfDebug::emitDebugLoc() {
Asm->EmitLabelDifference(Entry.EndSym, Base, Size);
}
- emitDebugLocEntryLocation(Entry, CU);
+ emitDebugLocEntryLocation(Entry);
continue;
}
@@ -2162,7 +2105,7 @@ void DwarfDebug::emitDebugLoc() {
Asm->OutStreamer->EmitSymbolValue(Entry.EndSym, Size);
}
- emitDebugLocEntryLocation(Entry, CU);
+ emitDebugLocEntryLocation(Entry);
}
if (IsLocLists) {
@@ -2198,7 +2141,7 @@ void DwarfDebug::emitDebugLocDWO() {
Asm->EmitULEB128(idx);
Asm->EmitLabelDifference(Entry.EndSym, Entry.BeginSym, 4);
- emitDebugLocEntryLocation(Entry, List.CU);
+ emitDebugLocEntryLocation(Entry);
}
Asm->emitInt8(dwarf::DW_LLE_end_of_list);
}
OpenPOWER on IntegriCloud