Reverting 268054 & 268063 as they caused PR27579.

llvm-svn: 268150
This commit is contained in:
Amjad Aboud 2016-04-30 01:44:07 +00:00
parent 0d28098245
commit bc689dbffb
20 changed files with 86 additions and 894 deletions

View File

@ -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<DILocalScope>(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());
@ -342,15 +336,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<DIImportedEntity>(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()));
@ -365,7 +367,6 @@ void DwarfCompileUnit::constructScopeDIE(
ScopeDIE->addChild(std::move(I));
FinalChildren.push_back(std::move(ScopeDIE));
addLocalScopeDieToLexicalScope(Scope, ScopeDIE);
}
DIE::value_iterator
@ -558,37 +559,20 @@ DIE *DwarfCompileUnit::constructVariableDIE(DbgVariable &DV,
DIE *DwarfCompileUnit::createScopeChildrenDIE(LexicalScope *Scope,
SmallVectorImpl<DIE *> &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<DIImportedEntity>(DI))
D = getOrCreateImportedEntityDIE(IE);
else if (auto *GV = dyn_cast<DIGlobalVariable>(DI))
D = getOrCreateGlobalVariableDIE(GV);
else if (auto *RT = dyn_cast<DIType>(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;
}
@ -630,8 +614,6 @@ DIE *DwarfCompileUnit::createAndAddScopeChildren(LexicalScope *Scope,
for (auto &I : Children)
ScopeDIE.addChild(std::move(I));
addLocalScopeDieToLexicalScope(Scope, &ScopeDIE);
return ObjectPointer;
}
@ -668,20 +650,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<DINamespace>(Entity))
@ -708,46 +680,23 @@ 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<DISubprogram>(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::emitHeader(bool UseOffsets) {
// Don't bother labeling the .dwo unit, as its offset isn't used.
if (!Skeleton) {
@ -863,32 +812,6 @@ void DwarfCompileUnit::applySubprogramAttributesToDefinition(
addGlobalName(SP->getName(), SPDie, Context);
}
void DwarfCompileUnit::addLocalScopeDieToLexicalScope(LexicalScope *LS,
DIE *D) {
const DILocalScope *Scope = LS->getScopeNode();
assert(!isa<DILexicalBlockFile>(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;
}
void DwarfCompileUnit::addLocalDclDieToLexicalScope(LexicalScope *LS, DIE *D) {
const DILocalScope *Scope = LS->getScopeNode();
assert(!isa<DILexicalBlockFile>(Scope) && "Don't expect Lexical Block File!");
auto &LSInfo = getLSDieInfoMap()[Scope];
LSInfo.LocalDclDies.insert(D);
}
bool DwarfCompileUnit::isDwoUnit() const {
return DD->useSplitDwarf() && Skeleton;
}

View File

@ -15,7 +15,6 @@
#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
#include "DwarfUnit.h"
#include "llvm/ADT/SetVector.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<const MDNode *, 8> LocalDeclNodeList;
typedef llvm::DenseMap<const MDNode *, LocalDeclNodeList> LocalScopesMap;
typedef llvm::SmallVector<const MDNode *, 8> ImportedEntityList;
typedef llvm::DenseMap<const MDNode *, ImportedEntityList>
ImportedEntityMap;
LocalScopesMap LocalDeclNodes;
ImportedEntityMap ImportedEntities;
/// GlobalNames - A map of globally visible named entities for this unit.
StringMap<const DIE *> GlobalNames;
@ -71,15 +71,6 @@ class DwarfCompileUnit : public DwarfUnit {
// ranges/locs.
const MCSymbol *BaseAddress;
struct LocalScopeDieInfo {
DIE *ConcreteLSDie = nullptr;
DIE *AbstractLSDie = nullptr;
SetVector<DIE *> InlineLSDies;
SetVector<DIE *> LocalDclDies;
};
// Collection of local scope DIE info.
DenseMap<const MDNode *, LocalScopeDieInfo> LocalScopeDieInfoMap;
/// \brief Construct a DIE for the given DbgVariable without initializing the
/// DbgVariable's DIE reference.
DIE *constructVariableDIEImpl(const DbgVariable &DV, bool Abstract);
@ -126,14 +117,15 @@ public:
unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;
void addLocalDeclNode(const DINode *DI, DILocalScope *Scope) {
void addImportedEntity(const DIImportedEntity* IE) {
DIScope *Scope = IE->getScope();
assert(Scope && "Invalid Scope encoding!");
if (!isa<DILocalScope>(Scope))
// No need to add imported enities that are not local declaration.
return;
auto *LocalScope = cast<DILocalScope>(Scope)->getNonLexicalBlockFileScope();
LocalDeclNodes[LocalScope].push_back(DI);
ImportedEntities[LocalScope].push_back(IE);
}
/// addRange - Add an address range to the list of ranges for this unit.
@ -181,7 +173,7 @@ public:
/// A helper function to create children of a Scope DIE.
DIE *createScopeChildrenDIE(LexicalScope *Scope,
SmallVectorImpl<DIE *> &Children,
bool *HasNonScopeChildren = nullptr);
unsigned *ChildScopeCount = nullptr);
/// \brief Construct a DIE for this subprogram scope.
void constructSubprogramScopeDIE(LexicalScope *Scope);
@ -190,15 +182,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();
/// Set the skeleton unit associated with this unit.
void setSkeleton(DwarfCompileUnit &Skel) { Skeleton = &Skel; }
@ -270,15 +258,6 @@ public:
void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; }
const MCSymbol *getBaseAddress() const { return BaseAddress; }
DenseMap<const MDNode *, LocalScopeDieInfo> &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

View File

@ -457,16 +457,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<DILocalScope>(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.
@ -488,8 +478,9 @@ void DwarfDebug::beginModule() {
for (DICompileUnit *CUNode : M->debug_compile_units()) {
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);
for (auto *Ty : CUNode->getEnumTypes()) {
// The enum types array by design contains pointers to
@ -499,18 +490,14 @@ void DwarfDebug::beginModule() {
for (auto *Ty : CUNode->getRetainedTypes()) {
// The retained types array by design contains pointers to
// MDNodes rather than DIRefs. Unique them here.
if (DIType *RT = dyn_cast<DIType>(Ty)) {
if (RT->isExternalTypeRef())
if (DIType *RT = dyn_cast<DIType>(Ty))
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);
}
}
@ -551,18 +538,11 @@ void DwarfDebug::finishSubprogramDefinitions() {
});
}
void DwarfDebug::finishLocalScopeDefinitions() {
for (const auto &I : CUMap)
I.second->finishLocalScopeDefinitions();
}
void DwarfDebug::finalizeModuleInfo() {
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
finishSubprogramDefinitions();
finishLocalScopeDefinitions();
finishVariableDefinitions();
// Handle anything that needs to be done on a per-unit basis after
@ -1178,9 +1158,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);
}

View File

@ -206,10 +206,6 @@ class DwarfDebug : public DebugHandlerBase {
/// Size of each symbol emitted (for those symbols that have a specific size).
DenseMap<const MCSymbol *, uint64_t> SymSize;
/// Holder for scopes containing local declaration DI nodes per DI function.
DenseMap<const DISubprogram *, SmallPtrSet<const DILocalScope *, 16>>
LocalScopesMap;
/// Collection of abstract variables.
DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables;
SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;
@ -320,8 +316,6 @@ class DwarfDebug : public DebugHandlerBase {
void finishSubprogramDefinitions();
void finishLocalScopeDefinitions();
/// Finish off debug information after all functions have been
/// processed.
void finalizeModuleInfo();
@ -420,11 +414,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.
@ -563,12 +552,6 @@ public:
SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() {
return ProcessedSPNodes;
}
/// Return collection of function scopes that contains local declararion DIEs.
SmallPtrSet<const DILocalScope *, 16> &
getLocalScopes(const DISubprogram *SP) {
return LocalScopesMap[SP];
}
};
} // End of namespace llvm

View File

@ -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;
}
@ -730,18 +725,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<DILocalScope>(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);

View File

@ -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);

View File

@ -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, unit: !4, 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: FullDebug, file: !38, enums: !39, retainedTypes: !41, imports: null)
!4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang 1.5", isOptimized: false, emissionKind: FullDebug, file: !38, enums: !39, retainedTypes: !39, 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}

View File

@ -27,7 +27,7 @@ entry:
!0 = distinct !DISubprogram(name: "foo", line: 9, isLocal: true, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !2, 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: FullDebug, file: !27, enums: !20, retainedTypes: !61, 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: FullDebug, file: !27, enums: !20, retainedTypes: !20, 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)

View File

@ -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
@ -69,25 +69,12 @@
; CHECK-NEXT: DW_AT_import{{.*}}=> {[[NS1]]})
; CHECK-NOT: NULL
; 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

View File

@ -27,7 +27,7 @@ entry:
!0 = distinct !DISubprogram(name: "foo", line: 9, isLocal: true, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !2, 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: FullDebug, file: !27, enums: !20, retainedTypes: !61, 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: FullDebug, file: !27, enums: !20, retainedTypes: !20, 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)

View File

@ -27,7 +27,7 @@ entry:
!0 = distinct !DISubprogram(name: "foo", line: 9, isLocal: true, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !2, 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: FullDebug, file: !27, enums: !20, retainedTypes: !111, 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: FullDebug, file: !27, enums: !20, retainedTypes: !20, 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)

View File

@ -1,66 +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 -debug-info-kind=limited -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: FullDebug, enums: !2, retainedTypes: !3)
!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, unit: !0, 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)
!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, unit: !0, 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)

