From: Manman Ren Date: Thu, 31 Jan 2013 20:05:14 +0000 (+0000) Subject: [Dwarf] early exit to avoid creating dangling DIEs X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8b15d74434dfde5ea9227b985c2c934f62bf03a7;p=oota-llvm.git [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 --- diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index f3c7a2afb39..13ad353be24 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 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);