<div dir="ltr">This patch is probably responsible for <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/11281">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/11281</a></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Mar 24, 2016 at 6:35 AM Amjad Aboud via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: aaboud<br>
Date: Thu Mar 24 08:30:16 2016<br>
New Revision: 264280<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264280&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=264280&view=rev</a><br>
Log:<br>
Recommitted r263424 "Supporting all entities declared in lexical scope in LLVM debug info."<br>
After fixing PR26942 (the fix is included in this commit).<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D18350" rel="noreferrer" target="_blank">http://reviews.llvm.org/D18350</a><br>
<br>
Added:<br>
llvm/trunk/test/DebugInfo/X86/PR24008.ll<br>
- copied unchanged from r263436, llvm/trunk/test/DebugInfo/X86/PR24008.ll<br>
llvm/trunk/test/DebugInfo/X86/lexical-block-file.ll<br>
llvm/trunk/test/DebugInfo/X86/lexical-block-inline.ll<br>
- copied unchanged from r263436, llvm/trunk/test/DebugInfo/X86/lexical-block-inline.ll<br>
llvm/trunk/test/DebugInfo/X86/lexical-block.ll<br>
- copied unchanged from r263436, llvm/trunk/test/DebugInfo/X86/lexical-block.ll<br>
llvm/trunk/test/DebugInfo/X86/subprogram-inline.ll<br>
- copied unchanged from r263436, llvm/trunk/test/DebugInfo/X86/subprogram-inline.ll<br>
Modified:<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h<br>
llvm/trunk/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll<br>
llvm/trunk/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll<br>
llvm/trunk/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll<br>
llvm/trunk/test/DebugInfo/Generic/namespace.ll<br>
llvm/trunk/test/DebugInfo/Generic/nodebug.ll<br>
llvm/trunk/test/DebugInfo/Mips/InlinedFnLocalVar.ll<br>
llvm/trunk/test/DebugInfo/X86/InlinedFnLocalVar.ll<br>
llvm/trunk/test/DebugInfo/X86/dbg-file-name.ll<br>
llvm/trunk/test/DebugInfo/X86/debug-dead-local-var.ll<br>
llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Thu Mar 24 08:30:16 2016<br>
@@ -114,10 +114,16 @@ DIE *DwarfCompileUnit::getOrCreateGlobal<br>
<br>
// Construct the context before querying for the existence of the DIE in<br>
// case such construction creates the DIE.<br>
- DIE *ContextDIE = getOrCreateContextDIE(GVContext);<br>
+ // For Local Scope, do not construct context DIE.<br>
+ bool IsLocalScope = GVContext && isa<DILocalScope>(GVContext);<br>
+ DIE *ContextDIE = IsLocalScope ? nullptr : getOrCreateContextDIE(GVContext);<br>
+ assert(ContextDIE || IsLocalScope);<br>
+<br>
+ // Create new global variable and add to map.<br>
+ DIE *VariableDIE = IsLocalScope<br>
+ ? createDIE(GV->getTag(), GV)<br>
+ : &createAndAddDIE(GV->getTag(), *ContextDIE, GV);<br>
<br>
- // Add to map.<br>
- DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV);<br>
DIScope *DeclContext;<br>
if (auto *SDMDecl = GV->getStaticDataMemberDeclaration()) {<br>
DeclContext = resolve(SDMDecl->getScope());<br>
@@ -335,23 +341,15 @@ void DwarfCompileUnit::constructScopeDIE<br>
if (DD->isLexicalScopeDIENull(Scope))<br>
return;<br>
<br>
- unsigned ChildScopeCount;<br>
+ bool HasNonScopeChildren;<br>
<br>
// We create children here when we know the scope DIE is not going to be<br>
// null and the children will be added to the scope DIE.<br>
- createScopeChildrenDIE(Scope, Children, &ChildScopeCount);<br>
-<br>
- // Skip imported directives in gmlt-like data.<br>
- if (!includeMinimalInlineScopes()) {<br>
- // There is no need to emit empty lexical block DIE.<br>
- for (const auto *IE : ImportedEntities[DS])<br>
- Children.push_back(<br>
- constructImportedEntityDIE(cast<DIImportedEntity>(IE)));<br>
- }<br>
+ createScopeChildrenDIE(Scope, Children, &HasNonScopeChildren);<br>
<br>
// If there are only other scopes as children, put them directly in the<br>
// parent instead, as this scope would serve no purpose.<br>
- if (Children.size() == ChildScopeCount) {<br>
+ if (!HasNonScopeChildren) {<br>
FinalChildren.insert(FinalChildren.end(),<br>
std::make_move_iterator(Children.begin()),<br>
std::make_move_iterator(Children.end()));<br>
@@ -366,6 +364,7 @@ void DwarfCompileUnit::constructScopeDIE<br>
ScopeDIE->addChild(std::move(I));<br>
<br>
FinalChildren.push_back(std::move(ScopeDIE));<br>
+ addLocalScopeDieToLexicalScope(Scope, ScopeDIE);<br>
}<br>
<br>
DIE::value_iterator<br>
@@ -558,20 +557,37 @@ DIE *DwarfCompileUnit::constructVariable<br>
<br>
DIE *DwarfCompileUnit::createScopeChildrenDIE(LexicalScope *Scope,<br>
SmallVectorImpl<DIE *> &Children,<br>
- unsigned *ChildScopeCount) {<br>
+ bool *HasNonScopeChildren) {<br>
DIE *ObjectPointer = nullptr;<br>
+ bool HasLocalDclDie = false;<br>
+ auto *DS = Scope->getScopeNode();<br>
<br>
for (DbgVariable *DV : DU->getScopeVariables().lookup(Scope))<br>
Children.push_back(constructVariableDIE(*DV, *Scope, ObjectPointer));<br>
<br>
- unsigned ChildCountWithoutScopes = Children.size();<br>
+ // Skip local declarations in gmlt-like data.<br>
+ if (!includeMinimalInlineScopes()) {<br>
+ for (const auto *DI : LocalDeclNodes[DS]) {<br>
+ DIE *D = nullptr;<br>
+ if (auto *IE = dyn_cast<DIImportedEntity>(DI))<br>
+ D = getOrCreateImportedEntityDIE(IE);<br>
+ else if (auto *GV = dyn_cast<DIGlobalVariable>(DI))<br>
+ D = getOrCreateGlobalVariableDIE(GV);<br>
+ else if (auto *RT = dyn_cast<DIType>(DI))<br>
+ D = getOrCreateTypeDIE(RT);<br>
+ else<br>
+ llvm_unreachable("Unexpected DI node!");<br>
+ addLocalDclDieToLexicalScope(Scope, D);<br>
+ HasLocalDclDie = true;<br>
+ }<br>
+ }<br>
+<br>
+ if (HasNonScopeChildren)<br>
+ *HasNonScopeChildren = !Children.empty() || HasLocalDclDie;<br>
<br>
for (LexicalScope *LS : Scope->getChildren())<br>
constructScopeDIE(LS, Children);<br>
<br>
- if (ChildScopeCount)<br>
- *ChildScopeCount = Children.size() - ChildCountWithoutScopes;<br>
-<br>
return ObjectPointer;<br>
}<br>
<br>
@@ -613,6 +629,8 @@ DIE *DwarfCompileUnit::createAndAddScope<br>
for (auto &I : Children)<br>
ScopeDIE.addChild(std::move(I));<br>
<br>
+ addLocalScopeDieToLexicalScope(Scope, &ScopeDIE);<br>
+<br>
return ObjectPointer;<br>
}<br>
<br>
@@ -649,10 +667,20 @@ void DwarfCompileUnit::constructAbstract<br>
addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);<br>
}<br>
<br>
+DIE *DwarfCompileUnit::getOrCreateImportedEntityDIE(<br>
+ const DIImportedEntity *Module) {<br>
+ if (DIE *Die = getDIE(Module))<br>
+ return Die;<br>
+<br>
+ return constructImportedEntityDIE(Module);<br>
+}<br>
+<br>
DIE *DwarfCompileUnit::constructImportedEntityDIE(<br>
const DIImportedEntity *Module) {<br>
- DIE *IMDie = DIE::get(DIEValueAllocator, (dwarf::Tag)Module->getTag());<br>
- insertDIE(Module, IMDie);<br>
+<br>
+ assert(!getDIE(Module));<br>
+<br>
+ DIE *IMDie = createDIE(Module->getTag(), Module);<br>
DIE *EntityDie;<br>
auto *Entity = resolve(Module->getEntity());<br>
if (auto *NS = dyn_cast<DINamespace>(Entity))<br>
@@ -679,22 +707,46 @@ DIE *DwarfCompileUnit::constructImported<br>
}<br>
<br>
void DwarfCompileUnit::finishSubprogramDefinition(const DISubprogram *SP) {<br>
- DIE *D = getDIE(SP);<br>
- if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) {<br>
- if (D)<br>
+ if (DIE *D = getDIE(SP)) {<br>
+ if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP))<br>
// If this subprogram has an abstract definition, reference that<br>
addDIEEntry(*D, dwarf::DW_AT_abstract_origin, *AbsSPDIE);<br>
- } else {<br>
- if (!D && !includeMinimalInlineScopes())<br>
- // Lazily construct the subprogram if we didn't see either concrete or<br>
- // inlined versions during codegen. (except in -gmlt ^ where we want<br>
- // to omit these entirely)<br>
- D = getOrCreateSubprogramDIE(SP);<br>
- if (D)<br>
+ else<br>
// And attach the attributes<br>
applySubprogramAttributesToDefinition(SP, *D);<br>
}<br>
}<br>
+<br>
+void DwarfCompileUnit::finishLocalScopeDefinitions() {<br>
+ for (const auto &I : getLSDieInfoMap()) {<br>
+ auto LSInfo = I.second;<br>
+ // Attach all local dcl DIEs to abstract local scope if available,<br>
+ // otherwise attach it to concrete local scope.<br>
+ DIE *LBDie =<br>
+ LSInfo.AbstractLSDie ? LSInfo.AbstractLSDie : LSInfo.ConcreteLSDie;<br>
+ assert(LBDie || LSInfo.LocalDclDies.empty());<br>
+ for (auto &D : LSInfo.LocalDclDies)<br>
+ LBDie->addChild(std::move(D));<br>
+<br>
+ if (isa<DISubprogram>(I.first))<br>
+ // For function scope there is nothing else to do.<br>
+ // "abstract_origin" dwarf attribute was added somewhere else.<br>
+ continue;<br>
+<br>
+ if (LSInfo.AbstractLSDie) {<br>
+ // Add "abstract_origin" dwarf attribute to concrete local scope pointing<br>
+ // to the corresponding abstract local scope.<br>
+ if (LSInfo.ConcreteLSDie)<br>
+ addDIEEntry(*LSInfo.ConcreteLSDie, dwarf::DW_AT_abstract_origin,<br>
+ *LSInfo.AbstractLSDie);<br>
+ // Add "abstract_origin" dwarf attribute to inline local scope pointing<br>
+ // to the corresponding abstract local scope.<br>
+ for (auto &L : LSInfo.InlineLSDies)<br>
+ addDIEEntry(*L, dwarf::DW_AT_abstract_origin, *LSInfo.AbstractLSDie);<br>
+ }<br>
+ }<br>
+}<br>
+<br>
void DwarfCompileUnit::collectDeadVariables(const DISubprogram *SP) {<br>
assert(SP && "CU's subprogram list contains a non-subprogram");<br>
assert(SP->isDefinition() &&<br>
@@ -705,7 +757,7 @@ void DwarfCompileUnit::collectDeadVariab<br>
<br>
DIE *SPDIE = DU->getAbstractSPDies().lookup(SP);<br>
if (!SPDIE)<br>
- SPDIE = getDIE(SP);<br>
+ return;<br>
assert(SPDIE);<br>
for (const DILocalVariable *DV : Variables) {<br>
DbgVariable NewVar(DV, /* IA */ nullptr, DD);<br>
@@ -830,6 +882,34 @@ void DwarfCompileUnit::applySubprogramAt<br>
addGlobalName(SP->getName(), SPDie, Context);<br>
}<br>
<br>
+void DwarfCompileUnit::addLocalScopeDieToLexicalScope(LexicalScope *LS,<br>
+ DIE *D) {<br>
+ const DILocalScope *Scope = LS->getScopeNode();<br>
+ assert(!isa<DILexicalBlockFile>(Scope) && "Don't expect Lexical Block File!");<br>
+ auto &LSInfo = getLSDieInfoMap()[Scope];<br>
+ if (LS->isAbstractScope()) {<br>
+ assert(!LSInfo.AbstractLSDie && "Adding abstract LS DIE twice.");<br>
+ LSInfo.AbstractLSDie = D;<br>
+ return;<br>
+ }<br>
+ if (LS->getInlinedAt()) {<br>
+ assert(!LSInfo.InlineLSDies.count(D) && "Adding inline LS DIE twice.");<br>
+ LSInfo.InlineLSDies.insert(D);<br>
+ return;<br>
+ }<br>
+ assert(!LSInfo.ConcreteLSDie && "Adding cocncrete LS DIE twice.");<br>
+ LSInfo.ConcreteLSDie = D;<br>
+ return;<br>
+}<br>
+<br>
+void DwarfCompileUnit::addLocalDclDieToLexicalScope(LexicalScope *LS, DIE *D) {<br>
+ const DILocalScope *Scope = LS->getScopeNode();<br>
+ assert(!isa<DILexicalBlockFile>(Scope) && "Don't expect Lexical Block File!");<br>
+ auto &LSInfo = getLSDieInfoMap()[Scope];<br>
+ LSInfo.LocalDclDies.insert(D);<br>
+ return;<br>
+}<br>
+<br>
bool DwarfCompileUnit::isDwoUnit() const {<br>
return DD->useSplitDwarf() && Skeleton;<br>
}<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Thu Mar 24 08:30:16 2016<br>
@@ -15,6 +15,7 @@<br>
#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H<br>
<br>
#include "DwarfUnit.h"<br>
+#include "llvm/ADT/SetVector.h"<br>
#include "llvm/ADT/StringRef.h"<br>
#include "llvm/IR/DebugInfo.h"<br>
#include "llvm/Support/Dwarf.h"<br>
@@ -48,11 +49,10 @@ class DwarfCompileUnit : public DwarfUni<br>
/// The start of the unit macro info within macro section.<br>
MCSymbol *MacroLabelBegin;<br>
<br>
- typedef llvm::SmallVector<const MDNode *, 8> ImportedEntityList;<br>
- typedef llvm::DenseMap<const MDNode *, ImportedEntityList><br>
- ImportedEntityMap;<br>
+ typedef llvm::SmallVector<const MDNode *, 8> LocalDeclNodeList;<br>
+ typedef llvm::DenseMap<const MDNode *, LocalDeclNodeList> LocalScopesMap;<br>
<br>
- ImportedEntityMap ImportedEntities;<br>
+ LocalScopesMap LocalDeclNodes;<br>
<br>
/// GlobalNames - A map of globally visible named entities for this unit.<br>
StringMap<const DIE *> GlobalNames;<br>
@@ -71,6 +71,15 @@ class DwarfCompileUnit : public DwarfUni<br>
// ranges/locs.<br>
const MCSymbol *BaseAddress;<br>
<br>
+ struct LocalScopeDieInfo {<br>
+ DIE *ConcreteLSDie = nullptr;<br>
+ DIE *AbstractLSDie = nullptr;<br>
+ SetVector<DIE *> InlineLSDies;<br>
+ SetVector<DIE *> LocalDclDies;<br>
+ };<br>
+ // Collection of local scope DIE info.<br>
+ DenseMap<const MDNode *, LocalScopeDieInfo> LocalScopeDieInfoMap;<br>
+<br>
/// \brief Construct a DIE for the given DbgVariable without initializing the<br>
/// DbgVariable's DIE reference.<br>
DIE *constructVariableDIEImpl(const DbgVariable &DV, bool Abstract);<br>
@@ -117,8 +126,16 @@ public:<br>
<br>
unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;<br>
<br>
- void addImportedEntity(const DIImportedEntity* IE) {<br>
- ImportedEntities[IE->getScope()].push_back(IE);<br>
+ void addLocalDeclNode(const DINode *DI, DILocalScope *Scope) {<br>
+ // LocalDeclNodes maps local declaration DIEs to their parent DILocalScope.<br>
+ // These local declaration entities will be processed when processing the<br>
+ // lexical scopes collected by LexicalScopes component.<br>
+ // DILexicalBlockFile is skipped by LexicalScopes and it collect its parent,<br>
+ // which is of a DILexicalBlock. Thus, LocalDeclNodes must not map to<br>
+ // DILexicalBlockFile but to its parent DILexicalBlock.<br>
+ if (auto *File = dyn_cast<DILexicalBlockFile>(Scope))<br>
+ Scope = File->getScope();<br>
+ LocalDeclNodes[Scope].push_back(DI);<br>
}<br>
<br>
/// addRange - Add an address range to the list of ranges for this unit.<br>
@@ -166,7 +183,7 @@ public:<br>
/// A helper function to create children of a Scope DIE.<br>
DIE *createScopeChildrenDIE(LexicalScope *Scope,<br>
SmallVectorImpl<DIE *> &Children,<br>
- unsigned *ChildScopeCount = nullptr);<br>
+ bool *HasNonScopeChildren = nullptr);<br>
<br>
/// \brief Construct a DIE for this subprogram scope.<br>
void constructSubprogramScopeDIE(LexicalScope *Scope);<br>
@@ -175,11 +192,15 @@ public:<br>
<br>
void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);<br>
<br>
+ /// \brief Get or create import_module DIE.<br>
+ DIE *getOrCreateImportedEntityDIE(const DIImportedEntity *Module);<br>
/// \brief Construct import_module DIE.<br>
DIE *constructImportedEntityDIE(const DIImportedEntity *Module);<br>
<br>
void finishSubprogramDefinition(const DISubprogram *SP);<br>
<br>
+ void finishLocalScopeDefinitions();<br>
+<br>
void collectDeadVariables(const DISubprogram *SP);<br>
<br>
/// Set the skeleton unit associated with this unit.<br>
@@ -253,6 +274,15 @@ public:<br>
<br>
void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; }<br>
const MCSymbol *getBaseAddress() const { return BaseAddress; }<br>
+<br>
+ DenseMap<const MDNode *, LocalScopeDieInfo> &getLSDieInfoMap() {<br>
+ return LocalScopeDieInfoMap;<br>
+ }<br>
+<br>
+ /// Add local scope DIE entry to lexical scope info.<br>
+ void addLocalScopeDieToLexicalScope(LexicalScope *LS, DIE *D);<br>
+ /// Add local declaration DIE entry to lexical scope info.<br>
+ void addLocalDclDieToLexicalScope(LexicalScope *LS, DIE *D);<br>
};<br>
<br>
} // end llvm namespace<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Mar 24 08:30:16 2016<br>
@@ -455,6 +455,16 @@ void DwarfDebug::constructAndAddImported<br>
D->addChild(TheCU.constructImportedEntityDIE(N));<br>
}<br>
<br>
+bool DwarfDebug::collectLocalScopedNode(DIScope *S, const DINode *N,<br>
+ DwarfCompileUnit &CU) {<br>
+ if (auto LS = dyn_cast_or_null<DILocalScope>(S)) {<br>
+ getLocalScopes(LS->getSubprogram()).insert(LS);<br>
+ CU.addLocalDeclNode(N, LS);<br>
+ return true;<br>
+ }<br>
+ return false;<br>
+}<br>
+<br>
// Emit all Dwarf sections that should come prior to the content. Create<br>
// global DIEs and emit initial debug info sections. This is invoked by<br>
// the target AsmPrinter.<br>
@@ -474,10 +484,9 @@ void DwarfDebug::beginModule() {<br>
for (MDNode *N : CU_Nodes->operands()) {<br>
auto *CUNode = cast<DICompileUnit>(N);<br>
DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);<br>
- for (auto *IE : CUNode->getImportedEntities())<br>
- CU.addImportedEntity(IE);<br>
for (auto *GV : CUNode->getGlobalVariables())<br>
- CU.getOrCreateGlobalVariableDIE(GV);<br>
+ if (!collectLocalScopedNode(GV->getScope(), GV, CU))<br>
+ CU.getOrCreateGlobalVariableDIE(GV);<br>
for (auto *SP : CUNode->getSubprograms())<br>
SPMap.insert(std::make_pair(SP, &CU));<br>
for (auto *Ty : CUNode->getEnumTypes()) {<br>
@@ -489,14 +498,17 @@ void DwarfDebug::beginModule() {<br>
// The retained types array by design contains pointers to<br>
// MDNodes rather than DIRefs. Unique them here.<br>
DIType *RT = cast<DIType>(resolve(Ty->getRef()));<br>
- if (!RT->isExternalTypeRef())<br>
+ if (RT->isExternalTypeRef())<br>
// There is no point in force-emitting a forward declaration.<br>
+ continue;<br>
+ if (!collectLocalScopedNode(resolve(Ty->getScope()), RT, CU))<br>
CU.getOrCreateTypeDIE(RT);<br>
}<br>
// Emit imported_modules last so that the relevant context is already<br>
// available.<br>
for (auto *IE : CUNode->getImportedEntities())<br>
- constructAndAddImportedEntityDIE(CU, IE);<br>
+ if (!collectLocalScopedNode(IE->getScope(), IE, CU))<br>
+ constructAndAddImportedEntityDIE(CU, IE);<br>
}<br>
<br>
// Tell MMI that we have debug info.<br>
@@ -529,6 +541,11 @@ void DwarfDebug::finishSubprogramDefinit<br>
});<br>
}<br>
<br>
+void DwarfDebug::finishLocalScopeDefinitions() {<br>
+ for (const auto &I : CUMap)<br>
+ I.second->finishLocalScopeDefinitions();<br>
+}<br>
+<br>
// Collect info for variables that were optimized out.<br>
void DwarfDebug::collectDeadVariables() {<br>
const Module *M = MMI->getModule();<br>
@@ -554,6 +571,8 @@ void DwarfDebug::finalizeModuleInfo() {<br>
<br>
finishSubprogramDefinitions();<br>
<br>
+ finishLocalScopeDefinitions();<br>
+<br>
finishVariableDefinitions();<br>
<br>
// Collect info for variables that were optimized out.<br>
@@ -1164,6 +1183,9 @@ void DwarfDebug::endFunction(const Machi<br>
assert(LScopes.getAbstractScopesList().size() == NumAbstractScopes<br>
&& "ensureAbstractVariableIsCreated inserted abstract scopes");<br>
}<br>
+ // Assure abstract local scope created for each one contains local DIEs.<br>
+ for (const DILocalScope *LS : getLocalScopes(SP))<br>
+ LScopes.getOrCreateAbstractScope(LS);<br>
constructAbstractSubprogramScopeDIE(AScope);<br>
}<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Thu Mar 24 08:30:16 2016<br>
@@ -211,6 +211,10 @@ class DwarfDebug : public DebugHandlerBa<br>
/// Size of each symbol emitted (for those symbols that have a specific size).<br>
DenseMap<const MCSymbol *, uint64_t> SymSize;<br>
<br>
+ /// Holder for scopes containing local declaration DI nodes per DI function.<br>
+ DenseMap<const DISubprogram *, SmallPtrSet<const DILocalScope *, 16>><br>
+ LocalScopesMap;<br>
+<br>
/// Collection of abstract variables.<br>
DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables;<br>
SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;<br>
@@ -327,6 +331,8 @@ class DwarfDebug : public DebugHandlerBa<br>
<br>
void finishSubprogramDefinitions();<br>
<br>
+ void finishLocalScopeDefinitions();<br>
+<br>
/// Finish off debug information after all functions have been<br>
/// processed.<br>
void finalizeModuleInfo();<br>
@@ -425,6 +431,11 @@ class DwarfDebug : public DebugHandlerBa<br>
void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,<br>
const DIImportedEntity *N);<br>
<br>
+ /// Collect MD Node located within local scope node.<br>
+ /// Return true if node was collected, false otherwise.<br>
+ bool collectLocalScopedNode(DIScope *S, const DINode *N,<br>
+ DwarfCompileUnit &CU);<br>
+<br>
/// Register a source line with debug info. Returns the unique<br>
/// label that was emitted and which provides correspondence to the<br>
/// source line list.<br>
@@ -567,6 +578,12 @@ public:<br>
SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() {<br>
return ProcessedSPNodes;<br>
}<br>
+<br>
+ /// Return collection of function scopes that contains local declararion DIEs.<br>
+ SmallPtrSet<const DILocalScope *, 16> &<br>
+ getLocalScopes(const DISubprogram *SP) {<br>
+ return LocalScopesMap[SP];<br>
+ }<br>
};<br>
} // End of namespace llvm<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Thu Mar 24 08:30:16 2016<br>
@@ -298,10 +298,15 @@ void DwarfUnit::addDIEEntry(DIE &Die, dw<br>
Entry);<br>
}<br>
<br>
-DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {<br>
- DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, (dwarf::Tag)Tag));<br>
+DIE *DwarfUnit::createDIE(unsigned Tag, const DINode *N) {<br>
+ DIE *Die = DIE::get(DIEValueAllocator, (dwarf::Tag)Tag);<br>
if (N)<br>
- insertDIE(N, &Die);<br>
+ insertDIE(N, Die);<br>
+ return Die;<br>
+}<br>
+<br>
+DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {<br>
+ DIE &Die = Parent.addChild(createDIE(Tag, N));<br>
return Die;<br>
}<br>
<br>
@@ -727,15 +732,18 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const<br>
<br>
// Construct the context before querying for the existence of the DIE in case<br>
// such construction creates the DIE.<br>
+ // For Local Scope, do not construct context DIE.<br>
auto *Context = resolve(Ty->getScope());<br>
- DIE *ContextDIE = getOrCreateContextDIE(Context);<br>
- assert(ContextDIE);<br>
+ bool IsLocalScope = Context && isa<DILocalScope>(Context);<br>
+ DIE *ContextDIE = IsLocalScope ? nullptr : getOrCreateContextDIE(Context);<br>
+ assert(ContextDIE || IsLocalScope);<br>
<br>
if (DIE *TyDIE = getDIE(Ty))<br>
return TyDIE;<br>
<br>
- // Create new type.<br>
- DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);<br>
+ // Create new type and add to map.<br>
+ DIE &TyDIE = IsLocalScope ? *createDIE(Ty->getTag(), Ty)<br>
+ : createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);<br>
<br>
updateAcceleratorTables(Context, Ty, TyDIE);<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Thu Mar 24 08:30:16 2016<br>
@@ -298,6 +298,9 @@ public:<br>
/// Construct function argument DIEs.<br>
void constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args);<br>
<br>
+ /// Create a DIE with the given Tag, and call insertDIE if MD is not null.<br>
+ DIE *createDIE(unsigned Tag, const DINode *N = nullptr);<br>
+<br>
/// Create a DIE with the given Tag, add the DIE to its parent, and<br>
/// call insertDIE if MD is not null.<br>
DIE &createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N = nullptr);<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll Thu Mar 24 08:30:16 2016<br>
@@ -74,7 +74,7 @@ entry:<br>
!1 = distinct !DILexicalBlock(line: 15, column: 12, file: !38, scope: !2)<br>
!2 = distinct !DISubprogram(name: "main", linkageName: "main", line: 15, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, scopeLine: 15, file: !38, scope: !3, type: !5)<br>
!3 = !DIFile(filename: "one.cc", directory: "/tmp")<br>
-!4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang 1.5", isOptimized: false, emissionKind: 0, file: !38, enums: !39, retainedTypes: !39, subprograms: !37, imports: null)<br>
+!4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang 1.5", isOptimized: false, emissionKind: 0, file: !38, enums: !39, retainedTypes: !41, subprograms: !37, imports: null)<br>
!5 = !DISubroutineType(types: !6)<br>
!6 = !{!7}<br>
!7 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)<br>
@@ -112,3 +112,4 @@ entry:<br>
!38 = !DIFile(filename: "one.cc", directory: "/tmp")<br>
!39 = !{}<br>
!40 = !{i32 1, !"Debug Info Version", i32 3}<br>
+!41 = !{!21}<br>
\ No newline at end of file<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll Thu Mar 24 08:30:16 2016<br>
@@ -27,7 +27,7 @@ entry:<br>
<br>
!0 = distinct !DISubprogram(name: "foo", line: 9, isLocal: true, isDefinition: true, virtualIndex: 6, isOptimized: true, scopeLine: 9, file: !27, scope: !1, type: !3, variables: !24)<br>
!1 = !DIFile(filename: "bar.c", directory: "/tmp/")<br>
-!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !20, subprograms: !25, globals: !26, imports: !20)<br>
+!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !61, subprograms: !25, globals: !26, imports: !20)<br>
!3 = !DISubroutineType(types: !4)<br>
!4 = !{!5, !5}<br>
!5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)<br>
@@ -39,6 +39,7 @@ entry:<br>
<br>
!59 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5)<br>
!60 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12)<br>
+!61 = !{!12}<br>
<br>
!11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0)<br>
!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13)<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll Thu Mar 24 08:30:16 2016<br>
@@ -32,7 +32,7 @@<br>
; CHECK: DW_AT_name {{.*}} "func"<br>
; CHECK: DW_TAG_compile_unit<br>
<br>
-; FIXME: Maybe we should drop the subprogram here - since the function was<br>
+; Check that the subprogram is dropped in this CU - since the function was<br>
; emitted in one CU, due to linkonce_odr uniquing. We certainly don't emit the<br>
; subprogram here if the source location for this definition is the same (see<br>
; test/DebugInfo/cross-cu-linkonce.ll), though it's very easy to tickle that<br>
@@ -43,7 +43,7 @@<br>
; directory of the source file even though the file name is absolute, not<br>
; relative)<br>
<br>
-; CHECK: DW_TAG_subprogram<br>
+; CHECK-NOT: DW_TAG_subprogram<br>
<br>
@x = global i32 (i32)* @_Z4funci, align 8<br>
@y = global i32 (i32)* @_Z4funci, align 8<br>
@@ -64,7 +64,7 @@ declare void @llvm.dbg.declare(metadata,<br>
attributes #0 = { inlinehint nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>
attributes #1 = { nounwind readnone }<br>
<br>
-!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!12, !0}<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0, !12}<br>
!llvm.module.flags = !{!19, !20}<br>
!llvm.ident = !{!21, !21}<br>
<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Generic/namespace.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/namespace.ll?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/namespace.ll?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/Generic/namespace.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/Generic/namespace.ll Thu Mar 24 08:30:16 2016<br>
@@ -23,6 +23,11 @@<br>
; CHECK-NOT: NULL<br>
; CHECK: [[BAR:0x[0-9a-f]*]]:{{ *}}DW_TAG_structure_type<br>
; CHECK-NEXT: DW_AT_name{{.*}}= "bar"<br>
+; CHECK: DW_TAG_subprogram<br>
+; CHECK-NOT: DW_TAG<br>
+; CHECK: DW_AT_MIPS_linkage_name<br>
+; CHECK-NOT: DW_TAG<br>
+; CHECK: DW_AT_name{{.*}}= "f1"<br>
; CHECK: [[FUNC1:.*]]: DW_TAG_subprogram<br>
; CHECK-NOT: DW_TAG<br>
; CHECK: DW_AT_MIPS_linkage_name<br>
@@ -45,11 +50,6 @@<br>
; CHECK-NOT: DW_TAG<br>
; CHECK: DW_AT_name{{.*}}= "func_fwd"<br>
; CHECK-NOT: DW_AT_declaration<br>
-; CHECK: DW_TAG_subprogram<br>
-; CHECK-NOT: DW_TAG<br>
-; CHECK: DW_AT_MIPS_linkage_name<br>
-; CHECK-NOT: DW_TAG<br>
-; CHECK: DW_AT_name{{.*}}= "f1"<br>
; CHECK: NULL<br>
<br>
; CHECK-NOT: NULL<br>
@@ -71,10 +71,23 @@<br>
<br>
; CHECK: DW_TAG_subprogram<br>
; CHECK-NOT: DW_TAG<br>
+; CHECK: DW_AT_name{{.*}}= "__cxx_global_var_init"<br>
+; CHECK-NOT: DW_TAG<br>
+<br>
+; CHECK: DW_TAG_subprogram<br>
+; CHECK-NOT: DW_TAG<br>
; CHECK: DW_AT_MIPS_linkage_name<br>
; CHECK-NOT: DW_TAG<br>
; CHECK: DW_AT_name{{.*}}= "func"<br>
; CHECK-NOT: NULL<br>
+; CHECK: DW_TAG_lexical_block<br>
+; CHECK-NOT: NULL<br>
+; CHECK: DW_TAG_imported_module<br>
+; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])<br>
+; CHECK-NEXT: DW_AT_decl_line{{.*}}(23)<br>
+; CHECK-NEXT: DW_AT_import{{.*}}=><br>
+; CHECK: NULL<br>
+; CHECK-NOT: NULL<br>
; CHECK: DW_TAG_imported_module<br>
; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])<br>
; CHECK-NEXT: DW_AT_decl_line{{.*}}(26)<br>
@@ -134,13 +147,6 @@<br>
; CHECK-NEXT: DW_AT_decl_line{{.*}}(37)<br>
; CHECK-NEXT: DW_AT_import{{.*}}=> {[[FUNC_FWD]]})<br>
<br>
-; CHECK: DW_TAG_lexical_block<br>
-; CHECK-NOT: NULL<br>
-; CHECK: DW_TAG_imported_module<br>
-; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])<br>
-; CHECK-NEXT: DW_AT_decl_line{{.*}}(23)<br>
-; CHECK-NEXT: DW_AT_import{{.*}}=><br>
-; CHECK: NULL<br>
; CHECK: NULL<br>
; CHECK: NULL<br>
<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Generic/nodebug.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/nodebug.ll?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/nodebug.ll?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/Generic/nodebug.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/Generic/nodebug.ll Thu Mar 24 08:30:16 2016<br>
@@ -16,10 +16,8 @@<br>
; f1();<br>
; }<br>
<br>
-; Check that there's only one DW_TAG_subprogram, nothing for the 'f2' function.<br>
-; CHECK: DW_TAG_subprogram<br>
-; CHECK-NOT: DW_TAG<br>
-; CHECK: DW_AT_name {{.*}} "f1"<br>
+; Check that there is no DW_TAG_subprogram, nothing for the 'f2' function.<br>
+; Note: No debug info was emitted for 'f1' function because it has no code.<br>
; CHECK-NOT: DW_TAG_subprogram<br>
<br>
@i = external global i32<br>
<br>
Modified: llvm/trunk/test/DebugInfo/Mips/InlinedFnLocalVar.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Mips/InlinedFnLocalVar.ll?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Mips/InlinedFnLocalVar.ll?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/Mips/InlinedFnLocalVar.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/Mips/InlinedFnLocalVar.ll Thu Mar 24 08:30:16 2016<br>
@@ -27,7 +27,7 @@ entry:<br>
<br>
!0 = distinct !DISubprogram(name: "foo", line: 9, isLocal: true, isDefinition: true, virtualIndex: 6, isOptimized: true, scopeLine: 9, file: !27, scope: !1, type: !3, variables: !24)<br>
!1 = !DIFile(filename: "bar.c", directory: "/tmp/")<br>
-!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !20, subprograms: !25, globals: !26, imports: !20)<br>
+!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !61, subprograms: !25, globals: !26, imports: !20)<br>
!3 = !DISubroutineType(types: !4)<br>
!4 = !{!5, !5}<br>
!5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)<br>
@@ -39,6 +39,7 @@ entry:<br>
<br>
!59 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5)<br>
!60 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12)<br>
+!61 = !{!12}<br>
<br>
!11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0)<br>
!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13)<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/InlinedFnLocalVar.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/InlinedFnLocalVar.ll?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/InlinedFnLocalVar.ll?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/InlinedFnLocalVar.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/InlinedFnLocalVar.ll Thu Mar 24 08:30:16 2016<br>
@@ -27,7 +27,7 @@ entry:<br>
<br>
!0 = distinct !DISubprogram(name: "foo", line: 9, isLocal: true, isDefinition: true, virtualIndex: 6, isOptimized: true, scopeLine: 9, file: !27, scope: !1, type: !3, variables: !24)<br>
!1 = !DIFile(filename: "bar.c", directory: "/tmp/")<br>
-!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !20, subprograms: !25, globals: !26, imports: !20)<br>
+!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: 0, file: !27, enums: !20, retainedTypes: !111, subprograms: !25, globals: !26, imports: !20)<br>
!3 = !DISubroutineType(types: !4)<br>
!4 = !{!5, !5}<br>
!5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)<br>
@@ -39,6 +39,7 @@ entry:<br>
<br>
!109 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5)<br>
!110 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12)<br>
+!111 = !{!12}<br>
<br>
!11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0)<br>
!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13)<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/dbg-file-name.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-file-name.ll?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-file-name.ll?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/dbg-file-name.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/dbg-file-name.ll Thu Mar 24 08:30:16 2016<br>
@@ -6,7 +6,7 @@<br>
declare i32 @printf(i8*, ...) nounwind<br>
<br>
define i32 @main() nounwind !dbg !6 {<br>
- ret i32 0<br>
+ ret i32 0, !dbg !13<br>
}<br>
<br>
!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!2}<br>
@@ -22,3 +22,4 @@ define i32 @main() nounwind !dbg !6 {<br>
!10 = !DIFile(filename: "simple.c", directory: "/Users/manav/one/two")<br>
!11 = !{}<br>
!12 = !{i32 1, !"Debug Info Version", i32 3}<br>
+!13 = !DILocation(line: 10, scope: !6)<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/debug-dead-local-var.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug-dead-local-var.ll?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug-dead-local-var.ll?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/debug-dead-local-var.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/debug-dead-local-var.ll Thu Mar 24 08:30:16 2016<br>
@@ -11,9 +11,9 @@<br>
; return 1;<br>
; }<br>
<br>
-; Check that we still have the structure type for X even though we're not<br>
-; going to emit a low/high_pc for foo.<br>
-; CHECK: DW_TAG_structure_type<br>
+; Check that we will not have the structure type for X as we are going to omit<br>
+; the function foo.<br>
+; CHECK-NOT: DW_TAG_structure_type<br>
<br>
; Function Attrs: nounwind readnone uwtable<br>
define i32 @bar() #0 !dbg !4 {<br>
@@ -27,7 +27,7 @@ attributes #0 = { nounwind readnone uwta<br>
!llvm.module.flags = !{!18, !19}<br>
!llvm.ident = !{!20}<br>
<br>
-!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 (trunk 209255) (llvm/trunk 209253)", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 (trunk 209255) (llvm/trunk 209253)", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !22, subprograms: !3, globals: !2, imports: !2)<br>
!1 = !DIFile(filename: "debug-dead-local-var.c", directory: "/usr/local/google/home/echristo")<br>
!2 = !{}<br>
!3 = !{!4, !9}<br>
@@ -49,3 +49,4 @@ attributes #0 = { nounwind readnone uwta<br>
!19 = !{i32 2, !"Debug Info Version", i32 3}<br>
!20 = !{!"clang version 3.5.0 (trunk 209255) (llvm/trunk 209253)"}<br>
!21 = !DILocation(line: 13, scope: !4)<br>
+!22 = !{!14}<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll?rev=264280&r1=264279&r2=264280&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll?rev=264280&r1=264279&r2=264280&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll Thu Mar 24 08:30:16 2016<br>
@@ -123,17 +123,6 @@<br>
; CHECK: DW_AT_linkage_name<br>
; CHECK-NOT: DW_TAG<br>
; CHECK: DW_AT_name {{.*}} "global_namespace_function"<br>
-<br>
-; CHECK: DW_TAG_subprogram<br>
-; CHECK-NOT: DW_TAG<br>
-; CHECK: DW_AT_name {{.*}} "f3"<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: [[F3_Z:.*]]: DW_TAG_variable<br>
-; CHECK-NOT: DW_TAG<br>
-; CHECK: DW_AT_name {{.*}} "z"<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_AT_location<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
; CHECK: NULL<br>
; CHECK-NOT: {{DW_TAG|NULL}}<br>
<br>
@@ -194,6 +183,18 @@<br>
; CHECK-NOT: DW_TAG<br>
; CHECK: DW_AT_name {{.*}} "global_function"<br>
<br>
+; CHECK: DW_TAG_subprogram<br>
+; CHECK-NOT: DW_TAG<br>
+; CHECK: DW_AT_name {{.*}} "f3"<br>
+; CHECK-NOT: {{DW_TAG|NULL}}<br>
+; CHECK: [[F3_Z:.*]]: DW_TAG_variable<br>
+; CHECK-NOT: DW_TAG<br>
+; CHECK: DW_AT_name {{.*}} "z"<br>
+; CHECK-NOT: {{DW_TAG|NULL}}<br>
+; CHECK: DW_AT_location<br>
+; CHECK-NOT: {{DW_TAG|NULL}}<br>
+; CHECK: NULL<br>
+<br>
; CHECK-LABEL: .debug_gnu_pubnames contents:<br>
; CHECK-NEXT: length = {{.*}} version = 0x0002 unit_offset = 0x00000000 unit_size = {{.*}}<br>
; CHECK-NEXT: Offset Linkage Kind Name<br>
@@ -201,12 +202,12 @@<br>
; CHECK-NEXT: [[NS]] EXTERNAL TYPE "ns"<br>
; CHECK-NEXT: [[OUTER_ANON_C]] STATIC VARIABLE "outer::(anonymous namespace)::c"<br>
; CHECK-NEXT: [[ANON_I]] STATIC VARIABLE "(anonymous namespace)::i"<br>
+; CHECK-NEXT: [[ANON]] EXTERNAL TYPE "(anonymous namespace)"<br>
; GCC Doesn't put local statics in pubnames, but it seems not unreasonable and<br>
; comes out naturally from LLVM's implementation, so I'm OK with it for now. If<br>
; it's demonstrated that this is a major size concern or degrades debug info<br>
; consumer behavior, feel free to change it.<br>
; CHECK-NEXT: [[F3_Z]] STATIC VARIABLE "f3::z"<br>
-; CHECK-NEXT: [[ANON]] EXTERNAL TYPE "(anonymous namespace)"<br>
; CHECK-NEXT: [[OUTER_ANON]] EXTERNAL TYPE "outer::(anonymous namespace)"<br>
; CHECK-NEXT: [[ANON_INNER_B]] STATIC VARIABLE "(anonymous namespace)::inner::b"<br>
; CHECK-NEXT: [[OUTER]] EXTERNAL TYPE "outer"<br>
<br>
Added: llvm/trunk/test/DebugInfo/X86/lexical-block-file.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/lexical-block-file.ll?rev=264280&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/lexical-block-file.ll?rev=264280&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/lexical-block-file.ll (added)<br>
+++ llvm/trunk/test/DebugInfo/X86/lexical-block-file.ll Thu Mar 24 08:30:16 2016<br>
@@ -0,0 +1,89 @@<br>
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s<br>
+<br>
+;; This test checks that Inlined DILexicalBlockFile with local decl entry is<br>
+;; skipped and only one DW_TAG_lexical_block is generated.<br>
+;;<br>
+;; This test was generated by running following command:<br>
+;; clang -cc1 -O0 -debug-info-kind=limited -emit-llvm test.cpp<br>
+;; Where test.cpp<br>
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
+;;<br>
+;;static __attribute__((always_inline)) int bar() {<br>
+;; {<br>
+;;#line 2 "test.h"<br>
+;; static int x = 0;<br>
+;; return x;<br>
+;; }<br>
+;;}<br>
+;;int foo() {<br>
+;; {<br>
+;; return bar();<br>
+;; }<br>
+;;}<br>
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
+<br>
+;; Abstract "bar" function<br>
+; CHECK: [[Offset_bar:0x[0-9abcdef]+]]: DW_TAG_subprogram<br>
+; CHECK-NOT: {{DW_TAG|NULL}}<br>
+; CHECK: DW_AT_name {{.*}} "bar"<br>
+; CHECK: DW_AT_inline<br>
+<br>
+; CHECK-NOT: {{DW_TAG|NULL}}<br>
+; CHECK: [[Offset_LB:0x[0-9abcdef]+]]: DW_TAG_lexical_block<br>
+<br>
+; CHECK-NOT: {{DW_TAG|NULL}}<br>
+; CHECK: [[Offset_x:0x[0-9abcdef]+]]: DW_TAG_variable<br>
+; CHECK-NOT: {{DW_TAG|NULL}}<br>
+; CHECK: DW_AT_name {{.*}} "x"<br>
+<br>
+<br>
+; CHECK: DW_TAG_subprogram<br>
+; CHECK-NOT: {{DW_TAG|NULL}}<br>
+; CHECK: DW_AT_name {{.*}} "foo"<br>
+; CHECK-NOT: {{NULL}}<br>
+<br>
+;; Inlined "bar" function<br>
+; CHECK: DW_TAG_inlined_subroutine<br>
+; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]}<br>
+<br>
+; CHECK-NOT: {{DW_TAG|NULL}}<br>
+; CHECK: DW_TAG_lexical_block<br>
+; CHECK-NOT: {{DW_TAG|NULL}}<br>
+; CHECK: DW_AT_abstract_origin {{.*}} {[[Offset_LB]]}<br>
+<br>
+<br>
+@bar.x = internal global i32 0, align 4<br>
+<br>
+; Function Attrs: nounwind<br>
+define i32 @foo() #0 !dbg !4 {<br>
+entry:<br>
+ %0 = load i32, i32* @bar.x, align 4, !dbg !16<br>
+ ret i32 %0, !dbg !19<br>
+}<br>
+<br>
+attributes #0 = { nounwind }<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
+!llvm.module.flags = !{!14}<br>
+!llvm.ident = !{!15}<br>
+<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (trunk 263423)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3, globals: !10)<br>
+!1 = !DIFile(filename: "test.c", directory: "/")<br>
+!2 = !{}<br>
+!3 = !{!4, !9}<br>
+!4 = distinct !DISubprogram(name: "foo", scope: !5, file: !5, line: 6, type: !6, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: false, variables: !2)<br>
+!5 = !DIFile(filename: "test.h", directory: "/")<br>
+!6 = !DISubroutineType(types: !7)<br>
+!7 = !{!8}<br>
+!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)<br>
+!9 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !6, isLocal: true, isDefinition: true, scopeLine: 2, isOptimized: false, variables: !2)<br>
+!10 = !{!11}<br>
+!11 = !DIGlobalVariable(name: "x", scope: !12, file: !5, line: 2, type: !8, isLocal: true, isDefinition: true, variable: i32* @bar.x)<br>
+!12 = !DILexicalBlockFile(scope: !13, file: !5, discriminator: 0)<br>
+!13 = distinct !DILexicalBlock(scope: !9, file: !1, line: 3)<br>
+!14 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!15 = !{!"clang version 3.9.0 (trunk 263423)"}<br>
+!16 = !DILocation(line: 3, scope: !12, inlinedAt: !17)<br>
+!17 = distinct !DILocation(line: 8, scope: !18)<br>
+!18 = distinct !DILexicalBlock(scope: !4, file: !5, line: 7)<br>
+!19 = !DILocation(line: 8, scope: !18)<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>