One instruction may start (or end) multiple lexical scopes.

There is no need to remember labels identifying regions marked by such instructions in each scope.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100781 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2010-04-08 16:50:29 +00:00
parent fcf0f082f4
commit 1c246358a0
2 changed files with 28 additions and 58 deletions

View File

@ -192,8 +192,6 @@ class DbgScope {
// Location at which this scope is inlined.
AssertingVH<MDNode> InlinedAtLocation;
bool AbstractScope; // Abstract Scope
MCSymbol *StartLabel; // Label ID of the beginning of scope.
MCSymbol *EndLabel; // Label ID of the end of scope.
const MachineInstr *LastInsn; // Last instruction of this scope.
const MachineInstr *FirstInsn; // First instruction of this scope.
// Scopes defined in scope. Contents not owned.
@ -206,7 +204,6 @@ class DbgScope {
public:
DbgScope(DbgScope *P, DIDescriptor D, MDNode *I = 0)
: Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(false),
StartLabel(0), EndLabel(0),
LastInsn(0), FirstInsn(0), IndentLevel(0) {}
virtual ~DbgScope();
@ -216,12 +213,8 @@ public:
DIDescriptor getDesc() const { return Desc; }
MDNode *getInlinedAt() const { return InlinedAtLocation; }
MDNode *getScopeNode() const { return Desc.getNode(); }
MCSymbol *getStartLabel() const { return StartLabel; }
MCSymbol *getEndLabel() const { return EndLabel; }
const SmallVector<DbgScope *, 4> &getScopes() { return Scopes; }
const SmallVector<DbgVariable *, 8> &getVariables() { return Variables; }
void setStartLabel(MCSymbol *S) { StartLabel = S; }
void setEndLabel(MCSymbol *E) { EndLabel = E; }
void setLastInsn(const MachineInstr *MI) { LastInsn = MI; }
const MachineInstr *getLastInsn() { return LastInsn; }
void setFirstInsn(const MachineInstr *MI) { FirstInsn = MI; }
@ -287,7 +280,6 @@ void DbgScope::dump() const {
err.indent(IndentLevel);
MDNode *N = Desc.getNode();
N->dump();
err << " [" << StartLabel << ", " << EndLabel << "]\n";
if (AbstractScope)
err << "Abstract Scope\n";
@ -1406,8 +1398,9 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(MDNode *SPNode) {
/// constructLexicalScope - Construct new DW_TAG_lexical_block
/// for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels.
DIE *DwarfDebug::constructLexicalScopeDIE(DbgScope *Scope) {
MCSymbol *Start = Scope->getStartLabel();
MCSymbol *End = Scope->getEndLabel();
MCSymbol *Start = InsnBeforeLabelMap.lookup(Scope->getFirstInsn());
MCSymbol *End = InsnAfterLabelMap.lookup(Scope->getLastInsn());
if (Start == 0 || End == 0) return 0;
assert(Start->isDefined() && "Invalid starting label for an inlined scope!");
@ -1430,8 +1423,8 @@ DIE *DwarfDebug::constructLexicalScopeDIE(DbgScope *Scope) {
/// a function. Construct DIE to represent this concrete inlined copy
/// of the function.
DIE *DwarfDebug::constructInlinedScopeDIE(DbgScope *Scope) {
MCSymbol *StartLabel = Scope->getStartLabel();
MCSymbol *EndLabel = Scope->getEndLabel();
MCSymbol *StartLabel = InsnBeforeLabelMap.lookup(Scope->getFirstInsn());
MCSymbol *EndLabel = InsnAfterLabelMap.lookup(Scope->getLastInsn());
if (StartLabel == 0 || EndLabel == 0) return 0;
assert(StartLabel->isDefined() &&
@ -2137,15 +2130,9 @@ void DwarfDebug::beginScope(const MachineInstr *MI) {
MCSymbol *Label = recordSourceLine(DL.getLine(), DL.getCol(), Scope);
PrevInstLoc = DL;
// update DbgScope if this instruction starts a new scope.
InsnToDbgScopeMapTy::iterator I = DbgScopeBeginMap.find(MI);
if (I == DbgScopeBeginMap.end())
return;
ScopeVector &SD = I->second;
for (ScopeVector::iterator SDI = SD.begin(), SDE = SD.end();
SDI != SDE; ++SDI)
(*SDI)->setStartLabel(Label);
// If this instruction begins a scope then note down corresponding label.
if (InsnsBeginScopeSet.count(MI) != 0)
InsnBeforeLabelMap[MI] = Label;
}
/// endScope - Process end of a scope.
@ -2159,19 +2146,12 @@ void DwarfDebug::endScope(const MachineInstr *MI) {
if (DL.isUnknown())
return;
// Emit a label and update DbgScope if this instruction ends a scope.
InsnToDbgScopeMapTy::iterator I = DbgScopeEndMap.find(MI);
if (I == DbgScopeEndMap.end())
return;
MCSymbol *Label = MMI->getContext().CreateTempSymbol();
Asm->OutStreamer.EmitLabel(Label);
SmallVector<DbgScope*, 2> &SD = I->second;
for (SmallVector<DbgScope *, 2>::iterator SDI = SD.begin(), SDE = SD.end();
SDI != SDE; ++SDI)
(*SDI)->setEndLabel(Label);
return;
if (InsnsEndScopeSet.count(MI) != 0) {
// Emit a label if this instruction ends a scope.
MCSymbol *Label = MMI->getContext().CreateTempSymbol();
Asm->OutStreamer.EmitLabel(Label);
InsnAfterLabelMap[MI] = Label;
}
}
/// createDbgScope - Create DbgScope for the scope.
@ -2288,22 +2268,11 @@ void DwarfDebug::populateDbgScopeInverseMaps() {
if (S->isAbstractScope())
continue;
const MachineInstr *MI = S->getFirstInsn();
assert(MI && "DbgScope does not have first instruction!");
assert(S->getFirstInsn() && "DbgScope does not have first instruction!");
InsnsBeginScopeSet.insert(S->getFirstInsn());
InsnToDbgScopeMapTy::iterator IDI = DbgScopeBeginMap.find(MI);
if (IDI != DbgScopeBeginMap.end())
IDI->second.push_back(S);
else
DbgScopeBeginMap[MI].push_back(S);
MI = S->getLastInsn();
assert(MI && "DbgScope does not have last instruction!");
IDI = DbgScopeEndMap.find(MI);
if (IDI != DbgScopeEndMap.end())
IDI->second.push_back(S);
else
DbgScopeEndMap[MI].push_back(S);
assert(S->getLastInsn() && "DbgScope does not have last instruction!");
InsnsEndScopeSet.insert(S->getLastInsn());
}
}
@ -2374,8 +2343,6 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
// Clear debug info
CurrentFnDbgScope = NULL;
DeleteContainerSeconds(DbgScopeMap);
DbgScopeBeginMap.clear();
DbgScopeEndMap.clear();
DbgValueStartMap.clear();
ConcreteScopes.clear();
DeleteContainerSeconds(AbstractScopes);

View File

@ -179,14 +179,9 @@ class DwarfDebug {
SmallPtrSet<DIE *, 4> AbstractSubprogramDIEs;
typedef SmallVector<DbgScope *, 2> ScopeVector;
typedef DenseMap<const MachineInstr *, ScopeVector>
InsnToDbgScopeMapTy;
/// DbgScopeBeginMap - Maps instruction with a list of DbgScopes it starts.
InsnToDbgScopeMapTy DbgScopeBeginMap;
/// DbgScopeEndMap - Maps instruction with a list DbgScopes it ends.
InsnToDbgScopeMapTy DbgScopeEndMap;
SmallPtrSet<const MachineInstr *, 8> InsnsBeginScopeSet;
SmallPtrSet<const MachineInstr *, 8> InsnsEndScopeSet;
/// InlineInfo - Keep track of inlined functions and their location. This
/// information is used to populate debug_inlined section.
@ -194,6 +189,14 @@ class DwarfDebug {
DenseMap<MDNode*, SmallVector<InlineInfoLabels, 4> > InlineInfo;
SmallVector<MDNode *, 4> InlinedSPNodes;
/// InsnBeforeLabelMap - Maps instruction with label emitted before
/// instruction.
DenseMap<const MachineInstr *, MCSymbol *> InsnBeforeLabelMap;
/// InsnAfterLabelMap - Maps instruction with label emitted after
/// instruction.
DenseMap<const MachineInstr *, MCSymbol *> InsnAfterLabelMap;
/// CompileUnitOffsets - A vector of the offsets of the compile units. This is
/// used when calculating the "origin" of a concrete instance of an inlined
/// function.