mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-21 21:29:41 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235201 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6aa30ccfdb
commit
7c554b51ea
@ -153,8 +153,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Lower this entry into a DWARF expression.
|
/// \brief Lower this entry into a DWARF expression.
|
||||||
void finalize(const AsmPrinter &AP,
|
void finalize(const AsmPrinter &AP, const MDBasicType *TypeIdentifierMap);
|
||||||
const DITypeIdentifierMap &TypeIdentifierMap);
|
|
||||||
|
|
||||||
/// \brief Return the lowered DWARF expression.
|
/// \brief Return the lowered DWARF expression.
|
||||||
StringRef getDWARFBytes() const { return DWARFBytes; }
|
StringRef getDWARFBytes() const { return DWARFBytes; }
|
||||||
|
@ -921,9 +921,16 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP,
|
|||||||
|
|
||||||
// Build the location list for this variable.
|
// Build the location list for this variable.
|
||||||
buildLocationList(LocList.List, Ranges);
|
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.
|
// Finalize the entry by lowering it into a DWARF bytestream.
|
||||||
for (auto &Entry : LocList.List)
|
for (auto &Entry : LocList.List)
|
||||||
Entry.finalize(*Asm, TypeIdentifierMap);
|
Entry.finalize(*Asm, BT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect info for variables that were optimized out.
|
// Collect info for variables that were optimized out.
|
||||||
@ -1469,21 +1476,17 @@ void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer,
|
|||||||
Streamer.EmitInt8(Byte, Comment != End ? *(Comment++) : "");
|
Streamer.EmitInt8(Byte, Comment != End ? *(Comment++) : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emitDebugLocValue(const AsmPrinter &AP,
|
static void emitDebugLocValue(const AsmPrinter &AP, const MDBasicType *BT,
|
||||||
const DITypeIdentifierMap &TypeIdentifierMap,
|
|
||||||
ByteStreamer &Streamer,
|
ByteStreamer &Streamer,
|
||||||
const DebugLocEntry::Value &Value,
|
const DebugLocEntry::Value &Value,
|
||||||
unsigned PieceOffsetInBits) {
|
unsigned PieceOffsetInBits) {
|
||||||
DIVariable DV = Value.getVariable();
|
|
||||||
DebugLocDwarfExpression DwarfExpr(*AP.MF->getSubtarget().getRegisterInfo(),
|
DebugLocDwarfExpression DwarfExpr(*AP.MF->getSubtarget().getRegisterInfo(),
|
||||||
AP.getDwarfDebug()->getDwarfVersion(),
|
AP.getDwarfDebug()->getDwarfVersion(),
|
||||||
Streamer);
|
Streamer);
|
||||||
// Regular entry.
|
// Regular entry.
|
||||||
if (Value.isInt()) {
|
if (Value.isInt()) {
|
||||||
MDType *T = DV->getType().resolve(TypeIdentifierMap);
|
if (BT && (BT->getEncoding() == dwarf::DW_ATE_signed ||
|
||||||
auto *B = dyn_cast<MDBasicType>(T);
|
BT->getEncoding() == dwarf::DW_ATE_signed_char))
|
||||||
if (B && (B->getEncoding() == dwarf::DW_ATE_signed ||
|
|
||||||
B->getEncoding() == dwarf::DW_ATE_signed_char))
|
|
||||||
DwarfExpr.AddSignedConstant(Value.getInt());
|
DwarfExpr.AddSignedConstant(Value.getInt());
|
||||||
else
|
else
|
||||||
DwarfExpr.AddUnsignedConstant(Value.getInt());
|
DwarfExpr.AddUnsignedConstant(Value.getInt());
|
||||||
@ -1509,9 +1512,7 @@ static void emitDebugLocValue(const AsmPrinter &AP,
|
|||||||
// FIXME: ^
|
// FIXME: ^
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebugLocEntry::finalize(const AsmPrinter &AP, const MDBasicType *BT) {
|
||||||
void DebugLocEntry::finalize(const AsmPrinter &AP,
|
|
||||||
const DITypeIdentifierMap &TypeIdentifierMap) {
|
|
||||||
BufferByteStreamer Streamer(DWARFBytes, Comments);
|
BufferByteStreamer Streamer(DWARFBytes, Comments);
|
||||||
const DebugLocEntry::Value Value = Values[0];
|
const DebugLocEntry::Value Value = Values[0];
|
||||||
if (Value.isBitPiece()) {
|
if (Value.isBitPiece()) {
|
||||||
@ -1538,11 +1539,11 @@ void DebugLocEntry::finalize(const AsmPrinter &AP,
|
|||||||
}
|
}
|
||||||
Offset += PieceSize;
|
Offset += PieceSize;
|
||||||
|
|
||||||
emitDebugLocValue(AP, TypeIdentifierMap, Streamer, Piece, PieceOffset);
|
emitDebugLocValue(AP, BT, Streamer, Piece, PieceOffset);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(Values.size() == 1 && "only pieces may have >1 value");
|
assert(Values.size() == 1 && "only pieces may have >1 value");
|
||||||
emitDebugLocValue(AP, TypeIdentifierMap, Streamer, Value, 0);
|
emitDebugLocValue(AP, BT, Streamer, Value, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user