diff options
| author | Devang Patel <dpatel@apple.com> | 2009-10-05 23:40:42 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2009-10-05 23:40:42 +0000 |
| commit | 4c420eca417510e2c4b3a5d34e9a4541b7368810 (patch) | |
| tree | 87beeeea44e6a109f1c4da8079f487889afcf9a1 /llvm/lib/CodeGen | |
| parent | 4144a821549f8b17bcf2a8aaab15f1497fb9e840 (diff) | |
| download | bcm5719-llvm-4c420eca417510e2c4b3a5d34e9a4541b7368810.tar.gz bcm5719-llvm-4c420eca417510e2c4b3a5d34e9a4541b7368810.zip | |
Adjust context for the global variables that are not at file scope, e.g.
void foo() { static int bar = 42; }
Here, foo's DIE is parent of bar's DIE.
llvm-svn: 83344
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 20 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 4 |
2 files changed, 22 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 7614c481c91..2aff2f2593b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1477,6 +1477,17 @@ void DwarfDebug::ConstructFunctionDbgScope(DbgScope *RootScope, } ConstructDbgScope(RootScope, 0, 0, SPDie, ModuleCU); + // If there are global variables at this scope then add their dies. + for (SmallVector<WeakVH, 4>::iterator SGI = ScopedGVs.begin(), + SGE = ScopedGVs.end(); SGI != SGE; ++SGI) { + MDNode *N = dyn_cast_or_null<MDNode>(*SGI); + if (!N) continue; + DIGlobalVariable GV(N); + if (GV.getContext().getNode() == RootScope->getDesc().getNode()) { + DIE *ScopedGVDie = CreateGlobalVariableDIE(ModuleCU, GV); + SPDie->AddChild(ScopedGVDie); + } + } } /// ConstructDefaultDbgScope - Construct a default scope for the subprogram. @@ -1667,8 +1678,13 @@ void DwarfDebug::BeginModule(Module *M, MachineModuleInfo *mmi) { // Create DIEs for each of the externally visible global variables. for (DebugInfoFinder::iterator I = DbgFinder.global_variable_begin(), - E = DbgFinder.global_variable_end(); I != E; ++I) - ConstructGlobalVariableDIE(*I); + E = DbgFinder.global_variable_end(); I != E; ++I) { + DIGlobalVariable GV(*I); + if (GV.getContext().getNode() != GV.getCompileUnit().getNode()) + ScopedGVs.push_back(*I); + else + ConstructGlobalVariableDIE(*I); + } // Create DIEs for each of the externally visible subprograms. for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(), diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index f671ae3403b..2947d76d703 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -141,6 +141,10 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf { /// DbgScopeMap - Tracks the scopes in the current function. DenseMap<MDNode *, DbgScope *> DbgScopeMap; + /// ScopedGVs - Tracks global variables that are not at file scope. + /// For example void f() { static int b = 42; } + SmallVector<WeakVH, 4> ScopedGVs; + typedef DenseMap<const MachineInstr *, SmallVector<DbgScope *, 2> > InsnToDbgScopeMapTy; |

