summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2013-01-31 20:05:14 +0000
committerManman Ren <mren@apple.com>2013-01-31 20:05:14 +0000
commit8b15d74434dfde5ea9227b985c2c934f62bf03a7 (patch)
tree8f5b1e57364303e2931e5750a276970de4937d1a /lib/CodeGen
parent108fb3202af6f500073cdbb7be32c25d7a273a2e (diff)
downloadexternal_llvm-8b15d74434dfde5ea9227b985c2c934f62bf03a7.zip
external_llvm-8b15d74434dfde5ea9227b985c2c934f62bf03a7.tar.gz
external_llvm-8b15d74434dfde5ea9227b985c2c934f62bf03a7.tar.bz2
[Dwarf] early exit to avoid creating dangling DIEs
We used to create children DIEs for a scope, then check whether ScopeDIE is null. If ScopeDIE is null, the children DIEs will be dangling. Other DIEs can link to those dangling DIEs, which are not emitted at all, causing dwarf error. The current testing case is 4k lines, from MultiSource/BenchMark/McCat/09-vor. rdar://problem/13071959 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174084 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index f3c7a2a..13ad353 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -540,6 +540,12 @@ DIE *DwarfDebug::constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope) {
if (!Scope || !Scope->getScopeNode())
return NULL;
+ DIScope DS(Scope->getScopeNode());
+ // Early return to avoid creating dangling variable|scope DIEs.
+ if (!Scope->getInlinedAt() && DS.isSubprogram() && Scope->isAbstractScope() &&
+ !TheCU->getDIE(DS))
+ return NULL;
+
SmallVector<DIE *, 8> Children;
DIE *ObjectPointer = NULL;
@@ -565,7 +571,6 @@ DIE *DwarfDebug::constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope) {
for (unsigned j = 0, M = Scopes.size(); j < M; ++j)
if (DIE *Nested = constructScopeDIE(TheCU, Scopes[j]))
Children.push_back(Nested);
- DIScope DS(Scope->getScopeNode());
DIE *ScopeDIE = NULL;
if (Scope->getInlinedAt())
ScopeDIE = constructInlinedScopeDIE(TheCU, Scope);