summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2013-10-29 05:49:41 +0000
committerManman Ren <manman.ren@gmail.com>2013-10-29 05:49:41 +0000
commitf6b936bc062e7490cfe956d58d47ba92b46e830f (patch)
treec8206c7550195f3ee9eed8057d98059eda1fbec2 /llvm/lib
parentb1ffd99b6a262f674c4cf8ca81205f39baed6765 (diff)
downloadbcm5719-llvm-f6b936bc062e7490cfe956d58d47ba92b46e830f.tar.gz
bcm5719-llvm-f6b936bc062e7490cfe956d58d47ba92b46e830f.zip
Debug Info: instead of calling addToContextOwner which constructs the context
after the DIE creation, we construct the context first. This touches creation of namespaces and global variables. The purpose is to handle all DIE creations similarly: constructs the context first, then creates the DIE and immediately adds the DIE to its parent. We use createAndAddDIE to wrap around "new DIE(". llvm-svn: 193589
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 8528ab7edf5..6c36cd28f50 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1327,11 +1327,19 @@ CompileUnit::constructTemplateValueParameterDIE(DIE &Buffer,
/// getOrCreateNameSpace - Create a DIE for DINameSpace.
DIE *CompileUnit::getOrCreateNameSpace(DINameSpace NS) {
+ // Construct the context before querying for the existence of the DIE in case
+ // such construction creates the DIE.
+ DIE *ContextDIE = getOrCreateContextDIE(NS.getContext());
+ if (!ContextDIE)
+ // If the context is null, DIE should belong to the CU we call construct
+ // function on.
+ ContextDIE = CUDie.get();
+
DIE *NDie = getDIE(NS);
if (NDie)
return NDie;
- NDie = new DIE(dwarf::DW_TAG_namespace);
- insertDIE(NS, NDie);
+ NDie = createAndAddDIE(dwarf::DW_TAG_namespace, *ContextDIE, NS);
+
if (!NS.getName().empty()) {
addString(NDie, dwarf::DW_AT_name, NS.getName());
addAccelNamespace(NS.getName(), NDie);
@@ -1339,7 +1347,6 @@ DIE *CompileUnit::getOrCreateNameSpace(DINameSpace NS) {
} else
addAccelNamespace("(anonymous namespace)", NDie);
addSourceLine(NDie, NS);
- addToContextOwner(NDie, NS.getContext());
return NDie;
}
@@ -1506,9 +1513,14 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) {
// If this is not a static data member definition, create the variable
// DIE and add the initial set of attributes to it.
if (!VariableDIE) {
- VariableDIE = new DIE(GV.getTag());
+ // Construct the context before querying for the existence of the DIE in
+ // case such construction creates the DIE.
+ DIE *ContextDIE = getOrCreateContextDIE(GVContext);
+ if (!ContextDIE)
+ ContextDIE = CUDie.get();
+
// Add to map.
- insertDIE(N, VariableDIE);
+ VariableDIE = createAndAddDIE(GV.getTag(), *ContextDIE, N);
// Add name and type.
addString(VariableDIE, dwarf::DW_AT_name, GV.getDisplayName());
@@ -1520,8 +1532,6 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) {
// Add line number info.
addSourceLine(VariableDIE, GV);
- // Add to context owner.
- addToContextOwner(VariableDIE, GVContext);
}
// Add location.
OpenPOWER on IntegriCloud