diff options
author | Devang Patel <dpatel@apple.com> | 2010-06-25 22:07:34 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-06-25 22:07:34 +0000 |
commit | 78e127d81b58de8663f8328dc1cdbd1f31a759fd (patch) | |
tree | 300966b31c99d145b19948659ef1cc90e29af5c5 /lib/CodeGen | |
parent | 135ec50ce26b4bb9aee305f5e861d2348969aa31 (diff) | |
download | external_llvm-78e127d81b58de8663f8328dc1cdbd1f31a759fd.zip external_llvm-78e127d81b58de8663f8328dc1cdbd1f31a759fd.tar.gz external_llvm-78e127d81b58de8663f8328dc1cdbd1f31a759fd.tar.bz2 |
Collect debug info for optimized variables of inlined functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106895 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 33 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.h | 3 |
2 files changed, 30 insertions, 6 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index abd42dc..46582da 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2159,8 +2159,9 @@ static bool isDbgValueInDefinedReg(const MachineInstr *MI) { } /// collectVariableInfo - Populate DbgScope entries with variables' info. -void DwarfDebug::collectVariableInfo(const MachineFunction *MF) { - SmallPtrSet<const MDNode *, 16> Processed; +void +DwarfDebug::collectVariableInfo(const MachineFunction *MF, + SmallPtrSet<const MDNode *, 16> &Processed) { /// collection info from MMI table. collectVariableInfoFromMMITable(MF, Processed); @@ -2367,6 +2368,7 @@ DbgScope *DwarfDebug::getOrCreateDbgScope(const MDNode *Scope, const MDNode *Inl return WScope; } + getOrCreateAbstractScope(Scope); DbgScope *WScope = DbgScopeMap.lookup(InlinedAt); if (WScope) return WScope; @@ -2380,7 +2382,6 @@ DbgScope *DwarfDebug::getOrCreateDbgScope(const MDNode *Scope, const MDNode *Inl Parent->addScope(WScope); ConcreteScopes[InlinedAt] = WScope; - getOrCreateAbstractScope(Scope); return WScope; } @@ -2693,7 +2694,8 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { // Assumes in correct section after the entry point. Asm->OutStreamer.EmitLabel(FunctionEndSym); - collectVariableInfo(MF); + SmallPtrSet<const MDNode *, 16> ProcessedVars; + collectVariableInfo(MF, ProcessedVars); // Get function line info. if (!Lines.empty()) { @@ -2708,8 +2710,29 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { // Construct abstract scopes. for (SmallVector<DbgScope *, 4>::iterator AI = AbstractScopesList.begin(), - AE = AbstractScopesList.end(); AI != AE; ++AI) + AE = AbstractScopesList.end(); AI != AE; ++AI) { constructScopeDIE(*AI); + DISubprogram SP((*AI)->getScopeNode()); + if (SP.Verify()) { + // Collect info for variables that were optimized out. + StringRef FName = SP.getLinkageName(); + if (FName.empty()) + FName = SP.getName(); + const Module *M = MF->getFunction()->getParent(); + if (NamedMDNode *NMD = + M->getNamedMetadata(Twine("llvm.dbg.lv.", + getRealLinkageName(FName)))) { + for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) { + DIVariable DV(cast_or_null<MDNode>(NMD->getOperand(i))); + if (!DV || !ProcessedVars.insert(DV)) + continue; + DbgScope *Scope = DbgScopeMap.lookup(DV.getContext()); + if (Scope) + Scope->addVariable(new DbgVariable(DV)); + } + } + } + } DIE *CurFnDIE = constructScopeDIE(CurrentFnDbgScope); diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index a9cb8e8..c4c765c 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -590,7 +590,8 @@ private: bool extractScopeInformation(); /// collectVariableInfo - Populate DbgScope entries with variables' info. - void collectVariableInfo(const MachineFunction *); + void collectVariableInfo(const MachineFunction *, + SmallPtrSet<const MDNode *, 16> &ProcessedVars); /// collectVariableInfoFromMMITable - Collect variable information from /// side table maintained by MMI. |