mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 06:33:21 +00:00
Simplify mapping to variable from its abstract variable info.
When a variable is inlined multiple places, abstract variable keeps name, location, type etc.. info and all other concreate instances of the variable directly refers to abstract variable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137637 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
305e046e53
commit
5a1a67cd3f
@ -383,21 +383,15 @@ DIE *DwarfDebug::constructVariableDIE(DbgVariable *DV, LexicalScope *Scope) {
|
||||
// Define variable debug information entry.
|
||||
DIE *VariableDie = new DIE(Tag);
|
||||
CompileUnit *VariableCU = getCompileUnit(DV->getVariable());
|
||||
DIE *AbsDIE = NULL;
|
||||
DenseMap<const DbgVariable *, const DbgVariable *>::iterator
|
||||
V2AVI = VarToAbstractVarMap.find(DV);
|
||||
if (V2AVI != VarToAbstractVarMap.end())
|
||||
AbsDIE = V2AVI->second->getDIE();
|
||||
|
||||
DbgVariable *AbsVar = DV->getAbstractVariable();
|
||||
DIE *AbsDIE = AbsVar ? AbsVar->getDIE() : NULL;
|
||||
if (AbsDIE)
|
||||
VariableCU->addDIEEntry(VariableDie, dwarf::DW_AT_abstract_origin,
|
||||
dwarf::DW_FORM_ref4, AbsDIE);
|
||||
dwarf::DW_FORM_ref4, AbsDIE);
|
||||
else {
|
||||
VariableCU->addString(VariableDie, dwarf::DW_AT_name, dwarf::DW_FORM_string,
|
||||
Name);
|
||||
VariableCU->addString(VariableDie, dwarf::DW_AT_name,
|
||||
dwarf::DW_FORM_string, Name);
|
||||
VariableCU->addSourceLine(VariableDie, DV->getVariable());
|
||||
|
||||
// Add variable type.
|
||||
VariableCU->addType(VariableDie, DV->getType());
|
||||
}
|
||||
|
||||
@ -812,7 +806,7 @@ void DwarfDebug::endModule() {
|
||||
for (unsigned I = 0; I != E; ++I) {
|
||||
DIVariable DV(NMD->getOperand(I));
|
||||
if (!DV.Verify()) continue;
|
||||
Variables.push_back(DbgVariable(DV));
|
||||
Variables.push_back(DbgVariable(DV, NULL));
|
||||
}
|
||||
|
||||
// Construct subprogram DIE and add variables DIEs.
|
||||
@ -907,7 +901,7 @@ DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &DV,
|
||||
if (!Scope)
|
||||
return NULL;
|
||||
|
||||
AbsDbgVariable = new DbgVariable(Var);
|
||||
AbsDbgVariable = new DbgVariable(Var, NULL);
|
||||
addScopeVariable(Scope, AbsDbgVariable);
|
||||
AbstractVariables[Var] = AbsDbgVariable;
|
||||
return AbsDbgVariable;
|
||||
@ -958,14 +952,12 @@ DwarfDebug::collectVariableInfoFromMMITable(const MachineFunction *MF,
|
||||
continue;
|
||||
|
||||
DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.second);
|
||||
DbgVariable *RegVar = new DbgVariable(DV);
|
||||
DbgVariable *RegVar = new DbgVariable(DV, AbsDbgVariable);
|
||||
recordVariableFrameIndex(RegVar, VP.first);
|
||||
if (!addCurrentFnArgument(MF, RegVar, Scope))
|
||||
addScopeVariable(Scope, RegVar);
|
||||
if (AbsDbgVariable) {
|
||||
if (AbsDbgVariable)
|
||||
recordVariableFrameIndex(AbsDbgVariable, VP.first);
|
||||
VarToAbstractVarMap[RegVar] = AbsDbgVariable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1049,13 +1041,12 @@ DwarfDebug::collectVariableInfo(const MachineFunction *MF,
|
||||
|
||||
Processed.insert(DV);
|
||||
assert(MInsn->isDebugValue() && "History must begin with debug value");
|
||||
DbgVariable *RegVar = new DbgVariable(DV);
|
||||
DbgVariable *AbsVar = findAbstractVariable(DV, MInsn->getDebugLoc());
|
||||
DbgVariable *RegVar = new DbgVariable(DV, AbsVar);
|
||||
if (!addCurrentFnArgument(MF, RegVar, Scope))
|
||||
addScopeVariable(Scope, RegVar);
|
||||
if (DbgVariable *AbsVar = findAbstractVariable(DV, MInsn->getDebugLoc())) {
|
||||
if (AbsVar)
|
||||
DbgVariableToDbgInstMap[AbsVar] = MInsn;
|
||||
VarToAbstractVarMap[RegVar] = AbsVar;
|
||||
}
|
||||
|
||||
// Simple ranges that are fully coalesced.
|
||||
if (History.size() <= 1 || (History.size() == 2 &&
|
||||
@ -1113,7 +1104,7 @@ DwarfDebug::collectVariableInfo(const MachineFunction *MF,
|
||||
if (!DV || !Processed.insert(DV))
|
||||
continue;
|
||||
if (LexicalScope *Scope = LScopes.findLexicalScope(DV.getContext()))
|
||||
addScopeVariable(Scope, new DbgVariable(DV));
|
||||
addScopeVariable(Scope, new DbgVariable(DV, NULL));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1455,7 +1446,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
|
||||
if (!DV || !ProcessedVars.insert(DV))
|
||||
continue;
|
||||
if (LexicalScope *Scope = LScopes.findAbstractScope(DV.getContext()))
|
||||
addScopeVariable(Scope, new DbgVariable(DV));
|
||||
addScopeVariable(Scope, new DbgVariable(DV, NULL));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1481,7 +1472,6 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
|
||||
ScopeVariables.clear();
|
||||
DeleteContainerPointers(CurrentFnArguments);
|
||||
DbgVariableToFrameIndexMap.clear();
|
||||
VarToAbstractVarMap.clear();
|
||||
DbgVariableToDbgInstMap.clear();
|
||||
UserVariables.clear();
|
||||
DbgValues.clear();
|
||||
|
@ -125,9 +125,11 @@ class DbgVariable {
|
||||
DIVariable Var; // Variable Descriptor.
|
||||
DIE *TheDIE; // Variable DIE.
|
||||
unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
|
||||
DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
|
||||
public:
|
||||
// AbsVar may be NULL.
|
||||
DbgVariable(DIVariable V) : Var(V), TheDIE(0), DotDebugLocOffset(~0U) {}
|
||||
DbgVariable(DIVariable V, DbgVariable *AV)
|
||||
: Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV) {}
|
||||
|
||||
// Accessors.
|
||||
DIVariable getVariable() const { return Var; }
|
||||
@ -136,6 +138,7 @@ public:
|
||||
void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
|
||||
unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
|
||||
StringRef getName() const { return Var.getName(); }
|
||||
DbgVariable *getAbstractVariable() const { return AbsVar; }
|
||||
// Translate tag to proper Dwarf tag.
|
||||
unsigned getTag() const {
|
||||
if (Var.getTag() == dwarf::DW_TAG_arg_variable)
|
||||
@ -236,10 +239,6 @@ class DwarfDebug {
|
||||
/// idetifies corresponding .debug_loc entry offset.
|
||||
SmallPtrSet<const DIE *, 4> UseDotDebugLocEntry;
|
||||
|
||||
/// VarToAbstractVarMap - Maps DbgVariable with corresponding Abstract
|
||||
/// DbgVariable, if any.
|
||||
DenseMap<const DbgVariable *, const DbgVariable *> VarToAbstractVarMap;
|
||||
|
||||
/// InliendSubprogramDIEs - Collection of subprgram DIEs that are marked
|
||||
/// (at the end of the module) as DW_AT_inline.
|
||||
SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
|
||||
|
Loading…
x
Reference in New Issue
Block a user