aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/AsmPrinter
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
commit6b713800ff03fdbb1d770d1e00af0e76041f3c03 (patch)
tree462a07a6ac3170b391694ad292197834134f6ed2 /lib/CodeGen/AsmPrinter
parentb4e591a4a68649a286cd1b08312566db17758158 (diff)
downloadexternal_llvm-6b713800ff03fdbb1d770d1e00af0e76041f3c03.zip
external_llvm-6b713800ff03fdbb1d770d1e00af0e76041f3c03.tar.gz
external_llvm-6b713800ff03fdbb1d770d1e00af0e76041f3c03.tar.bz2
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(". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193589 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 8528ab7..6c36cd2 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/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.