From 01bc66a8ce04297cd3688dacb7e6110b1a60cd50 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 24 Mar 2016 20:38:49 +0000 Subject: [PATCH] Revert "Recommitted r263424 "Supporting all entities declared in lexical scope in LLVM debug info." After fixing PR26942 (the fix is included in this commit)." This reverts commit r264280. This broke building Chromium for iOS. We'll upload a reproducer to the PR soon. llvm-svn: 264334 --- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 144 ++++----------- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h | 44 +---- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 32 +--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 17 -- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 22 +-- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h | 3 - .../Generic/2010-04-06-NestedFnDbgInfo.ll | 3 +- .../Generic/2010-06-29-InlinedFnLocalVar.ll | 3 +- .../Generic/cross-cu-linkonce-distinct.ll | 6 +- llvm/test/DebugInfo/Generic/namespace.ll | 30 ++-- llvm/test/DebugInfo/Generic/nodebug.ll | 6 +- llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll | 3 +- llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll | 3 +- llvm/test/DebugInfo/X86/PR24008.ll | 67 ------- llvm/test/DebugInfo/X86/dbg-file-name.ll | 3 +- llvm/test/DebugInfo/X86/debug-dead-local-var.ll | 9 +- llvm/test/DebugInfo/X86/gnu-public-names.ll | 25 ++- llvm/test/DebugInfo/X86/lexical-block-file.ll | 89 --------- llvm/test/DebugInfo/X86/lexical-block-inline.ll | 198 --------------------- llvm/test/DebugInfo/X86/lexical-block.ll | 131 -------------- llvm/test/DebugInfo/X86/subprogram-inline.ll | 169 ------------------ 21 files changed, 91 insertions(+), 916 deletions(-) delete mode 100644 llvm/test/DebugInfo/X86/PR24008.ll delete mode 100644 llvm/test/DebugInfo/X86/lexical-block-file.ll delete mode 100644 llvm/test/DebugInfo/X86/lexical-block-inline.ll delete mode 100644 llvm/test/DebugInfo/X86/lexical-block.ll delete mode 100644 llvm/test/DebugInfo/X86/subprogram-inline.ll diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 2638c25..56856c7 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -114,16 +114,10 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE( // Construct the context before querying for the existence of the DIE in // case such construction creates the DIE. - // For Local Scope, do not construct context DIE. - bool IsLocalScope = GVContext && isa(GVContext); - DIE *ContextDIE = IsLocalScope ? nullptr : getOrCreateContextDIE(GVContext); - assert(ContextDIE || IsLocalScope); - - // Create new global variable and add to map. - DIE *VariableDIE = IsLocalScope - ? createDIE(GV->getTag(), GV) - : &createAndAddDIE(GV->getTag(), *ContextDIE, GV); + DIE *ContextDIE = getOrCreateContextDIE(GVContext); + // Add to map. + DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV); DIScope *DeclContext; if (auto *SDMDecl = GV->getStaticDataMemberDeclaration()) { DeclContext = resolve(SDMDecl->getScope()); @@ -341,15 +335,23 @@ void DwarfCompileUnit::constructScopeDIE( if (DD->isLexicalScopeDIENull(Scope)) return; - bool HasNonScopeChildren; + unsigned ChildScopeCount; // We create children here when we know the scope DIE is not going to be // null and the children will be added to the scope DIE. - createScopeChildrenDIE(Scope, Children, &HasNonScopeChildren); + createScopeChildrenDIE(Scope, Children, &ChildScopeCount); + + // Skip imported directives in gmlt-like data. + if (!includeMinimalInlineScopes()) { + // There is no need to emit empty lexical block DIE. + for (const auto *IE : ImportedEntities[DS]) + Children.push_back( + constructImportedEntityDIE(cast(IE))); + } // If there are only other scopes as children, put them directly in the // parent instead, as this scope would serve no purpose. - if (!HasNonScopeChildren) { + if (Children.size() == ChildScopeCount) { FinalChildren.insert(FinalChildren.end(), std::make_move_iterator(Children.begin()), std::make_move_iterator(Children.end())); @@ -364,7 +366,6 @@ void DwarfCompileUnit::constructScopeDIE( ScopeDIE->addChild(std::move(I)); FinalChildren.push_back(std::move(ScopeDIE)); - addLocalScopeDieToLexicalScope(Scope, ScopeDIE); } DIE::value_iterator @@ -557,37 +558,20 @@ DIE *DwarfCompileUnit::constructVariableDIE(DbgVariable &DV, DIE *DwarfCompileUnit::createScopeChildrenDIE(LexicalScope *Scope, SmallVectorImpl &Children, - bool *HasNonScopeChildren) { + unsigned *ChildScopeCount) { DIE *ObjectPointer = nullptr; - bool HasLocalDclDie = false; - auto *DS = Scope->getScopeNode(); for (DbgVariable *DV : DU->getScopeVariables().lookup(Scope)) Children.push_back(constructVariableDIE(*DV, *Scope, ObjectPointer)); - // Skip local declarations in gmlt-like data. - if (!includeMinimalInlineScopes()) { - for (const auto *DI : LocalDeclNodes[DS]) { - DIE *D = nullptr; - if (auto *IE = dyn_cast(DI)) - D = getOrCreateImportedEntityDIE(IE); - else if (auto *GV = dyn_cast(DI)) - D = getOrCreateGlobalVariableDIE(GV); - else if (auto *RT = dyn_cast(DI)) - D = getOrCreateTypeDIE(RT); - else - llvm_unreachable("Unexpected DI node!"); - addLocalDclDieToLexicalScope(Scope, D); - HasLocalDclDie = true; - } - } - - if (HasNonScopeChildren) - *HasNonScopeChildren = !Children.empty() || HasLocalDclDie; + unsigned ChildCountWithoutScopes = Children.size(); for (LexicalScope *LS : Scope->getChildren()) constructScopeDIE(LS, Children); + if (ChildScopeCount) + *ChildScopeCount = Children.size() - ChildCountWithoutScopes; + return ObjectPointer; } @@ -629,8 +613,6 @@ DIE *DwarfCompileUnit::createAndAddScopeChildren(LexicalScope *Scope, for (auto &I : Children) ScopeDIE.addChild(std::move(I)); - addLocalScopeDieToLexicalScope(Scope, &ScopeDIE); - return ObjectPointer; } @@ -667,20 +649,10 @@ void DwarfCompileUnit::constructAbstractSubprogramScopeDIE( addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer); } -DIE *DwarfCompileUnit::getOrCreateImportedEntityDIE( - const DIImportedEntity *Module) { - if (DIE *Die = getDIE(Module)) - return Die; - - return constructImportedEntityDIE(Module); -} - DIE *DwarfCompileUnit::constructImportedEntityDIE( const DIImportedEntity *Module) { - - assert(!getDIE(Module)); - - DIE *IMDie = createDIE(Module->getTag(), Module); + DIE *IMDie = DIE::get(DIEValueAllocator, (dwarf::Tag)Module->getTag()); + insertDIE(Module, IMDie); DIE *EntityDie; auto *Entity = resolve(Module->getEntity()); if (auto *NS = dyn_cast(Entity)) @@ -707,46 +679,22 @@ DIE *DwarfCompileUnit::constructImportedEntityDIE( } void DwarfCompileUnit::finishSubprogramDefinition(const DISubprogram *SP) { - if (DIE *D = getDIE(SP)) { - if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) + DIE *D = getDIE(SP); + if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) { + if (D) // If this subprogram has an abstract definition, reference that addDIEEntry(*D, dwarf::DW_AT_abstract_origin, *AbsSPDIE); - else + } else { + if (!D && !includeMinimalInlineScopes()) + // Lazily construct the subprogram if we didn't see either concrete or + // inlined versions during codegen. (except in -gmlt ^ where we want + // to omit these entirely) + D = getOrCreateSubprogramDIE(SP); + if (D) // And attach the attributes applySubprogramAttributesToDefinition(SP, *D); } } - -void DwarfCompileUnit::finishLocalScopeDefinitions() { - for (const auto &I : getLSDieInfoMap()) { - auto LSInfo = I.second; - // Attach all local dcl DIEs to abstract local scope if available, - // otherwise attach it to concrete local scope. - DIE *LBDie = - LSInfo.AbstractLSDie ? LSInfo.AbstractLSDie : LSInfo.ConcreteLSDie; - assert(LBDie || LSInfo.LocalDclDies.empty()); - for (auto &D : LSInfo.LocalDclDies) - LBDie->addChild(std::move(D)); - - if (isa(I.first)) - // For function scope there is nothing else to do. - // "abstract_origin" dwarf attribute was added somewhere else. - continue; - - if (LSInfo.AbstractLSDie) { - // Add "abstract_origin" dwarf attribute to concrete local scope pointing - // to the corresponding abstract local scope. - if (LSInfo.ConcreteLSDie) - addDIEEntry(*LSInfo.ConcreteLSDie, dwarf::DW_AT_abstract_origin, - *LSInfo.AbstractLSDie); - // Add "abstract_origin" dwarf attribute to inline local scope pointing - // to the corresponding abstract local scope. - for (auto &L : LSInfo.InlineLSDies) - addDIEEntry(*L, dwarf::DW_AT_abstract_origin, *LSInfo.AbstractLSDie); - } - } -} - void DwarfCompileUnit::collectDeadVariables(const DISubprogram *SP) { assert(SP && "CU's subprogram list contains a non-subprogram"); assert(SP->isDefinition() && @@ -757,7 +705,7 @@ void DwarfCompileUnit::collectDeadVariables(const DISubprogram *SP) { DIE *SPDIE = DU->getAbstractSPDies().lookup(SP); if (!SPDIE) - return; + SPDIE = getDIE(SP); assert(SPDIE); for (const DILocalVariable *DV : Variables) { DbgVariable NewVar(DV, /* IA */ nullptr, DD); @@ -882,34 +830,6 @@ void DwarfCompileUnit::applySubprogramAttributesToDefinition( addGlobalName(SP->getName(), SPDie, Context); } -void DwarfCompileUnit::addLocalScopeDieToLexicalScope(LexicalScope *LS, - DIE *D) { - const DILocalScope *Scope = LS->getScopeNode(); - assert(!isa(Scope) && "Don't expect Lexical Block File!"); - auto &LSInfo = getLSDieInfoMap()[Scope]; - if (LS->isAbstractScope()) { - assert(!LSInfo.AbstractLSDie && "Adding abstract LS DIE twice."); - LSInfo.AbstractLSDie = D; - return; - } - if (LS->getInlinedAt()) { - assert(!LSInfo.InlineLSDies.count(D) && "Adding inline LS DIE twice."); - LSInfo.InlineLSDies.insert(D); - return; - } - assert(!LSInfo.ConcreteLSDie && "Adding cocncrete LS DIE twice."); - LSInfo.ConcreteLSDie = D; - return; -} - -void DwarfCompileUnit::addLocalDclDieToLexicalScope(LexicalScope *LS, DIE *D) { - const DILocalScope *Scope = LS->getScopeNode(); - assert(!isa(Scope) && "Don't expect Lexical Block File!"); - auto &LSInfo = getLSDieInfoMap()[Scope]; - LSInfo.LocalDclDies.insert(D); - return; -} - bool DwarfCompileUnit::isDwoUnit() const { return DD->useSplitDwarf() && Skeleton; } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h index b47cbae..bacf87d 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h @@ -15,7 +15,6 @@ #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H #include "DwarfUnit.h" -#include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/DebugInfo.h" #include "llvm/Support/Dwarf.h" @@ -49,10 +48,11 @@ class DwarfCompileUnit : public DwarfUnit { /// The start of the unit macro info within macro section. MCSymbol *MacroLabelBegin; - typedef llvm::SmallVector LocalDeclNodeList; - typedef llvm::DenseMap LocalScopesMap; + typedef llvm::SmallVector ImportedEntityList; + typedef llvm::DenseMap + ImportedEntityMap; - LocalScopesMap LocalDeclNodes; + ImportedEntityMap ImportedEntities; /// GlobalNames - A map of globally visible named entities for this unit. StringMap GlobalNames; @@ -71,15 +71,6 @@ class DwarfCompileUnit : public DwarfUnit { // ranges/locs. const MCSymbol *BaseAddress; - struct LocalScopeDieInfo { - DIE *ConcreteLSDie = nullptr; - DIE *AbstractLSDie = nullptr; - SetVector InlineLSDies; - SetVector LocalDclDies; - }; - // Collection of local scope DIE info. - DenseMap LocalScopeDieInfoMap; - /// \brief Construct a DIE for the given DbgVariable without initializing the /// DbgVariable's DIE reference. DIE *constructVariableDIEImpl(const DbgVariable &DV, bool Abstract); @@ -126,16 +117,8 @@ public: unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override; - void addLocalDeclNode(const DINode *DI, DILocalScope *Scope) { - // LocalDeclNodes maps local declaration DIEs to their parent DILocalScope. - // These local declaration entities will be processed when processing the - // lexical scopes collected by LexicalScopes component. - // DILexicalBlockFile is skipped by LexicalScopes and it collect its parent, - // which is of a DILexicalBlock. Thus, LocalDeclNodes must not map to - // DILexicalBlockFile but to its parent DILexicalBlock. - if (auto *File = dyn_cast(Scope)) - Scope = File->getScope(); - LocalDeclNodes[Scope].push_back(DI); + void addImportedEntity(const DIImportedEntity* IE) { + ImportedEntities[IE->getScope()].push_back(IE); } /// addRange - Add an address range to the list of ranges for this unit. @@ -183,7 +166,7 @@ public: /// A helper function to create children of a Scope DIE. DIE *createScopeChildrenDIE(LexicalScope *Scope, SmallVectorImpl &Children, - bool *HasNonScopeChildren = nullptr); + unsigned *ChildScopeCount = nullptr); /// \brief Construct a DIE for this subprogram scope. void constructSubprogramScopeDIE(LexicalScope *Scope); @@ -192,15 +175,11 @@ public: void constructAbstractSubprogramScopeDIE(LexicalScope *Scope); - /// \brief Get or create import_module DIE. - DIE *getOrCreateImportedEntityDIE(const DIImportedEntity *Module); /// \brief Construct import_module DIE. DIE *constructImportedEntityDIE(const DIImportedEntity *Module); void finishSubprogramDefinition(const DISubprogram *SP); - void finishLocalScopeDefinitions(); - void collectDeadVariables(const DISubprogram *SP); /// Set the skeleton unit associated with this unit. @@ -274,15 +253,6 @@ public: void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; } const MCSymbol *getBaseAddress() const { return BaseAddress; } - - DenseMap &getLSDieInfoMap() { - return LocalScopeDieInfoMap; - } - - /// Add local scope DIE entry to lexical scope info. - void addLocalScopeDieToLexicalScope(LexicalScope *LS, DIE *D); - /// Add local declaration DIE entry to lexical scope info. - void addLocalDclDieToLexicalScope(LexicalScope *LS, DIE *D); }; } // end llvm namespace diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 9829d0f..dc21583 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -458,16 +458,6 @@ void DwarfDebug::constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU, D->addChild(TheCU.constructImportedEntityDIE(N)); } -bool DwarfDebug::collectLocalScopedNode(DIScope *S, const DINode *N, - DwarfCompileUnit &CU) { - if (auto LS = dyn_cast_or_null(S)) { - getLocalScopes(LS->getSubprogram()).insert(LS); - CU.addLocalDeclNode(N, LS); - return true; - } - return false; -} - // Emit all Dwarf sections that should come prior to the content. Create // global DIEs and emit initial debug info sections. This is invoked by // the target AsmPrinter. @@ -487,9 +477,10 @@ void DwarfDebug::beginModule() { for (MDNode *N : CU_Nodes->operands()) { auto *CUNode = cast(N); DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode); + for (auto *IE : CUNode->getImportedEntities()) + CU.addImportedEntity(IE); for (auto *GV : CUNode->getGlobalVariables()) - if (!collectLocalScopedNode(GV->getScope(), GV, CU)) - CU.getOrCreateGlobalVariableDIE(GV); + CU.getOrCreateGlobalVariableDIE(GV); for (auto *SP : CUNode->getSubprograms()) SPMap.insert(std::make_pair(SP, &CU)); for (auto *Ty : CUNode->getEnumTypes()) { @@ -501,17 +492,14 @@ void DwarfDebug::beginModule() { // The retained types array by design contains pointers to // MDNodes rather than DIRefs. Unique them here. DIType *RT = cast(resolve(Ty->getRef())); - if (RT->isExternalTypeRef()) + if (!RT->isExternalTypeRef()) // There is no point in force-emitting a forward declaration. - continue; - if (!collectLocalScopedNode(resolve(Ty->getScope()), RT, CU)) CU.getOrCreateTypeDIE(RT); } // Emit imported_modules last so that the relevant context is already // available. for (auto *IE : CUNode->getImportedEntities()) - if (!collectLocalScopedNode(IE->getScope(), IE, CU)) - constructAndAddImportedEntityDIE(CU, IE); + constructAndAddImportedEntityDIE(CU, IE); } // Tell MMI that we have debug info. @@ -544,11 +532,6 @@ void DwarfDebug::finishSubprogramDefinitions() { }); } -void DwarfDebug::finishLocalScopeDefinitions() { - for (const auto &I : CUMap) - I.second->finishLocalScopeDefinitions(); -} - // Collect info for variables that were optimized out. void DwarfDebug::collectDeadVariables() { const Module *M = MMI->getModule(); @@ -574,8 +557,6 @@ void DwarfDebug::finalizeModuleInfo() { finishSubprogramDefinitions(); - finishLocalScopeDefinitions(); - finishVariableDefinitions(); // Collect info for variables that were optimized out. @@ -1186,9 +1167,6 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { assert(LScopes.getAbstractScopesList().size() == NumAbstractScopes && "ensureAbstractVariableIsCreated inserted abstract scopes"); } - // Assure abstract local scope created for each one contains local DIEs. - for (const DILocalScope *LS : getLocalScopes(SP)) - LScopes.getOrCreateAbstractScope(LS); constructAbstractSubprogramScopeDIE(AScope); } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index 253fa18..f0859ec 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -211,10 +211,6 @@ class DwarfDebug : public DebugHandlerBase { /// Size of each symbol emitted (for those symbols that have a specific size). DenseMap SymSize; - /// Holder for scopes containing local declaration DI nodes per DI function. - DenseMap> - LocalScopesMap; - /// Collection of abstract variables. DenseMap> AbstractVariables; SmallVector, 64> ConcreteVariables; @@ -331,8 +327,6 @@ class DwarfDebug : public DebugHandlerBase { void finishSubprogramDefinitions(); - void finishLocalScopeDefinitions(); - /// Finish off debug information after all functions have been /// processed. void finalizeModuleInfo(); @@ -431,11 +425,6 @@ class DwarfDebug : public DebugHandlerBase { void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU, const DIImportedEntity *N); - /// Collect MD Node located within local scope node. - /// Return true if node was collected, false otherwise. - bool collectLocalScopedNode(DIScope *S, const DINode *N, - DwarfCompileUnit &CU); - /// Register a source line with debug info. Returns the unique /// label that was emitted and which provides correspondence to the /// source line list. @@ -578,12 +567,6 @@ public: SmallPtrSet &getProcessedSPNodes() { return ProcessedSPNodes; } - - /// Return collection of function scopes that contains local declararion DIEs. - SmallPtrSet & - getLocalScopes(const DISubprogram *SP) { - return LocalScopesMap[SP]; - } }; } // End of namespace llvm diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index b2fe3c0..387921c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -298,15 +298,10 @@ void DwarfUnit::addDIEEntry(DIE &Die, dwarf::Attribute Attribute, Entry); } -DIE *DwarfUnit::createDIE(unsigned Tag, const DINode *N) { - DIE *Die = DIE::get(DIEValueAllocator, (dwarf::Tag)Tag); - if (N) - insertDIE(N, Die); - return Die; -} - DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) { - DIE &Die = Parent.addChild(createDIE(Tag, N)); + DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, (dwarf::Tag)Tag)); + if (N) + insertDIE(N, &Die); return Die; } @@ -732,18 +727,15 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) { // Construct the context before querying for the existence of the DIE in case // such construction creates the DIE. - // For Local Scope, do not construct context DIE. auto *Context = resolve(Ty->getScope()); - bool IsLocalScope = Context && isa(Context); - DIE *ContextDIE = IsLocalScope ? nullptr : getOrCreateContextDIE(Context); - assert(ContextDIE || IsLocalScope); + DIE *ContextDIE = getOrCreateContextDIE(Context); + assert(ContextDIE); if (DIE *TyDIE = getDIE(Ty)) return TyDIE; - // Create new type and add to map. - DIE &TyDIE = IsLocalScope ? *createDIE(Ty->getTag(), Ty) - : createAndAddDIE(Ty->getTag(), *ContextDIE, Ty); + // Create new type. + DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty); updateAcceleratorTables(Context, Ty, TyDIE); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h index a72e5a3..a79add6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -298,9 +298,6 @@ public: /// Construct function argument DIEs. void constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args); - /// Create a DIE with the given Tag, and call insertDIE if MD is not null. - DIE *createDIE(unsigned Tag, const DINode *N = nullptr); - /// Create a DIE with the given Tag, add the DIE to its parent, and /// call insertDIE if MD is not null. DIE &createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N = nullptr); diff --git a/llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll b/llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll index 3eaedd8..610b55c 100644 --- a/llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll +++ b/llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll @@ -74,7 +74,7 @@ entry: !1 = distinct !DILexicalBlock(line: 15, column: 12, file: !38, scope: !2) !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) !3 = !DIFile(filename: "one.cc", directory: "/tmp") -!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) +!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) !5 = !DISubroutineType(types: !6) !6 = !{!7} !7 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) @@ -112,4 +112,3 @@ entry: !38 = !DIFile(filename: "one.cc", directory: "/tmp") !39 = !{} !40 = !{i32 1, !"Debug Info Version", i32 3} -!41 = !{!21} \ No newline at end of file diff --git a/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll b/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll index 10bc50c..f01cf6d 100644 --- a/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll +++ b/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll @@ -27,7 +27,7 @@ entry: !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) !1 = !DIFile(filename: "bar.c", directory: "/tmp/") -!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) +!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) !3 = !DISubroutineType(types: !4) !4 = !{!5, !5} !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) @@ -39,7 +39,6 @@ entry: !59 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5) !60 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12) -!61 = !{!12} !11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0) !12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13) diff --git a/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll b/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll index cbe1920..1713ea1 100644 --- a/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll +++ b/llvm/test/DebugInfo/Generic/cross-cu-linkonce-distinct.ll @@ -32,7 +32,7 @@ ; CHECK: DW_AT_name {{.*}} "func" ; CHECK: DW_TAG_compile_unit -; Check that the subprogram is dropped in this CU - since the function was +; FIXME: Maybe we should drop the subprogram here - since the function was ; emitted in one CU, due to linkonce_odr uniquing. We certainly don't emit the ; subprogram here if the source location for this definition is the same (see ; test/DebugInfo/cross-cu-linkonce.ll), though it's very easy to tickle that @@ -43,7 +43,7 @@ ; directory of the source file even though the file name is absolute, not ; relative) -; CHECK-NOT: DW_TAG_subprogram +; CHECK: DW_TAG_subprogram @x = global i32 (i32)* @_Z4funci, align 8 @y = global i32 (i32)* @_Z4funci, align 8 @@ -64,7 +64,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 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" } attributes #1 = { nounwind readnone } -!llvm.dbg.cu = !{!0, !12} +!llvm.dbg.cu = !{!12, !0} !llvm.module.flags = !{!19, !20} !llvm.ident = !{!21, !21} diff --git a/llvm/test/DebugInfo/Generic/namespace.ll b/llvm/test/DebugInfo/Generic/namespace.ll index e176975..e446806 100644 --- a/llvm/test/DebugInfo/Generic/namespace.ll +++ b/llvm/test/DebugInfo/Generic/namespace.ll @@ -23,11 +23,6 @@ ; CHECK-NOT: NULL ; CHECK: [[BAR:0x[0-9a-f]*]]:{{ *}}DW_TAG_structure_type ; CHECK-NEXT: DW_AT_name{{.*}}= "bar" -; CHECK: DW_TAG_subprogram -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_MIPS_linkage_name -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name{{.*}}= "f1" ; CHECK: [[FUNC1:.*]]: DW_TAG_subprogram ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_MIPS_linkage_name @@ -50,6 +45,11 @@ ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name{{.*}}= "func_fwd" ; CHECK-NOT: DW_AT_declaration +; CHECK: DW_TAG_subprogram +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_MIPS_linkage_name +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_name{{.*}}= "f1" ; CHECK: NULL ; CHECK-NOT: NULL @@ -71,23 +71,10 @@ ; CHECK: DW_TAG_subprogram ; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name{{.*}}= "__cxx_global_var_init" -; CHECK-NOT: DW_TAG - -; CHECK: DW_TAG_subprogram -; CHECK-NOT: DW_TAG ; CHECK: DW_AT_MIPS_linkage_name ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name{{.*}}= "func" ; CHECK-NOT: NULL -; CHECK: DW_TAG_lexical_block -; CHECK-NOT: NULL -; CHECK: DW_TAG_imported_module -; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]]) -; CHECK-NEXT: DW_AT_decl_line{{.*}}(23) -; CHECK-NEXT: DW_AT_import{{.*}}=> -; CHECK: NULL -; CHECK-NOT: NULL ; CHECK: DW_TAG_imported_module ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]]) ; CHECK-NEXT: DW_AT_decl_line{{.*}}(26) @@ -147,6 +134,13 @@ ; CHECK-NEXT: DW_AT_decl_line{{.*}}(37) ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[FUNC_FWD]]}) +; CHECK: DW_TAG_lexical_block +; CHECK-NOT: NULL +; CHECK: DW_TAG_imported_module +; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]]) +; CHECK-NEXT: DW_AT_decl_line{{.*}}(23) +; CHECK-NEXT: DW_AT_import{{.*}}=> +; CHECK: NULL ; CHECK: NULL ; CHECK: NULL diff --git a/llvm/test/DebugInfo/Generic/nodebug.ll b/llvm/test/DebugInfo/Generic/nodebug.ll index 7aafc8d..6f20aec 100644 --- a/llvm/test/DebugInfo/Generic/nodebug.ll +++ b/llvm/test/DebugInfo/Generic/nodebug.ll @@ -16,8 +16,10 @@ ; f1(); ; } -; Check that there is no DW_TAG_subprogram, nothing for the 'f2' function. -; Note: No debug info was emitted for 'f1' function because it has no code. +; Check that there's only one DW_TAG_subprogram, nothing for the 'f2' function. +; CHECK: DW_TAG_subprogram +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_name {{.*}} "f1" ; CHECK-NOT: DW_TAG_subprogram @i = external global i32 diff --git a/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll b/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll index 4b57e7c..fe66152 100644 --- a/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll +++ b/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll @@ -27,7 +27,7 @@ entry: !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) !1 = !DIFile(filename: "bar.c", directory: "/tmp/") -!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) +!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) !3 = !DISubroutineType(types: !4) !4 = !{!5, !5} !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) @@ -39,7 +39,6 @@ entry: !59 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5) !60 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12) -!61 = !{!12} !11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0) !12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13) diff --git a/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll b/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll index 0b1490a..a262fc8 100644 --- a/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll +++ b/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll @@ -27,7 +27,7 @@ entry: !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) !1 = !DIFile(filename: "bar.c", directory: "/tmp/") -!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) +!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) !3 = !DISubroutineType(types: !4) !4 = !{!5, !5} !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) @@ -39,7 +39,6 @@ entry: !109 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5) !110 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12) -!111 = !{!12} !11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0) !12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13) diff --git a/llvm/test/DebugInfo/X86/PR24008.ll b/llvm/test/DebugInfo/X86/PR24008.ll deleted file mode 100644 index ec7c978..0000000 --- a/llvm/test/DebugInfo/X86/PR24008.ll +++ /dev/null @@ -1,67 +0,0 @@ -; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s - -;; This test checks the following: -;; 1. Compilation does not crash -;; 2. "f1" function is defined. -;; 3. "nested::f2" function is not defined. -;; -;; This test was generated by running following command: -;; clang -cc1 -O0 -g -emit-llvm foo.cpp -o - | opt -S -inline -sroa -;; Where test.cpp -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;void f1() { -;; while (true) { -;; struct nested { -;; static void f2() {} -;; }; -;; nested::f2(); -;; } -;;} -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; CHECK: DW_TAG_compile_unit -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_subprogram -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "f1" -; CHECK: NULL - -; CHECK-NOT: DW_TAG_subprogram - - -; Function Attrs: nounwind -define void @_Z2f1v() #0 !dbg !6 { -entry: - br label %while.body, !dbg !16 - -while.body: ; preds = %while.body, %entry - br label %while.body, !dbg !16 - -return: ; No predecessors! - ret void, !dbg !17 -} - -attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!13, !14} -!llvm.ident = !{!15} - -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !11) -!1 = !DIFile(filename: "foo.cpp", directory: "/") -!2 = !{} -!3 = !{!4} -!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "nested", scope: !5, file: !1, line: 3, size: 8, align: 8, elements: !9) -!5 = distinct !DILexicalBlock(scope: !6, file: !1, line: 2) -!6 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !2) -!7 = !DISubroutineType(types: !8) -!8 = !{null} -!9 = !{!10} -!10 = distinct !DISubprogram(name: "f2", scope: !4, file: !1, line: 4, type: !7, isLocal: false, isDefinition: false, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false) -!11 = !{!6, !12} -!12 = distinct !DISubprogram(name: "f2", linkageName: "_ZZ2f1vEN6nested2f2Ev", scope: !4, file: !1, line: 4, type: !7, isLocal: true, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, declaration: !10, variables: !2) -!13 = !{i32 2, !"Dwarf Version", i32 4} -!14 = !{i32 2, !"Debug Info Version", i32 3} -!15 = !{!"clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)"} -!16 = !DILocation(line: 2, scope: !6) -!17 = !DILocation(line: 8, scope: !6) diff --git a/llvm/test/DebugInfo/X86/dbg-file-name.ll b/llvm/test/DebugInfo/X86/dbg-file-name.ll index 0716d86..60954b9 100644 --- a/llvm/test/DebugInfo/X86/dbg-file-name.ll +++ b/llvm/test/DebugInfo/X86/dbg-file-name.ll @@ -6,7 +6,7 @@ declare i32 @printf(i8*, ...) nounwind define i32 @main() nounwind !dbg !6 { - ret i32 0, !dbg !13 + ret i32 0 } !llvm.dbg.cu = !{!2} @@ -22,4 +22,3 @@ define i32 @main() nounwind !dbg !6 { !10 = !DIFile(filename: "simple.c", directory: "/Users/manav/one/two") !11 = !{} !12 = !{i32 1, !"Debug Info Version", i32 3} -!13 = !DILocation(line: 10, scope: !6) diff --git a/llvm/test/DebugInfo/X86/debug-dead-local-var.ll b/llvm/test/DebugInfo/X86/debug-dead-local-var.ll index ef64536..9a2872ae 100644 --- a/llvm/test/DebugInfo/X86/debug-dead-local-var.ll +++ b/llvm/test/DebugInfo/X86/debug-dead-local-var.ll @@ -11,9 +11,9 @@ ; return 1; ; } -; Check that we will not have the structure type for X as we are going to omit -; the function foo. -; CHECK-NOT: DW_TAG_structure_type +; Check that we still have the structure type for X even though we're not +; going to emit a low/high_pc for foo. +; CHECK: DW_TAG_structure_type ; Function Attrs: nounwind readnone uwtable define i32 @bar() #0 !dbg !4 { @@ -27,7 +27,7 @@ attributes #0 = { nounwind readnone uwtable "less-precise-fpmad"="false" "no-fra !llvm.module.flags = !{!18, !19} !llvm.ident = !{!20} -!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) +!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) !1 = !DIFile(filename: "debug-dead-local-var.c", directory: "/usr/local/google/home/echristo") !2 = !{} !3 = !{!4, !9} @@ -49,4 +49,3 @@ attributes #0 = { nounwind readnone uwtable "less-precise-fpmad"="false" "no-fra !19 = !{i32 2, !"Debug Info Version", i32 3} !20 = !{!"clang version 3.5.0 (trunk 209255) (llvm/trunk 209253)"} !21 = !DILocation(line: 13, scope: !4) -!22 = !{!14} diff --git a/llvm/test/DebugInfo/X86/gnu-public-names.ll b/llvm/test/DebugInfo/X86/gnu-public-names.ll index 45b6b27..584c879 100644 --- a/llvm/test/DebugInfo/X86/gnu-public-names.ll +++ b/llvm/test/DebugInfo/X86/gnu-public-names.ll @@ -123,6 +123,17 @@ ; CHECK: DW_AT_linkage_name ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "global_namespace_function" + +; CHECK: DW_TAG_subprogram +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_name {{.*}} "f3" +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: [[F3_Z:.*]]: DW_TAG_variable +; CHECK-NOT: DW_TAG +; CHECK: DW_AT_name {{.*}} "z" +; CHECK-NOT: {{DW_TAG|NULL}} +; CHECK: DW_AT_location +; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: NULL ; CHECK-NOT: {{DW_TAG|NULL}} @@ -183,18 +194,6 @@ ; CHECK-NOT: DW_TAG ; CHECK: DW_AT_name {{.*}} "global_function" -; CHECK: DW_TAG_subprogram -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name {{.*}} "f3" -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[F3_Z:.*]]: DW_TAG_variable -; CHECK-NOT: DW_TAG -; CHECK: DW_AT_name {{.*}} "z" -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_location -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: NULL - ; CHECK-LABEL: .debug_gnu_pubnames contents: ; CHECK-NEXT: length = {{.*}} version = 0x0002 unit_offset = 0x00000000 unit_size = {{.*}} ; CHECK-NEXT: Offset Linkage Kind Name @@ -202,12 +201,12 @@ ; CHECK-NEXT: [[NS]] EXTERNAL TYPE "ns" ; CHECK-NEXT: [[OUTER_ANON_C]] STATIC VARIABLE "outer::(anonymous namespace)::c" ; CHECK-NEXT: [[ANON_I]] STATIC VARIABLE "(anonymous namespace)::i" -; CHECK-NEXT: [[ANON]] EXTERNAL TYPE "(anonymous namespace)" ; GCC Doesn't put local statics in pubnames, but it seems not unreasonable and ; comes out naturally from LLVM's implementation, so I'm OK with it for now. If ; it's demonstrated that this is a major size concern or degrades debug info ; consumer behavior, feel free to change it. ; CHECK-NEXT: [[F3_Z]] STATIC VARIABLE "f3::z" +; CHECK-NEXT: [[ANON]] EXTERNAL TYPE "(anonymous namespace)" ; CHECK-NEXT: [[OUTER_ANON]] EXTERNAL TYPE "outer::(anonymous namespace)" ; CHECK-NEXT: [[ANON_INNER_B]] STATIC VARIABLE "(anonymous namespace)::inner::b" ; CHECK-NEXT: [[OUTER]] EXTERNAL TYPE "outer" diff --git a/llvm/test/DebugInfo/X86/lexical-block-file.ll b/llvm/test/DebugInfo/X86/lexical-block-file.ll deleted file mode 100644 index a03a01e..0000000 --- a/llvm/test/DebugInfo/X86/lexical-block-file.ll +++ /dev/null @@ -1,89 +0,0 @@ -; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s - -;; This test checks that Inlined DILexicalBlockFile with local decl entry is -;; skipped and only one DW_TAG_lexical_block is generated. -;; -;; This test was generated by running following command: -;; clang -cc1 -O0 -debug-info-kind=limited -emit-llvm test.cpp -;; Where test.cpp -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;static __attribute__((always_inline)) int bar() { -;; { -;;#line 2 "test.h" -;; static int x = 0; -;; return x; -;; } -;;} -;;int foo() { -;; { -;; return bar(); -;; } -;;} -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; Abstract "bar" function -; CHECK: [[Offset_bar:0x[0-9abcdef]+]]: DW_TAG_subprogram -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "bar" -; CHECK: DW_AT_inline - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_LB:0x[0-9abcdef]+]]: DW_TAG_lexical_block - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_x:0x[0-9abcdef]+]]: DW_TAG_variable -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "x" - - -; CHECK: DW_TAG_subprogram -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "foo" -; CHECK-NOT: {{NULL}} - -;; Inlined "bar" function -; CHECK: DW_TAG_inlined_subroutine -; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]} - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_lexical_block -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_abstract_origin {{.*}} {[[Offset_LB]]} - - -@bar.x = internal global i32 0, align 4 - -; Function Attrs: nounwind -define i32 @foo() #0 !dbg !4 { -entry: - %0 = load i32, i32* @bar.x, align 4, !dbg !16 - ret i32 %0, !dbg !19 -} - -attributes #0 = { nounwind } - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!14} -!llvm.ident = !{!15} - -!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) -!1 = !DIFile(filename: "test.c", directory: "/") -!2 = !{} -!3 = !{!4, !9} -!4 = distinct !DISubprogram(name: "foo", scope: !5, file: !5, line: 6, type: !6, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: false, variables: !2) -!5 = !DIFile(filename: "test.h", directory: "/") -!6 = !DISubroutineType(types: !7) -!7 = !{!8} -!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -!9 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !6, isLocal: true, isDefinition: true, scopeLine: 2, isOptimized: false, variables: !2) -!10 = !{!11} -!11 = !DIGlobalVariable(name: "x", scope: !12, file: !5, line: 2, type: !8, isLocal: true, isDefinition: true, variable: i32* @bar.x) -!12 = !DILexicalBlockFile(scope: !13, file: !5, discriminator: 0) -!13 = distinct !DILexicalBlock(scope: !9, file: !1, line: 3) -!14 = !{i32 2, !"Debug Info Version", i32 3} -!15 = !{!"clang version 3.9.0 (trunk 263423)"} -!16 = !DILocation(line: 3, scope: !12, inlinedAt: !17) -!17 = distinct !DILocation(line: 8, scope: !18) -!18 = distinct !DILexicalBlock(scope: !4, file: !5, line: 7) -!19 = !DILocation(line: 8, scope: !18) diff --git a/llvm/test/DebugInfo/X86/lexical-block-inline.ll b/llvm/test/DebugInfo/X86/lexical-block-inline.ll deleted file mode 100644 index caf51bc..0000000 --- a/llvm/test/DebugInfo/X86/lexical-block-inline.ll +++ /dev/null @@ -1,198 +0,0 @@ -; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s -; RUN: llc -mtriple=x86_64-unknown-linux-gnu -split-dwarf=Enable -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info.dwo - | FileCheck %s - -;; This test checks the following: -;; 1. Useless lexical block entry is not emitted. -;; 2. Function static variable, typedef, records (structure, class and union) -;; that are defined in lexical basic block are emitted as children to -;; these lexical blocks. -;; * For typedef and record check that both are emitted in lexical block -;; where they are declared and not in the one where they are used. -;; 3. "bar" function, which was inlined into "foo" function, is created as -;; abstract (with DW_AT_inline attribute). -;; All variables and types are defined in this abstract entry. -;; 4. "bar" function is created in "foo" function as inlined function -;; (with DW_TAG_inlined_subroutine attribute), and all its local variables -;; are created as concrete variables pointing to the abstract suitable entry -;; defined under abstract "bar" function. -;; 5. Lexical block entries created in the inline "bar" function entry have -;; "DW_AT_abstract_origin" attribute pointing to the equivalent abstract -;; lexical block entry. -;; -;; This test was generated by running following command: -;; clang -cc1 -O0 -g -emit-llvm foo.cpp -o - | opt -S -inline -sroa -;; Where foo.cpp -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;__inline int bar(int s) { -;; { -;; { -;; struct X { -;; int x; -;; }; -;; typedef int Y; -;; { -;; X a = { s }; -;; Y b(s); -;; static int c = 0; -;; return a.x + b + c++; -;; } -;; } -;; } -;;} -;; -;; -;;int foo(int i) { -;; return -;; bar(i); -;;} -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; CHECK: [[Offset_bar:0x[0-9abcdef]+]]: DW_TAG_subprogram -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "bar" -; CHECK: DW_AT_inline -; CHECK-NOT: NULL -; CHECK: DW_TAG_lexical_block - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_LB2:0x[0-9abcdef]+]]: DW_TAG_lexical_block - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_a:0x[0-9abcdef]+]]: DW_TAG_variable -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "a" - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_b:0x[0-9abcdef]+]]: DW_TAG_variable -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "b" - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_c:0x[0-9abcdef]+]]: DW_TAG_variable -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "c" -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_location - -; CHECK-NOT: {{DW_TAG}} -; CHECK: NULL - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_X:0x[0-9abcdef]+]]: DW_TAG_structure_type -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "X" -; CHECK: NULL - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_Y:0x[0-9abcdef]+]]: DW_TAG_typedef -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "Y" - -; CHECK-NOT: {{DW_TAG}} -; CHECK: NULL - - -; CHECK: DW_TAG_subprogram -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "foo" -; CHECK-NOT: {{NULL}} -; CHECK: DW_TAG_inlined_subroutine -; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]} - -; CHECK-NOT: {{NULL}} -; CHECK: DW_TAG_lexical_block - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_lexical_block -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_abstract_origin {{.*}} {[[Offset_LB2]]} - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location -; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_a]]} - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location -; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_b]]} - -; CHECK-NOT: {{DW_TAG}} -; CHECK: NULL - -; CHECK-NOT: {{DW_TAG}} -; CHECK: NULL - -%struct.X = type { i32 } - -$_ZZ3bariE1c = comdat any - -@_ZZ3bariE1c = linkonce_odr global i32 0, comdat, align 4 - -; Function Attrs: nounwind -define i32 @_Z3fooi(i32 %i) #0 !dbg !15 { -entry: - call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !22, metadata !23), !dbg !24 - call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !25, metadata !23), !dbg !26 - call void @llvm.dbg.declare(metadata %struct.X* undef, metadata !28, metadata !23), !dbg !29 - call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !28, metadata !23), !dbg !29 - call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !30, metadata !23), !dbg !31 - %add.i = add nsw i32 %i, %i, !dbg !32 - %0 = load i32, i32* @_ZZ3bariE1c, align 4, !dbg !32 - %inc.i = add nsw i32 %0, 1, !dbg !32 - store i32 %inc.i, i32* @_ZZ3bariE1c, align 4, !dbg !32 - %add2.i = add nsw i32 %add.i, %0, !dbg !32 - ret i32 %add2.i, !dbg !33 -} - -; Function Attrs: nounwind readnone -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -; Function Attrs: nounwind readnone -declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 - -attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { nounwind readnone } - -!llvm.dbg.cu = !{!0, !34} -!llvm.module.flags = !{!19, !20} -!llvm.ident = !{!21} - -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !14, globals: !16) -!1 = !DIFile(filename: "foo.cpp", directory: "/") -!2 = !{} -!3 = !{!4, !13} -!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !11, identifier: "_ZTSZ3bariE1X") -!5 = distinct !DILexicalBlock(scope: !6, file: !1, line: 3) -!6 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2) -!7 = distinct !DISubprogram(name: "bar", linkageName: "_Z3bari", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !2) -!8 = !DISubroutineType(types: !9) -!9 = !{!10, !10} -!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -!11 = !{!12} -!12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !"_ZTSZ3bariE1X", file: !1, line: 5, baseType: !10, size: 32, align: 32) -!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !10) -!14 = !{!15, !7} -!15 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 19, type: !8, isLocal: false, isDefinition: true, scopeLine: 19, flags: DIFlagPrototyped, isOptimized: false, variables: !2) -!16 = !{!17} -!17 = !DIGlobalVariable(name: "c", scope: !18, file: !1, line: 11, type: !10, isLocal: false, isDefinition: true, variable: i32* @_ZZ3bariE1c) -!18 = distinct !DILexicalBlock(scope: !5, file: !1, line: 8) -!19 = !{i32 2, !"Dwarf Version", i32 4} -!20 = !{i32 2, !"Debug Info Version", i32 3} -!21 = !{!"clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)"} -!22 = !DILocalVariable(name: "i", arg: 1, scope: !15, file: !1, line: 19, type: !10) -!23 = !DIExpression() -!24 = !DILocation(line: 19, scope: !15) -!25 = !DILocalVariable(name: "s", arg: 1, scope: !7, file: !1, line: 1, type: !10) -!26 = !DILocation(line: 1, scope: !7, inlinedAt: !27) -!27 = distinct !DILocation(line: 21, scope: !15) -!28 = !DILocalVariable(name: "a", scope: !18, file: !1, line: 9, type: !"_ZTSZ3bariE1X") -!29 = !DILocation(line: 9, scope: !18, inlinedAt: !27) -!30 = !DILocalVariable(name: "b", scope: !18, file: !1, line: 10, type: !13) -!31 = !DILocation(line: 10, scope: !18, inlinedAt: !27) -!32 = !DILocation(line: 12, scope: !18, inlinedAt: !27) -!33 = !DILocation(line: 20, scope: !15) - -; This line is manually added to check that the test does not crash when having -; more than one compile unit! -!34 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !2, globals: !2) diff --git a/llvm/test/DebugInfo/X86/lexical-block.ll b/llvm/test/DebugInfo/X86/lexical-block.ll deleted file mode 100644 index 5f8ed34..0000000 --- a/llvm/test/DebugInfo/X86/lexical-block.ll +++ /dev/null @@ -1,131 +0,0 @@ -; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s - -;; This test checks the following: -;; 1. Useless lexical block entry is not emitted. -;; 2. Function static variable, typedef, records (structure, class and union) -;; that are defined in lexical basic block are emitted as children to -;; these lexical blocks. -;; * For typedef and record check that both are emitted in lexical block -;; where they are declared and not in the one where they are used. -;; -;; This test was generated by running following command: -;; clang -cc1 -O0 -g -emit-llvm foo.cpp -;; Where foo.cpp -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;int foo(void) { -;; { -;; { -;; struct X { -;; int x; -;; }; -;; typedef int Y; -;; { -;; X a; -;; Y b; -;; static int c; -;; return a.x + b + c; -;; } -;; } -;; } -;;} -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -; CHECK: DW_TAG_subprogram -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "foo" -; CHECK-NOT: NULL -; CHECK: DW_TAG_lexical_block - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_lexical_block - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_variable -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "a" - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_variable -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "b" - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_variable -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "c" - -; CHECK-NOT: {{DW_TAG}} -; CHECK: NULL - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_structure_type -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "X" -; CHECK: NULL - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_typedef -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "Y" - -; CHECK-NOT: {{DW_TAG}} -; CHECK: NULL - -%struct.X = type { i32 } - -@_ZZ3foovE1c = internal global i32 0, align 4 - -; Function Attrs: nounwind -define i32 @_Z3foov() #0 !dbg !7 { -entry: - %a = alloca %struct.X, align 4 - %b = alloca i32, align 4 - call void @llvm.dbg.declare(metadata %struct.X* %a, metadata !21, metadata !22), !dbg !23 - call void @llvm.dbg.declare(metadata i32* %b, metadata !24, metadata !22), !dbg !25 - %x = getelementptr inbounds %struct.X, %struct.X* %a, i32 0, i32 0, !dbg !26 - %0 = load i32, i32* %x, align 4, !dbg !26 - %1 = load i32, i32* %b, align 4, !dbg !26 - %add = add nsw i32 %0, %1, !dbg !26 - %2 = load i32, i32* @_ZZ3foovE1c, align 4, !dbg !26 - %add1 = add nsw i32 %add, %2, !dbg !26 - ret i32 %add1, !dbg !26 -} - -; Function Attrs: nounwind readnone -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { nounwind readnone } - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!18, !19} -!llvm.ident = !{!20} - -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.7.0 (trunk 237245)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !14, globals: !15, imports: !2) -!1 = !DIFile(filename: "foo.cpp", directory: "/") -!2 = !{} -!3 = !{!4, !13} -!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !11) -!5 = distinct !DILexicalBlock(scope: !6, file: !1, line: 3) -!6 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2) -!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !2) -!8 = !DISubroutineType(types: !9) -!9 = !{!10} -!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -!11 = !{!12} -!12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !4, file: !1, line: 5, baseType: !10, size: 32, align: 32) -!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !10) -!14 = !{!7} -!15 = !{!16} -!16 = !DIGlobalVariable(name: "c", scope: !17, file: !1, line: 11, type: !10, isLocal: true, isDefinition: true, variable: i32* @_ZZ3foovE1c) -!17 = distinct !DILexicalBlock(scope: !5, file: !1, line: 8) -!18 = !{i32 2, !"Dwarf Version", i32 4} -!19 = !{i32 2, !"Debug Info Version", i32 3} -!20 = !{!"clang version 3.7.0 (trunk 237245)"} -!21 = !DILocalVariable(name: "a", scope: !17, file: !1, line: 9, type: !4) -!22 = !DIExpression() -!23 = !DILocation(line: 9, scope: !17) -!24 = !DILocalVariable(name: "b", scope: !17, file: !1, line: 10, type: !13) -!25 = !DILocation(line: 10, scope: !17) -!26 = !DILocation(line: 12, scope: !17) diff --git a/llvm/test/DebugInfo/X86/subprogram-inline.ll b/llvm/test/DebugInfo/X86/subprogram-inline.ll deleted file mode 100644 index 1442a98..0000000 --- a/llvm/test/DebugInfo/X86/subprogram-inline.ll +++ /dev/null @@ -1,169 +0,0 @@ -; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s -; RUN: llc -mtriple=x86_64-unknown-linux-gnu -split-dwarf=Enable -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info.dwo - | FileCheck %s - -;; This test checks the following: -;; 2. Function static variable, typedef, records (structure, class and union) -;; that are defined in lexical function scope are emitted as children to -;; the function scope, directly. -;; 3. "bar" function, which was inlined into "foo" function, is created as -;; abstract (with DW_AT_inline attribute). -;; All variables and types are defined in this abstract entry. -;; 4. "bar" function is created in "foo" function as inlined function -;; (with DW_TAG_inlined_subroutine attribute), and all its local variables -;; are created as concrete variables pointing to the abstract suitable entry -;; defined under abstract "bar" function. -;; -;; This test was generated by running following command: -;; clang -cc1 -O0 -g -emit-llvm foo.cpp -o - | opt -S -inline -sroa -;; Where foo.cpp -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;__inline int bar(int s) { -;; -;; -;; struct X { -;; int x; -;; }; -;; typedef int Y; -;; -;; X a = { s }; -;; Y b(s); -;; static int c = 0; -;; return a.x + b + c++; -;; -;; -;; -;;} -;; -;; -;;int foo(int i) { -;; return -;; bar(i); -;;} -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; CHECK: [[Offset_bar:0x[0-9abcdef]+]]: DW_TAG_subprogram -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "bar" -; CHECK: DW_AT_inline -; CHECK-NOT: NULL - -; CHECK: [[Offset_a:0x[0-9abcdef]+]]: DW_TAG_variable -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "a" - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_b:0x[0-9abcdef]+]]: DW_TAG_variable -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "b" - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_c:0x[0-9abcdef]+]]: DW_TAG_variable -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "c" -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_location - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_X:0x[0-9abcdef]+]]: DW_TAG_structure_type -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "X" -; CHECK: NULL - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: [[Offset_Y:0x[0-9abcdef]+]]: DW_TAG_typedef -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "Y" - -; CHECK-NOT: {{DW_TAG}} -; CHECK: NULL - - -; CHECK: DW_TAG_subprogram -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_AT_name {{.*}} "foo" -; CHECK-NOT: {{NULL}} -; CHECK: DW_TAG_inlined_subroutine -; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]} - -; CHECK-NOT: {{NULL}} -; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location -; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_a]]} - -; CHECK-NOT: {{DW_TAG|NULL}} -; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_location -; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_b]]} - -; CHECK-NOT: {{DW_TAG}} -; CHECK: NULL - -%struct.X = type { i32 } - -$_ZZ3bariE1c = comdat any - -@_ZZ3bariE1c = linkonce_odr global i32 0, comdat, align 4 - -; Function Attrs: nounwind -define i32 @_Z3fooi(i32 %i) #0 !dbg !13 { -entry: - call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !18, metadata !19), !dbg !20 - call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !21, metadata !19), !dbg !22 - call void @llvm.dbg.declare(metadata %struct.X* undef, metadata !24, metadata !19), !dbg !25 - call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !24, metadata !19), !dbg !25 - call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !26, metadata !19), !dbg !27 - %add.i = add nsw i32 %i, %i, !dbg !28 - %0 = load i32, i32* @_ZZ3bariE1c, align 4, !dbg !28 - %inc.i = add nsw i32 %0, 1, !dbg !28 - store i32 %inc.i, i32* @_ZZ3bariE1c, align 4, !dbg !28 - %add2.i = add nsw i32 %add.i, %0, !dbg !28 - ret i32 %add2.i, !dbg !29 -} - -; Function Attrs: nounwind readnone -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -; Function Attrs: nounwind readnone -declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 - -attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { nounwind readnone } - -!llvm.dbg.cu = !{!0, !30} -!llvm.module.flags = !{!16} -!llvm.ident = !{!17} - -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 256818)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !12, globals: !14) -!1 = !DIFile(filename: "foo.cpp", directory: "/") -!2 = !{} -!3 = !{!4, !11} -!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !9, identifier: "_ZTSZ3bariE1X") -!5 = distinct !DISubprogram(name: "bar", linkageName: "_Z3bari", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !2) -!6 = !DISubroutineType(types: !7) -!7 = !{!8, !8} -!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -!9 = !{!10} -!10 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !"_ZTSZ3bariE1X", file: !1, line: 5, baseType: !8, size: 32, align: 32) -!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !8) -!12 = !{!13, !5} -!13 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 19, type: !6, isLocal: false, isDefinition: true, scopeLine: 19, flags: DIFlagPrototyped, isOptimized: false, variables: !2) -!14 = !{!15} -!15 = !DIGlobalVariable(name: "c", scope: !5, file: !1, line: 11, type: !8, isLocal: false, isDefinition: true, variable: i32* @_ZZ3bariE1c) -!16 = !{i32 2, !"Debug Info Version", i32 3} -!17 = !{!"clang version 3.8.0 (trunk 256818)"} -!18 = !DILocalVariable(name: "i", arg: 1, scope: !13, file: !1, line: 19, type: !8) -!19 = !DIExpression() -!20 = !DILocation(line: 19, scope: !13) -!21 = !DILocalVariable(name: "s", arg: 1, scope: !5, file: !1, line: 1, type: !8) -!22 = !DILocation(line: 1, scope: !5, inlinedAt: !23) -!23 = distinct !DILocation(line: 21, scope: !13) -!24 = !DILocalVariable(name: "a", scope: !5, file: !1, line: 9, type: !"_ZTSZ3bariE1X") -!25 = !DILocation(line: 9, scope: !5, inlinedAt: !23) -!26 = !DILocalVariable(name: "b", scope: !5, file: !1, line: 10, type: !11) -!27 = !DILocation(line: 10, scope: !5, inlinedAt: !23) -!28 = !DILocation(line: 12, scope: !5, inlinedAt: !23) -!29 = !DILocation(line: 20, scope: !13) - -; This line is manually added to check that the test does not crash when having -; more than one compile unit! -!30 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !2, globals: !2) -- 2.7.4