mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-17 18:24:34 +00:00
Simplify. Let DbgVariable keep track of variable's DBG_VALUE machine instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137656 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -417,10 +417,7 @@ DIE *DwarfDebug::constructVariableDIE(DbgVariable *DV, LexicalScope *Scope) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if variable is described by a DBG_VALUE instruction.
|
// Check if variable is described by a DBG_VALUE instruction.
|
||||||
DenseMap<const DbgVariable *, const MachineInstr *>::iterator DVI =
|
if (const MachineInstr *DVInsn = DV->getMInsn()) {
|
||||||
DbgVariableToDbgInstMap.find(DV);
|
|
||||||
if (DVI != DbgVariableToDbgInstMap.end()) {
|
|
||||||
const MachineInstr *DVInsn = DVI->second;
|
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
if (DVInsn->getNumOperands() == 3) {
|
if (DVInsn->getNumOperands() == 3) {
|
||||||
if (DVInsn->getOperand(0).isReg()) {
|
if (DVInsn->getOperand(0).isReg()) {
|
||||||
@@ -467,17 +464,17 @@ DIE *DwarfDebug::constructVariableDIE(DbgVariable *DV, LexicalScope *Scope) {
|
|||||||
}
|
}
|
||||||
DV->setDIE(VariableDie);
|
DV->setDIE(VariableDie);
|
||||||
return VariableDie;
|
return VariableDie;
|
||||||
}
|
} else {
|
||||||
|
// .. else use frame index.
|
||||||
// .. else use frame index, if available.
|
int FI = DV->getFrameIndex();
|
||||||
int FI = 0;
|
if (FI != ~0U) {
|
||||||
if (findVariableFrameIndex(DV, &FI)) {
|
unsigned FrameReg = 0;
|
||||||
unsigned FrameReg = 0;
|
const TargetFrameLowering *TFI = Asm->TM.getFrameLowering();
|
||||||
const TargetFrameLowering *TFI = Asm->TM.getFrameLowering();
|
int Offset =
|
||||||
int Offset =
|
TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
|
||||||
TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
|
MachineLocation Location(FrameReg, Offset);
|
||||||
MachineLocation Location(FrameReg, Offset);
|
VariableCU->addVariableAddress(DV, VariableDie, Location);
|
||||||
VariableCU->addVariableAddress(DV, VariableDie, Location);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DV->setDIE(VariableDie);
|
DV->setDIE(VariableDie);
|
||||||
@@ -953,11 +950,11 @@ DwarfDebug::collectVariableInfoFromMMITable(const MachineFunction *MF,
|
|||||||
|
|
||||||
DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.second);
|
DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.second);
|
||||||
DbgVariable *RegVar = new DbgVariable(DV, AbsDbgVariable);
|
DbgVariable *RegVar = new DbgVariable(DV, AbsDbgVariable);
|
||||||
recordVariableFrameIndex(RegVar, VP.first);
|
RegVar->setFrameIndex(VP.first);
|
||||||
if (!addCurrentFnArgument(MF, RegVar, Scope))
|
if (!addCurrentFnArgument(MF, RegVar, Scope))
|
||||||
addScopeVariable(Scope, RegVar);
|
addScopeVariable(Scope, RegVar);
|
||||||
if (AbsDbgVariable)
|
if (AbsDbgVariable)
|
||||||
recordVariableFrameIndex(AbsDbgVariable, VP.first);
|
AbsDbgVariable->setFrameIndex(VP.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1046,12 +1043,12 @@ DwarfDebug::collectVariableInfo(const MachineFunction *MF,
|
|||||||
if (!addCurrentFnArgument(MF, RegVar, Scope))
|
if (!addCurrentFnArgument(MF, RegVar, Scope))
|
||||||
addScopeVariable(Scope, RegVar);
|
addScopeVariable(Scope, RegVar);
|
||||||
if (AbsVar)
|
if (AbsVar)
|
||||||
DbgVariableToDbgInstMap[AbsVar] = MInsn;
|
AbsVar->setMInsn(MInsn);
|
||||||
|
|
||||||
// Simple ranges that are fully coalesced.
|
// Simple ranges that are fully coalesced.
|
||||||
if (History.size() <= 1 || (History.size() == 2 &&
|
if (History.size() <= 1 || (History.size() == 2 &&
|
||||||
MInsn->isIdenticalTo(History.back()))) {
|
MInsn->isIdenticalTo(History.back()))) {
|
||||||
DbgVariableToDbgInstMap[RegVar] = MInsn;
|
RegVar->setMInsn(MInsn);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1471,8 +1468,6 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
|
|||||||
DeleteContainerPointers(I->second);
|
DeleteContainerPointers(I->second);
|
||||||
ScopeVariables.clear();
|
ScopeVariables.clear();
|
||||||
DeleteContainerPointers(CurrentFnArguments);
|
DeleteContainerPointers(CurrentFnArguments);
|
||||||
DbgVariableToFrameIndexMap.clear();
|
|
||||||
DbgVariableToDbgInstMap.clear();
|
|
||||||
UserVariables.clear();
|
UserVariables.clear();
|
||||||
DbgValues.clear();
|
DbgValues.clear();
|
||||||
AbstractVariables.clear();
|
AbstractVariables.clear();
|
||||||
@@ -1481,24 +1476,6 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
|
|||||||
PrevLabel = NULL;
|
PrevLabel = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// recordVariableFrameIndex - Record a variable's index.
|
|
||||||
void DwarfDebug::recordVariableFrameIndex(const DbgVariable *V, int Index) {
|
|
||||||
assert (V && "Invalid DbgVariable!");
|
|
||||||
DbgVariableToFrameIndexMap[V] = Index;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// findVariableFrameIndex - Return true if frame index for the variable
|
|
||||||
/// is found. Update FI to hold value of the index.
|
|
||||||
bool DwarfDebug::findVariableFrameIndex(const DbgVariable *V, int *FI) {
|
|
||||||
assert (V && "Invalid DbgVariable!");
|
|
||||||
DenseMap<const DbgVariable *, int>::iterator I =
|
|
||||||
DbgVariableToFrameIndexMap.find(V);
|
|
||||||
if (I == DbgVariableToFrameIndexMap.end())
|
|
||||||
return false;
|
|
||||||
*FI = I->second;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// recordSourceLine - Register a source line with debug info. Returns the
|
/// recordSourceLine - Register a source line with debug info. Returns the
|
||||||
/// unique label that was emitted and which provides correspondence to
|
/// unique label that was emitted and which provides correspondence to
|
||||||
/// the source line list.
|
/// the source line list.
|
||||||
|
@@ -126,10 +126,13 @@ class DbgVariable {
|
|||||||
DIE *TheDIE; // Variable DIE.
|
DIE *TheDIE; // Variable DIE.
|
||||||
unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
|
unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
|
||||||
DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
|
DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
|
||||||
|
const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
|
||||||
|
int FrameIndex;
|
||||||
public:
|
public:
|
||||||
// AbsVar may be NULL.
|
// AbsVar may be NULL.
|
||||||
DbgVariable(DIVariable V, DbgVariable *AV)
|
DbgVariable(DIVariable V, DbgVariable *AV)
|
||||||
: Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV) {}
|
: Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
|
||||||
|
FrameIndex(~0U) {}
|
||||||
|
|
||||||
// Accessors.
|
// Accessors.
|
||||||
DIVariable getVariable() const { return Var; }
|
DIVariable getVariable() const { return Var; }
|
||||||
@@ -139,6 +142,10 @@ public:
|
|||||||
unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
|
unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
|
||||||
StringRef getName() const { return Var.getName(); }
|
StringRef getName() const { return Var.getName(); }
|
||||||
DbgVariable *getAbstractVariable() const { return AbsVar; }
|
DbgVariable *getAbstractVariable() const { return AbsVar; }
|
||||||
|
const MachineInstr *getMInsn() const { return MInsn; }
|
||||||
|
void setMInsn(const MachineInstr *M) { MInsn = M; }
|
||||||
|
int getFrameIndex() const { return FrameIndex; }
|
||||||
|
void setFrameIndex(int FI) { FrameIndex = FI; }
|
||||||
// Translate tag to proper Dwarf tag.
|
// Translate tag to proper Dwarf tag.
|
||||||
unsigned getTag() const {
|
unsigned getTag() const {
|
||||||
if (Var.getTag() == dwarf::DW_TAG_arg_variable)
|
if (Var.getTag() == dwarf::DW_TAG_arg_variable)
|
||||||
@@ -224,14 +231,6 @@ class DwarfDebug {
|
|||||||
/// AbstractVariables - Collection on abstract variables.
|
/// AbstractVariables - Collection on abstract variables.
|
||||||
DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
|
DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
|
||||||
|
|
||||||
/// DbgVariableToFrameIndexMap - Tracks frame index used to find
|
|
||||||
/// variable's value.
|
|
||||||
DenseMap<const DbgVariable *, int> DbgVariableToFrameIndexMap;
|
|
||||||
|
|
||||||
/// DbgVariableToDbgInstMap - Maps DbgVariable to corresponding DBG_VALUE
|
|
||||||
/// machine instruction.
|
|
||||||
DenseMap<const DbgVariable *, const MachineInstr *> DbgVariableToDbgInstMap;
|
|
||||||
|
|
||||||
/// DotDebugLocEntries - Collection of DotDebugLocEntry.
|
/// DotDebugLocEntries - Collection of DotDebugLocEntry.
|
||||||
SmallVector<DotDebugLocEntry, 4> DotDebugLocEntries;
|
SmallVector<DotDebugLocEntry, 4> DotDebugLocEntries;
|
||||||
|
|
||||||
@@ -432,13 +431,6 @@ private:
|
|||||||
void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
|
void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
|
||||||
unsigned Flags);
|
unsigned Flags);
|
||||||
|
|
||||||
/// recordVariableFrameIndex - Record a variable's index.
|
|
||||||
void recordVariableFrameIndex(const DbgVariable *V, int Index);
|
|
||||||
|
|
||||||
/// findVariableFrameIndex - Return true if frame index for the variable
|
|
||||||
/// is found. Update FI to hold value of the index.
|
|
||||||
bool findVariableFrameIndex(const DbgVariable *V, int *FI);
|
|
||||||
|
|
||||||
/// identifyScopeMarkers() - Indentify instructions that are marking
|
/// identifyScopeMarkers() - Indentify instructions that are marking
|
||||||
/// beginning of or end of a scope.
|
/// beginning of or end of a scope.
|
||||||
void identifyScopeMarkers();
|
void identifyScopeMarkers();
|
||||||
|
Reference in New Issue
Block a user