summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-04-17 16:28:58 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-04-17 16:28:58 +0000
commitfba25d6e9bef3229dabe322d3b117355821c1101 (patch)
treee45263085ac5898af262eb2365466e144bc2368e
parent561a1572338ec08e2a47287001bc55e954bab2e6 (diff)
downloadbcm5719-llvm-fba25d6e9bef3229dabe322d3b117355821c1101.tar.gz
bcm5719-llvm-fba25d6e9bef3229dabe322d3b117355821c1101.zip
AsmPrinter: Calculate type upfront for location lists, NFC
We can calculate the variable type up front before calling `DebugLocEntry::finalize()`. In fact, since we only care about the type if it's an `MDBasicType`, don't even bother resolving it using the type identifier map. llvm-svn: 235201
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h3
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp27
2 files changed, 15 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
index 4f6714e1a04..8dc003f1820 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
@@ -153,8 +153,7 @@ public:
}
/// \brief Lower this entry into a DWARF expression.
- void finalize(const AsmPrinter &AP,
- const DITypeIdentifierMap &TypeIdentifierMap);
+ void finalize(const AsmPrinter &AP, const MDBasicType *TypeIdentifierMap);
/// \brief Return the lowered DWARF expression.
StringRef getDWARFBytes() const { return DWARFBytes; }
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index fb8fc6e7545..853f6264e93 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -921,9 +921,16 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP,
// Build the location list for this variable.
buildLocationList(LocList.List, Ranges);
+
+ // If the variable has an MDBasicType, extract it. Basic types cannot have
+ // unique identifiers, so don't bother resolving the type with the
+ // identifier map.
+ const MDBasicType *BT = dyn_cast<MDBasicType>(
+ static_cast<const Metadata *>(IV.first->getType()));
+
// Finalize the entry by lowering it into a DWARF bytestream.
for (auto &Entry : LocList.List)
- Entry.finalize(*Asm, TypeIdentifierMap);
+ Entry.finalize(*Asm, BT);
}
// Collect info for variables that were optimized out.
@@ -1469,21 +1476,17 @@ void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer,
Streamer.EmitInt8(Byte, Comment != End ? *(Comment++) : "");
}
-static void emitDebugLocValue(const AsmPrinter &AP,
- const DITypeIdentifierMap &TypeIdentifierMap,
+static void emitDebugLocValue(const AsmPrinter &AP, const MDBasicType *BT,
ByteStreamer &Streamer,
const DebugLocEntry::Value &Value,
unsigned PieceOffsetInBits) {
- DIVariable DV = Value.getVariable();
DebugLocDwarfExpression DwarfExpr(*AP.MF->getSubtarget().getRegisterInfo(),
AP.getDwarfDebug()->getDwarfVersion(),
Streamer);
// Regular entry.
if (Value.isInt()) {
- MDType *T = DV->getType().resolve(TypeIdentifierMap);
- auto *B = dyn_cast<MDBasicType>(T);
- if (B && (B->getEncoding() == dwarf::DW_ATE_signed ||
- B->getEncoding() == dwarf::DW_ATE_signed_char))
+ if (BT && (BT->getEncoding() == dwarf::DW_ATE_signed ||
+ BT->getEncoding() == dwarf::DW_ATE_signed_char))
DwarfExpr.AddSignedConstant(Value.getInt());
else
DwarfExpr.AddUnsignedConstant(Value.getInt());
@@ -1509,9 +1512,7 @@ static void emitDebugLocValue(const AsmPrinter &AP,
// FIXME: ^
}
-
-void DebugLocEntry::finalize(const AsmPrinter &AP,
- const DITypeIdentifierMap &TypeIdentifierMap) {
+void DebugLocEntry::finalize(const AsmPrinter &AP, const MDBasicType *BT) {
BufferByteStreamer Streamer(DWARFBytes, Comments);
const DebugLocEntry::Value Value = Values[0];
if (Value.isBitPiece()) {
@@ -1538,11 +1539,11 @@ void DebugLocEntry::finalize(const AsmPrinter &AP,
}
Offset += PieceSize;
- emitDebugLocValue(AP, TypeIdentifierMap, Streamer, Piece, PieceOffset);
+ emitDebugLocValue(AP, BT, Streamer, Piece, PieceOffset);
}
} else {
assert(Values.size() == 1 && "only pieces may have >1 value");
- emitDebugLocValue(AP, TypeIdentifierMap, Streamer, Value, 0);
+ emitDebugLocValue(AP, BT, Streamer, Value, 0);
}
}
OpenPOWER on IntegriCloud