mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
Replace DebugLocTuple with DILocation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93630 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -17,6 +17,7 @@
|
|||||||
#define LLVM_CODEGEN_ASMPRINTER_H
|
#define LLVM_CODEGEN_ASMPRINTER_H
|
||||||
|
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
|
#include "llvm/Analysis/DebugInfo.h"
|
||||||
#include "llvm/Support/DebugLoc.h"
|
#include "llvm/Support/DebugLoc.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
@ -151,7 +152,7 @@ namespace llvm {
|
|||||||
mutable unsigned Counter;
|
mutable unsigned Counter;
|
||||||
|
|
||||||
// Private state for processDebugLoc()
|
// Private state for processDebugLoc()
|
||||||
mutable DebugLocTuple PrevDLT;
|
mutable DILocation PrevDLT;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit AsmPrinter(formatted_raw_ostream &o, TargetMachine &TM,
|
explicit AsmPrinter(formatted_raw_ostream &o, TargetMachine &TM,
|
||||||
|
@ -368,8 +368,8 @@ public:
|
|||||||
// Debug location.
|
// Debug location.
|
||||||
//
|
//
|
||||||
|
|
||||||
/// getDebugLocTuple - Get the DebugLocTuple for a given DebugLoc object.
|
/// getDILocation - Get the DILocation for a given DebugLoc object.
|
||||||
DebugLocTuple getDebugLocTuple(DebugLoc DL) const;
|
DILocation getDILocation(DebugLoc DL) const;
|
||||||
|
|
||||||
/// getDefaultDebugLoc - Get the default debug location for the machine
|
/// getDefaultDebugLoc - Get the default debug location for the machine
|
||||||
/// function.
|
/// function.
|
||||||
|
@ -21,29 +21,6 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
class MDNode;
|
class MDNode;
|
||||||
|
|
||||||
/// DebugLocTuple - Debug location tuple of filename id, line and column.
|
|
||||||
///
|
|
||||||
struct DebugLocTuple {
|
|
||||||
MDNode *Scope;
|
|
||||||
MDNode *InlinedAtLoc;
|
|
||||||
unsigned Line, Col;
|
|
||||||
|
|
||||||
DebugLocTuple()
|
|
||||||
: Scope(0), InlinedAtLoc(0), Line(~0U), Col(~0U) {}
|
|
||||||
|
|
||||||
DebugLocTuple(MDNode *n, MDNode *i, unsigned l, unsigned c)
|
|
||||||
: Scope(n), InlinedAtLoc(i), Line(l), Col(c) {}
|
|
||||||
|
|
||||||
bool operator==(const DebugLocTuple &DLT) const {
|
|
||||||
return Scope == DLT.Scope &&
|
|
||||||
InlinedAtLoc == DLT.InlinedAtLoc &&
|
|
||||||
Line == DLT.Line && Col == DLT.Col;
|
|
||||||
}
|
|
||||||
bool operator!=(const DebugLocTuple &DLT) const {
|
|
||||||
return !(*this == DLT);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr
|
/// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr
|
||||||
/// to index into a vector of unique debug location tuples.
|
/// to index into a vector of unique debug location tuples.
|
||||||
class DebugLoc {
|
class DebugLoc {
|
||||||
@ -65,40 +42,16 @@ namespace llvm {
|
|||||||
bool operator!=(const DebugLoc &DL) const { return !(*this == DL); }
|
bool operator!=(const DebugLoc &DL) const { return !(*this == DL); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Specialize DenseMapInfo for DebugLocTuple.
|
|
||||||
template<> struct DenseMapInfo<DebugLocTuple> {
|
|
||||||
static inline DebugLocTuple getEmptyKey() {
|
|
||||||
return DebugLocTuple(0, 0, ~0U, ~0U);
|
|
||||||
}
|
|
||||||
static inline DebugLocTuple getTombstoneKey() {
|
|
||||||
return DebugLocTuple((MDNode*)~1U, (MDNode*)~1U, ~1U, ~1U);
|
|
||||||
}
|
|
||||||
static unsigned getHashValue(const DebugLocTuple &Val) {
|
|
||||||
return DenseMapInfo<MDNode*>::getHashValue(Val.Scope) ^
|
|
||||||
DenseMapInfo<MDNode*>::getHashValue(Val.InlinedAtLoc) ^
|
|
||||||
DenseMapInfo<unsigned>::getHashValue(Val.Line) ^
|
|
||||||
DenseMapInfo<unsigned>::getHashValue(Val.Col);
|
|
||||||
}
|
|
||||||
static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) {
|
|
||||||
return LHS.Scope == RHS.Scope &&
|
|
||||||
LHS.InlinedAtLoc == RHS.InlinedAtLoc &&
|
|
||||||
LHS.Line == RHS.Line &&
|
|
||||||
LHS.Col == RHS.Col;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <> struct isPodLike<DebugLocTuple> {static const bool value = true;};
|
|
||||||
|
|
||||||
|
|
||||||
/// DebugLocTracker - This class tracks debug location information.
|
/// DebugLocTracker - This class tracks debug location information.
|
||||||
///
|
///
|
||||||
struct DebugLocTracker {
|
struct DebugLocTracker {
|
||||||
/// DebugLocations - A vector of unique DebugLocTuple's.
|
/// DebugLocations - A vector of unique DebugLocTuple's.
|
||||||
///
|
///
|
||||||
std::vector<DebugLocTuple> DebugLocations;
|
std::vector<MDNode *> DebugLocations;
|
||||||
|
|
||||||
/// DebugIdMap - This maps DebugLocTuple's to indices into the
|
/// DebugIdMap - This maps DebugLocTuple's to indices into the
|
||||||
/// DebugLocations vector.
|
/// DebugLocations vector.
|
||||||
DenseMap<DebugLocTuple, unsigned> DebugIdMap;
|
DenseMap<MDNode *, unsigned> DebugIdMap;
|
||||||
|
|
||||||
DebugLocTracker() {}
|
DebugLocTracker() {}
|
||||||
};
|
};
|
||||||
|
@ -1320,23 +1320,15 @@ bool llvm::getLocationInfo(const Value *V, std::string &DisplayName,
|
|||||||
/// from DILocation.
|
/// from DILocation.
|
||||||
DebugLoc llvm::ExtractDebugLocation(DILocation &Loc,
|
DebugLoc llvm::ExtractDebugLocation(DILocation &Loc,
|
||||||
DebugLocTracker &DebugLocInfo) {
|
DebugLocTracker &DebugLocInfo) {
|
||||||
DebugLoc DL;
|
DenseMap<MDNode *, unsigned>::iterator II
|
||||||
MDNode *Context = Loc.getScope().getNode();
|
= DebugLocInfo.DebugIdMap.find(Loc.getNode());
|
||||||
MDNode *InlinedLoc = NULL;
|
|
||||||
if (!Loc.getOrigLocation().isNull())
|
|
||||||
InlinedLoc = Loc.getOrigLocation().getNode();
|
|
||||||
// If this location is already tracked then use it.
|
|
||||||
DebugLocTuple Tuple(Context, InlinedLoc, Loc.getLineNumber(),
|
|
||||||
Loc.getColumnNumber());
|
|
||||||
DenseMap<DebugLocTuple, unsigned>::iterator II
|
|
||||||
= DebugLocInfo.DebugIdMap.find(Tuple);
|
|
||||||
if (II != DebugLocInfo.DebugIdMap.end())
|
if (II != DebugLocInfo.DebugIdMap.end())
|
||||||
return DebugLoc::get(II->second);
|
return DebugLoc::get(II->second);
|
||||||
|
|
||||||
// Add a new location entry.
|
// Add a new location entry.
|
||||||
unsigned Id = DebugLocInfo.DebugLocations.size();
|
unsigned Id = DebugLocInfo.DebugLocations.size();
|
||||||
DebugLocInfo.DebugLocations.push_back(Tuple);
|
DebugLocInfo.DebugLocations.push_back(Loc.getNode());
|
||||||
DebugLocInfo.DebugIdMap[Tuple] = Id;
|
DebugLocInfo.DebugIdMap[Loc.getNode()] = Id;
|
||||||
|
|
||||||
return DebugLoc::get(Id);
|
return DebugLoc::get(Id);
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,7 @@ AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
|
|||||||
// FIXME: Pass instprinter to streamer.
|
// FIXME: Pass instprinter to streamer.
|
||||||
OutStreamer(*createAsmStreamer(OutContext, O, *T, 0)),
|
OutStreamer(*createAsmStreamer(OutContext, O, *T, 0)),
|
||||||
|
|
||||||
LastMI(0), LastFn(0), Counter(~0U),
|
LastMI(0), LastFn(0), Counter(~0U), PrevDLT(NULL) {
|
||||||
PrevDLT(0, 0, ~0U, ~0U) {
|
|
||||||
DW = 0; MMI = 0;
|
DW = 0; MMI = 0;
|
||||||
switch (AsmVerbose) {
|
switch (AsmVerbose) {
|
||||||
case cl::BOU_UNSET: VerboseAsm = VDef; break;
|
case cl::BOU_UNSET: VerboseAsm = VDef; break;
|
||||||
@ -1406,14 +1405,15 @@ void AsmPrinter::processDebugLoc(const MachineInstr *MI,
|
|||||||
DebugLoc DL = MI->getDebugLoc();
|
DebugLoc DL = MI->getDebugLoc();
|
||||||
if (DL.isUnknown())
|
if (DL.isUnknown())
|
||||||
return;
|
return;
|
||||||
DebugLocTuple CurDLT = MF->getDebugLocTuple(DL);
|
DILocation CurDLT = MF->getDILocation(DL);
|
||||||
if (CurDLT.Scope == 0)
|
if (CurDLT.getScope().isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (BeforePrintingInsn) {
|
if (BeforePrintingInsn) {
|
||||||
if (CurDLT != PrevDLT) {
|
if (CurDLT.getNode() != PrevDLT.getNode()) {
|
||||||
unsigned L = DW->RecordSourceLine(CurDLT.Line, CurDLT.Col,
|
unsigned L = DW->RecordSourceLine(CurDLT.getLineNumber(),
|
||||||
CurDLT.Scope);
|
CurDLT.getColumnNumber(),
|
||||||
|
CurDLT.getScope().getNode());
|
||||||
printLabel(L);
|
printLabel(L);
|
||||||
O << '\n';
|
O << '\n';
|
||||||
DW->BeginScope(MI, L);
|
DW->BeginScope(MI, L);
|
||||||
@ -1910,20 +1910,20 @@ void AsmPrinter::EmitComments(const MachineInstr &MI) const {
|
|||||||
bool Newline = false;
|
bool Newline = false;
|
||||||
|
|
||||||
if (!MI.getDebugLoc().isUnknown()) {
|
if (!MI.getDebugLoc().isUnknown()) {
|
||||||
DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
|
DILocation DLT = MF->getDILocation(MI.getDebugLoc());
|
||||||
|
|
||||||
// Print source line info.
|
// Print source line info.
|
||||||
O.PadToColumn(MAI->getCommentColumn());
|
O.PadToColumn(MAI->getCommentColumn());
|
||||||
O << MAI->getCommentString() << ' ';
|
O << MAI->getCommentString() << ' ';
|
||||||
DIScope Scope(DLT.Scope);
|
DIScope Scope = DLT.getScope();
|
||||||
// Omit the directory, because it's likely to be long and uninteresting.
|
// Omit the directory, because it's likely to be long and uninteresting.
|
||||||
if (!Scope.isNull())
|
if (!Scope.isNull())
|
||||||
O << Scope.getFilename();
|
O << Scope.getFilename();
|
||||||
else
|
else
|
||||||
O << "<unknown>";
|
O << "<unknown>";
|
||||||
O << ':' << DLT.Line;
|
O << ':' << DLT.getLineNumber();
|
||||||
if (DLT.Col != 0)
|
if (DLT.getColumnNumber() != 0)
|
||||||
O << ':' << DLT.Col;
|
O << ':' << DLT.getColumnNumber();
|
||||||
Newline = true;
|
Newline = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2001,13 +2001,14 @@ bool DwarfDebug::extractScopeInformation(MachineFunction *MF) {
|
|||||||
MIIndexMap[MInsn] = MIIndex++;
|
MIIndexMap[MInsn] = MIIndex++;
|
||||||
DebugLoc DL = MInsn->getDebugLoc();
|
DebugLoc DL = MInsn->getDebugLoc();
|
||||||
if (DL.isUnknown()) continue;
|
if (DL.isUnknown()) continue;
|
||||||
DebugLocTuple DLT = MF->getDebugLocTuple(DL);
|
DILocation DLT = MF->getDILocation(DL);
|
||||||
if (!DLT.Scope) continue;
|
DIScope DLTScope = DLT.getScope();
|
||||||
|
if (DLTScope.isNull()) continue;
|
||||||
// There is no need to create another DIE for compile unit. For all
|
// There is no need to create another DIE for compile unit. For all
|
||||||
// other scopes, create one DbgScope now. This will be translated
|
// other scopes, create one DbgScope now. This will be translated
|
||||||
// into a scope DIE at the end.
|
// into a scope DIE at the end.
|
||||||
if (DIDescriptor(DLT.Scope).isCompileUnit()) continue;
|
if (DLTScope.isCompileUnit()) continue;
|
||||||
createDbgScope(DLT.Scope, DLT.InlinedAtLoc);
|
createDbgScope(DLTScope.getNode(), DLT.getOrigLocation().getNode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2020,13 +2021,15 @@ bool DwarfDebug::extractScopeInformation(MachineFunction *MF) {
|
|||||||
const MachineInstr *MInsn = II;
|
const MachineInstr *MInsn = II;
|
||||||
DebugLoc DL = MInsn->getDebugLoc();
|
DebugLoc DL = MInsn->getDebugLoc();
|
||||||
if (DL.isUnknown()) continue;
|
if (DL.isUnknown()) continue;
|
||||||
DebugLocTuple DLT = MF->getDebugLocTuple(DL);
|
DILocation DLT = MF->getDILocation(DL);
|
||||||
if (!DLT.Scope) continue;
|
DIScope DLTScope = DLT.getScope();
|
||||||
|
if (DLTScope.isNull()) continue;
|
||||||
// There is no need to create another DIE for compile unit. For all
|
// There is no need to create another DIE for compile unit. For all
|
||||||
// other scopes, create one DbgScope now. This will be translated
|
// other scopes, create one DbgScope now. This will be translated
|
||||||
// into a scope DIE at the end.
|
// into a scope DIE at the end.
|
||||||
if (DIDescriptor(DLT.Scope).isCompileUnit()) continue;
|
if (DLTScope.isCompileUnit()) continue;
|
||||||
DbgScope *Scope = getUpdatedDbgScope(DLT.Scope, MInsn, DLT.InlinedAtLoc);
|
DbgScope *Scope = getUpdatedDbgScope(DLTScope.getNode(), MInsn,
|
||||||
|
DLT.getOrigLocation().getNode());
|
||||||
Scope->setLastInsn(MInsn);
|
Scope->setLastInsn(MInsn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2091,13 +2094,16 @@ void DwarfDebug::beginFunction(MachineFunction *MF) {
|
|||||||
// function.
|
// function.
|
||||||
DebugLoc FDL = MF->getDefaultDebugLoc();
|
DebugLoc FDL = MF->getDefaultDebugLoc();
|
||||||
if (!FDL.isUnknown()) {
|
if (!FDL.isUnknown()) {
|
||||||
DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
|
DILocation DLT = MF->getDILocation(FDL);
|
||||||
unsigned LabelID = 0;
|
unsigned LabelID = 0;
|
||||||
DISubprogram SP = getDISubprogram(DLT.Scope);
|
DISubprogram SP = getDISubprogram(DLT.getScope().getNode());
|
||||||
if (!SP.isNull())
|
if (!SP.isNull())
|
||||||
LabelID = recordSourceLine(SP.getLineNumber(), 0, DLT.Scope);
|
LabelID = recordSourceLine(SP.getLineNumber(), 0,
|
||||||
|
DLT.getScope().getNode());
|
||||||
else
|
else
|
||||||
LabelID = recordSourceLine(DLT.Line, DLT.Col, DLT.Scope);
|
LabelID = recordSourceLine(DLT.getLineNumber(),
|
||||||
|
DLT.getColumnNumber(),
|
||||||
|
DLT.getScope().getNode());
|
||||||
Asm->printLabel(LabelID);
|
Asm->printLabel(LabelID);
|
||||||
O << '\n';
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
@ -426,12 +426,12 @@ unsigned MachineFunction::addLiveIn(unsigned PReg,
|
|||||||
return VReg;
|
return VReg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getDebugLocTuple - Get the DebugLocTuple for a given DebugLoc object.
|
/// getDILocation - Get the DILocation for a given DebugLoc object.
|
||||||
DebugLocTuple MachineFunction::getDebugLocTuple(DebugLoc DL) const {
|
DILocation MachineFunction::getDILocation(DebugLoc DL) const {
|
||||||
unsigned Idx = DL.getIndex();
|
unsigned Idx = DL.getIndex();
|
||||||
assert(Idx < DebugLocInfo.DebugLocations.size() &&
|
assert(Idx < DebugLocInfo.DebugLocations.size() &&
|
||||||
"Invalid index into debug locations!");
|
"Invalid index into debug locations!");
|
||||||
return DebugLocInfo.DebugLocations[Idx];
|
return DILocation(DebugLocInfo.DebugLocations[Idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -1189,17 +1189,17 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
|||||||
|
|
||||||
// TODO: print InlinedAtLoc information
|
// TODO: print InlinedAtLoc information
|
||||||
|
|
||||||
DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc);
|
DILocation DLT = MF->getDILocation(debugLoc);
|
||||||
DIScope Scope(DLT.Scope);
|
DIScope Scope = DLT.getScope();
|
||||||
OS << " dbg:";
|
OS << " dbg:";
|
||||||
// Omit the directory, since it's usually long and uninteresting.
|
// Omit the directory, since it's usually long and uninteresting.
|
||||||
if (!Scope.isNull())
|
if (!Scope.isNull())
|
||||||
OS << Scope.getFilename();
|
OS << Scope.getFilename();
|
||||||
else
|
else
|
||||||
OS << "<unknown>";
|
OS << "<unknown>";
|
||||||
OS << ':' << DLT.Line;
|
OS << ':' << DLT.getLineNumber();
|
||||||
if (DLT.Col != 0)
|
if (DLT.getColumnNumber() != 0)
|
||||||
OS << ':' << DLT.Col;
|
OS << ':' << DLT.getColumnNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
OS << "\n";
|
OS << "\n";
|
||||||
|
@ -368,12 +368,12 @@ namespace {
|
|||||||
// the stub is unused.
|
// the stub is unused.
|
||||||
DenseMap<void *, SmallPtrSet<const Function*, 1> > StubFnRefs;
|
DenseMap<void *, SmallPtrSet<const Function*, 1> > StubFnRefs;
|
||||||
|
|
||||||
DebugLocTuple PrevDLT;
|
DILocation PrevDLT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JITEmitter(JIT &jit, JITMemoryManager *JMM, TargetMachine &TM)
|
JITEmitter(JIT &jit, JITMemoryManager *JMM, TargetMachine &TM)
|
||||||
: SizeEstimate(0), Resolver(jit, *this), MMI(0), CurFn(0),
|
: SizeEstimate(0), Resolver(jit, *this), MMI(0), CurFn(0),
|
||||||
EmittedFunctions(this) {
|
EmittedFunctions(this), PrevDLT(NULL) {
|
||||||
MemMgr = JMM ? JMM : JITMemoryManager::CreateDefaultMemManager();
|
MemMgr = JMM ? JMM : JITMemoryManager::CreateDefaultMemManager();
|
||||||
if (jit.getJITInfo().needsGOT()) {
|
if (jit.getJITInfo().needsGOT()) {
|
||||||
MemMgr->AllocateGOT();
|
MemMgr->AllocateGOT();
|
||||||
@ -806,10 +806,11 @@ void JITEmitter::AddStubToCurrentFunction(void *StubAddr) {
|
|||||||
|
|
||||||
void JITEmitter::processDebugLoc(DebugLoc DL, bool BeforePrintingInsn) {
|
void JITEmitter::processDebugLoc(DebugLoc DL, bool BeforePrintingInsn) {
|
||||||
if (!DL.isUnknown()) {
|
if (!DL.isUnknown()) {
|
||||||
DebugLocTuple CurDLT = EmissionDetails.MF->getDebugLocTuple(DL);
|
DILocation CurDLT = EmissionDetails.MF->getDILocation(DL);
|
||||||
|
|
||||||
if (BeforePrintingInsn) {
|
if (BeforePrintingInsn) {
|
||||||
if (CurDLT.Scope != 0 && PrevDLT != CurDLT) {
|
if (CurDLT.getScope().getNode() != 0
|
||||||
|
&& PrevDLT.getNode() != CurDLT.getNode()) {
|
||||||
JITEvent_EmittedFunctionDetails::LineStart NextLine;
|
JITEvent_EmittedFunctionDetails::LineStart NextLine;
|
||||||
NextLine.Address = getCurrentPCValue();
|
NextLine.Address = getCurrentPCValue();
|
||||||
NextLine.Loc = DL;
|
NextLine.Loc = DL;
|
||||||
|
@ -259,8 +259,9 @@ void PIC16DbgInfo::ChangeDebugLoc(const MachineFunction &MF,
|
|||||||
if (! EmitDebugDirectives) return;
|
if (! EmitDebugDirectives) return;
|
||||||
assert (! DL.isUnknown() && "can't change to invalid debug loc");
|
assert (! DL.isUnknown() && "can't change to invalid debug loc");
|
||||||
|
|
||||||
MDNode *CU = MF.getDebugLocTuple(DL).Scope;
|
DILocation Loc = MF.getDILocation(DL);
|
||||||
unsigned line = MF.getDebugLocTuple(DL).Line;
|
MDNode *CU = Loc.getScope().getNode();
|
||||||
|
unsigned line = Loc.getLineNumber();
|
||||||
|
|
||||||
SwitchToCU(CU);
|
SwitchToCU(CU);
|
||||||
SwitchToLine(line, IsInBeginFunction);
|
SwitchToLine(line, IsInBeginFunction);
|
||||||
|
Reference in New Issue
Block a user