View File

@ -7,7 +7,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)

View File

@ -30,7 +30,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: FullDebug, file: !1, enums: !2, retainedTypes: !22, 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: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
!1 = !DIFile(filename: "debug-dead-local-var.c", directory: "/usr/local/google/home/echristo")
!2 = !{}
!4 = distinct !DISubprogram(name: "bar", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !0, scopeLine: 11, file: !1, scope: !5, type: !6, variables: !2)
@ -51,4 +51,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}

View File

@ -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"

View File

@ -32,6 +32,8 @@
; CHECK: DW_TAG_lexical_block
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: DW_TAG_variable
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: DW_TAG_imported_module
;; Abstract "bar" function
; CHECK: [[Offset_bar]]: DW_TAG_subprogram
@ -58,6 +60,8 @@
; CHECK: DW_TAG_lexical_block
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: DW_TAG_variable
; CHECK-NOT: {{DW_TAG|NULL}}
; CHECK: DW_TAG_imported_module
; Function Attrs: alwaysinline nounwind

View File

@ -1,88 +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: FullDebug, enums: !2, globals: !10)
!1 = !DIFile(filename: "test.c", directory: "/")
!2 = !{}
!4 = distinct !DISubprogram(name: "foo", scope: !5, file: !5, line: 6, type: !6, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: false, unit: !0, 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, unit: !0, 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)

View File

@ -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 -debug-info-kind=limited -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: FullDebug, enums: !2, retainedTypes: !3, 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, unit: !0, 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: !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 = !{!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, unit: !0, 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: !4)
!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: FullDebug, enums: !2, retainedTypes: !2, globals: !2)

View File

@ -1,130 +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 -debug-info-kind=limited -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: FullDebug, enums: !2, retainedTypes: !3, 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, unit: !0, 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)
!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)

View File

@ -1,168 +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 -debug-info-kind=limited -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: FullDebug, enums: !2, retainedTypes: !3, 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, unit: !0, 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: !4, 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)
!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, unit: !0, 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: !4)
!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: FullDebug, enums: !2, retainedTypes: !2, globals: !2)