summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-08-31 05:32:06 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-08-31 05:32:06 +0000
commite0e8a3baa05e3d2e8d66789964c793b7ec543cc8 (patch)
treec6d567a68a540451fc2b16bf7e5b8c463fabf6d0 /llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parent1b88632886c26f99721ee2f9ea834bda677abeef (diff)
downloadbcm5719-llvm-e0e8a3baa05e3d2e8d66789964c793b7ec543cc8.tar.gz
bcm5719-llvm-e0e8a3baa05e3d2e8d66789964c793b7ec543cc8.zip
Refactor constructImportedEntityDIE(DwarfUnit, DIImportedEntity) to return a DIE rather than inserting it into a specified context.
First of many steps to improve lexical scope construction (to omit trivial lexical scopes - those without any direct variables). To that end it's easier not to create imported entities directly into the lexical scope node, but to build them, then add them if necessary. llvm-svn: 216838
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 860c7ca9245..1eb8af938a3 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -688,22 +688,23 @@ void DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit &TheCU,
DIImportedEntity Module(N);
assert(Module.Verify());
if (DIE *D = TheCU.getOrCreateContextDIE(Module.getContext()))
- constructImportedEntityDIE(TheCU, Module, *D);
+ D->addChild(constructImportedEntityDIE(TheCU, Module));
}
void DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit &TheCU,
const MDNode *N, DIE &Context) {
DIImportedEntity Module(N);
assert(Module.Verify());
- return constructImportedEntityDIE(TheCU, Module, Context);
+ Context.addChild(constructImportedEntityDIE(TheCU, Module));
}
-void DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit &TheCU,
- const DIImportedEntity &Module,
- DIE &Context) {
+std::unique_ptr<DIE>
+DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit &TheCU,
+ const DIImportedEntity &Module) {
assert(Module.Verify() &&
"Use one of the MDNode * overloads to handle invalid metadata");
- DIE &IMDie = TheCU.createAndAddDIE(Module.getTag(), Context, Module);
+ std::unique_ptr<DIE> IMDie = make_unique<DIE>((dwarf::Tag)Module.getTag());
+ TheCU.insertDIE(Module, IMDie.get());
DIE *EntityDie;
DIDescriptor Entity = resolve(Module.getEntity());
if (Entity.isNameSpace())
@@ -714,13 +715,16 @@ void DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit &TheCU,
EntityDie = TheCU.getOrCreateTypeDIE(DIType(Entity));
else
EntityDie = TheCU.getDIE(Entity);
- TheCU.addSourceLine(IMDie, Module.getLineNumber(),
+ assert(EntityDie);
+ TheCU.addSourceLine(*IMDie, Module.getLineNumber(),
Module.getContext().getFilename(),
Module.getContext().getDirectory());
- TheCU.addDIEEntry(IMDie, dwarf::DW_AT_import, *EntityDie);
+ TheCU.addDIEEntry(*IMDie, dwarf::DW_AT_import, *EntityDie);
StringRef Name = Module.getName();
if (!Name.empty())
- TheCU.addString(IMDie, dwarf::DW_AT_name, Name);
+ TheCU.addString(*IMDie, dwarf::DW_AT_name, Name);
+
+ return IMDie;
}
// Emit all Dwarf sections that should come prior to the content. Create
OpenPOWER on IntegriCloud