llvm.org GIT mirror llvm / 13126c3
Recommitted r261633 "Supporting all entities declared in lexical scope in LLVM debug info." After fixing PR26715 at r263379. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263424 91177308-0d34-0410-b5e6-96231b3b80d8 Amjad Aboud 4 years ago
20 changed file(s) with 817 addition(s) and 93 deletion(s). Raw diff Collapse all Expand all
113113
114114 // Construct the context before querying for the existence of the DIE in
115115 // case such construction creates the DIE.
116 DIE *ContextDIE = getOrCreateContextDIE(GVContext);
117
118 // Add to map.
119 DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV);
116 // For Local Scope, do not construct context DIE.
117 bool IsLocalScope = GVContext && isa(GVContext);
118 DIE *ContextDIE = IsLocalScope ? nullptr : getOrCreateContextDIE(GVContext);
119 assert(ContextDIE || IsLocalScope);
120
121 // Create new global variable and add to map.
122 DIE *VariableDIE = IsLocalScope
123 ? createDIE(GV->getTag(), GV)
124 : &createAndAddDIE(GV->getTag(), *ContextDIE, GV);
125
120126 DIScope *DeclContext;
121127 if (auto *SDMDecl = GV->getStaticDataMemberDeclaration()) {
122128 DeclContext = resolve(SDMDecl->getScope());
334340 if (DD->isLexicalScopeDIENull(Scope))
335341 return;
336342
337 unsigned ChildScopeCount;
343 bool HasNonScopeChildren;
338344
339345 // We create children here when we know the scope DIE is not going to be
340346 // null and the children will be added to the scope DIE.
341 createScopeChildrenDIE(Scope, Children, &ChildScopeCount);
342
343 // Skip imported directives in gmlt-like data.
344 if (!includeMinimalInlineScopes()) {
345 // There is no need to emit empty lexical block DIE.
346 for (const auto *IE : ImportedEntities[DS])
347 Children.push_back(
348 constructImportedEntityDIE(cast(IE)));
349 }
347 createScopeChildrenDIE(Scope, Children, &HasNonScopeChildren);
350348
351349 // If there are only other scopes as children, put them directly in the
352350 // parent instead, as this scope would serve no purpose.
353 if (Children.size() == ChildScopeCount) {
351 if (!HasNonScopeChildren) {
354352 FinalChildren.insert(FinalChildren.end(),
355353 std::make_move_iterator(Children.begin()),
356354 std::make_move_iterator(Children.end()));
365363 ScopeDIE->addChild(std::move(I));
366364
367365 FinalChildren.push_back(std::move(ScopeDIE));
366 addLocalScopeDieToLexicalScope(Scope, ScopeDIE);
368367 }
369368
370369 DIE::value_iterator
557556
558557 DIE *DwarfCompileUnit::createScopeChildrenDIE(LexicalScope *Scope,
559558 SmallVectorImpl &Children,
560 unsigned *ChildScopeCount) {
559 bool *HasNonScopeChildren) {
561560 DIE *ObjectPointer = nullptr;
561 bool HasLocalDclDie = false;
562 auto *DS = Scope->getScopeNode();
562563
563564 for (DbgVariable *DV : DU->getScopeVariables().lookup(Scope))
564565 Children.push_back(constructVariableDIE(*DV, *Scope, ObjectPointer));
565566
566 unsigned ChildCountWithoutScopes = Children.size();
567 // Skip local declarations in gmlt-like data.
568 if (!includeMinimalInlineScopes()) {
569 for (const auto *DI : LocalDeclNodes[DS]) {
570 DIE *D = nullptr;
571 if (auto *IE = dyn_cast(DI))
572 D = getOrCreateImportedEntityDIE(IE);
573 else if (auto *GV = dyn_cast(DI))
574 D = getOrCreateGlobalVariableDIE(GV);
575 else if (auto *RT = dyn_cast(DI))
576 D = getOrCreateTypeDIE(RT);
577 else
578 llvm_unreachable("Unexpected DI node!");
579 addLocalDclDieToLexicalScope(Scope, D);
580 HasLocalDclDie = true;
581 }
582 }
583
584 if (HasNonScopeChildren)
585 *HasNonScopeChildren = !Children.empty() || HasLocalDclDie;
567586
568587 for (LexicalScope *LS : Scope->getChildren())
569588 constructScopeDIE(LS, Children);
570
571 if (ChildScopeCount)
572 *ChildScopeCount = Children.size() - ChildCountWithoutScopes;
573589
574590 return ObjectPointer;
575591 }
611627 // Add children
612628 for (auto &I : Children)
613629 ScopeDIE.addChild(std::move(I));
630
631 addLocalScopeDieToLexicalScope(Scope, &ScopeDIE);
614632
615633 return ObjectPointer;
616634 }
648666 addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);
649667 }
650668
669 DIE *DwarfCompileUnit::getOrCreateImportedEntityDIE(
670 const DIImportedEntity *Module) {
671 if (DIE *Die = getDIE(Module))
672 return Die;
673
674 return constructImportedEntityDIE(Module);
675 }
676
651677 DIE *DwarfCompileUnit::constructImportedEntityDIE(
652678 const DIImportedEntity *Module) {
653 DIE *IMDie = DIE::get(DIEValueAllocator, (dwarf::Tag)Module->getTag());
654 insertDIE(Module, IMDie);
679
680 assert(!getDIE(Module));
681
682 DIE *IMDie = createDIE(Module->getTag(), Module);
655683 DIE *EntityDie;
656684 auto *Entity = resolve(Module->getEntity());
657685 if (auto *NS = dyn_cast(Entity))
678706 }
679707
680708 void DwarfCompileUnit::finishSubprogramDefinition(const DISubprogram *SP) {
681 DIE *D = getDIE(SP);
682 if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) {
683 if (D)
709 if (DIE *D = getDIE(SP)) {
710 if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP))
684711 // If this subprogram has an abstract definition, reference that
685712 addDIEEntry(*D, dwarf::DW_AT_abstract_origin, *AbsSPDIE);
686 } else {
687 if (!D && !includeMinimalInlineScopes())
688 // Lazily construct the subprogram if we didn't see either concrete or
689 // inlined versions during codegen. (except in -gmlt ^ where we want
690 // to omit these entirely)
691 D = getOrCreateSubprogramDIE(SP);
692 if (D)
713 else
693714 // And attach the attributes
694715 applySubprogramAttributesToDefinition(SP, *D);
695716 }
696717 }
718
719 void DwarfCompileUnit::finishLocalScopeDefinitions() {
720 for (const auto &I : getLSDieInfoMap()) {
721 auto LSInfo = I.second;
722 // Attach all local dcl DIEs to abstract local scope if available,
723 // otherwise attach it to concrete local scope.
724 DIE *LBDie =
725 LSInfo.AbstractLSDie ? LSInfo.AbstractLSDie : LSInfo.ConcreteLSDie;
726 assert(LBDie || LSInfo.LocalDclDies.empty());
727 for (auto &D : LSInfo.LocalDclDies)
728 LBDie->addChild(std::move(D));
729
730 if (isa(I.first))
731 // For function scope there is nothing else to do.
732 // "abstract_origin" dwarf attribute was added somewhere else.
733 continue;
734
735 if (LSInfo.AbstractLSDie) {
736 // Add "abstract_origin" dwarf attribute to concrete local scope pointing
737 // to the corresponding abstract local scope.
738 if (LSInfo.ConcreteLSDie)
739 addDIEEntry(*LSInfo.ConcreteLSDie, dwarf::DW_AT_abstract_origin,
740 *LSInfo.AbstractLSDie);
741 // Add "abstract_origin" dwarf attribute to inline local scope pointing
742 // to the corresponding abstract local scope.
743 for (auto &L : LSInfo.InlineLSDies)
744 addDIEEntry(*L, dwarf::DW_AT_abstract_origin, *LSInfo.AbstractLSDie);
745 }
746 }
747 }
748
697749 void DwarfCompileUnit::collectDeadVariables(const DISubprogram *SP) {
698750 assert(SP && "CU's subprogram list contains a non-subprogram");
699751 assert(SP->isDefinition() &&
704756
705757 DIE *SPDIE = DU->getAbstractSPDies().lookup(SP);
706758 if (!SPDIE)
707 SPDIE = getDIE(SP);
759 return;
708760 assert(SPDIE);
709761 for (const DILocalVariable *DV : Variables) {
710762 DbgVariable NewVar(DV, /* IA */ nullptr, DD);
829881 addGlobalName(SP->getName(), SPDie, Context);
830882 }
831883
884 void DwarfCompileUnit::addLocalScopeDieToLexicalScope(LexicalScope *LS,
885 DIE *D) {
886 auto &LSInfo = getLSDieInfoMap()[LS->getScopeNode()];
887 if (LS->isAbstractScope()) {
888 assert(!LSInfo.AbstractLSDie && "Adding abstract LS DIE twice.");
889 LSInfo.AbstractLSDie = D;
890 return;
891 }
892 if (LS->getInlinedAt()) {
893 assert(!LSInfo.InlineLSDies.count(D) && "Adding inline LS DIE twice.");
894 LSInfo.InlineLSDies.insert(D);
895 return;
896 }
897 assert(!LSInfo.ConcreteLSDie && "Adding cocncrete LS DIE twice.");
898 LSInfo.ConcreteLSDie = D;
899 return;
900 }
901
902 void DwarfCompileUnit::addLocalDclDieToLexicalScope(LexicalScope *LS, DIE *D) {
903 auto &LSInfo = getLSDieInfoMap()[LS->getScopeNode()];
904 LSInfo.LocalDclDies.insert(D);
905 return;
906 }
907
832908 bool DwarfCompileUnit::isDwoUnit() const {
833909 return DD->useSplitDwarf() && Skeleton;
834910 }
1414 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H
1515
1616 #include "DwarfUnit.h"
17 #include "llvm/ADT/SetVector.h"
1718 #include "llvm/ADT/StringRef.h"
1819 #include "llvm/IR/DebugInfo.h"
1920 #include "llvm/Support/Dwarf.h"
4748 /// The start of the unit macro info within macro section.
4849 MCSymbol *MacroLabelBegin;
4950
50 typedef llvm::SmallVector ImportedEntityList;
51 typedef llvm::DenseMap
52 ImportedEntityMap;
53
54 ImportedEntityMap ImportedEntities;
51 typedef llvm::SmallVector LocalDeclNodeList;
52 typedef llvm::DenseMap LocalScopesMap;
53
54 LocalScopesMap LocalDeclNodes;
5555
5656 /// GlobalNames - A map of globally visible named entities for this unit.
5757 StringMap GlobalNames;
6969 // The base address of this unit, if any. Used for relative references in
7070 // ranges/locs.
7171 const MCSymbol *BaseAddress;
72
73 struct LocalScopeDieInfo {
74 DIE *ConcreteLSDie = nullptr;
75 DIE *AbstractLSDie = nullptr;
76 SetVector InlineLSDies;
77 SetVector LocalDclDies;
78 };
79 // Collection of local scope DIE info.
80 DenseMap LocalScopeDieInfoMap;
7281
7382 /// \brief Construct a DIE for the given DbgVariable without initializing the
7483 /// DbgVariable's DIE reference.
116125
117126 unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override;
118127
119 void addImportedEntity(const DIImportedEntity* IE) {
120 ImportedEntities[IE->getScope()].push_back(IE);
128 void addLocalDeclNode(const DINode *DI, DILocalScope *Scope) {
129 LocalDeclNodes[Scope].push_back(DI);
121130 }
122131
123132 /// addRange - Add an address range to the list of ranges for this unit.
165174 /// A helper function to create children of a Scope DIE.
166175 DIE *createScopeChildrenDIE(LexicalScope *Scope,
167176 SmallVectorImpl &Children,
168 unsigned *ChildScopeCount = nullptr);
177 bool *HasNonScopeChildren = nullptr);
169178
170179 /// \brief Construct a DIE for this subprogram scope.
171180 void constructSubprogramScopeDIE(LexicalScope *Scope);
174183
175184 void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
176185
186 /// \brief Get or create import_module DIE.
187 DIE *getOrCreateImportedEntityDIE(const DIImportedEntity *Module);
177188 /// \brief Construct import_module DIE.
178189 DIE *constructImportedEntityDIE(const DIImportedEntity *Module);
179190
180191 void finishSubprogramDefinition(const DISubprogram *SP);
192
193 void finishLocalScopeDefinitions();
181194
182195 void collectDeadVariables(const DISubprogram *SP);
183196
252265
253266 void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; }
254267 const MCSymbol *getBaseAddress() const { return BaseAddress; }
268
269 DenseMap &getLSDieInfoMap() {
270 return LocalScopeDieInfoMap;
271 }
272
273 /// Add local scope DIE entry to lexical scope info.
274 void addLocalScopeDieToLexicalScope(LexicalScope *LS, DIE *D);
275 /// Add local declaration DIE entry to lexical scope info.
276 void addLocalDclDieToLexicalScope(LexicalScope *LS, DIE *D);
255277 };
256278
257279 } // end llvm namespace
454454 D->addChild(TheCU.constructImportedEntityDIE(N));
455455 }
456456
457 bool DwarfDebug::collectLocalScopedNode(DIScope *S, const DINode *N,
458 DwarfCompileUnit &CU) {
459 if (auto LS = dyn_cast_or_null(S)) {
460 getLocalScopes(LS->getSubprogram()).insert(LS);
461 CU.addLocalDeclNode(N, LS);
462 return true;
463 }
464 return false;
465 }
466
457467 // Emit all Dwarf sections that should come prior to the content. Create
458468 // global DIEs and emit initial debug info sections. This is invoked by
459469 // the target AsmPrinter.
473483 for (MDNode *N : CU_Nodes->operands()) {
474484 auto *CUNode = cast(N);
475485 DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);
476 for (auto *IE : CUNode->getImportedEntities())
477 CU.addImportedEntity(IE);
478486 for (auto *GV : CUNode->getGlobalVariables())
479 CU.getOrCreateGlobalVariableDIE(GV);
487 if (!collectLocalScopedNode(GV->getScope(), GV, CU))
488 CU.getOrCreateGlobalVariableDIE(GV);
480489 for (auto *SP : CUNode->getSubprograms())
481490 SPMap.insert(std::make_pair(SP, &CU));
482491 for (auto *Ty : CUNode->getEnumTypes()) {
488497 // The retained types array by design contains pointers to
489498 // MDNodes rather than DIRefs. Unique them here.
490499 DIType *RT = cast(resolve(Ty->getRef()));
491 if (!RT->isExternalTypeRef())
500 if (RT->isExternalTypeRef())
492501 // There is no point in force-emitting a forward declaration.
502 continue;
503 if (!collectLocalScopedNode(resolve(Ty->getScope()), RT, CU))
493504 CU.getOrCreateTypeDIE(RT);
494505 }
495506 // Emit imported_modules last so that the relevant context is already
496507 // available.
497508 for (auto *IE : CUNode->getImportedEntities())
498 constructAndAddImportedEntityDIE(CU, IE);
509 if (!collectLocalScopedNode(IE->getScope(), IE, CU))
510 constructAndAddImportedEntityDIE(CU, IE);
499511 }
500512
501513 // Tell MMI that we have debug info.
528540 });
529541 }
530542
543 void DwarfDebug::finishLocalScopeDefinitions() {
544 for (const auto &I : CUMap)
545 I.second->finishLocalScopeDefinitions();
546 }
547
531548 // Collect info for variables that were optimized out.
532549 void DwarfDebug::collectDeadVariables() {
533550 const Module *M = MMI->getModule();
552569 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
553570
554571 finishSubprogramDefinitions();
572
573 finishLocalScopeDefinitions();
555574
556575 finishVariableDefinitions();
557576
11631182 assert(LScopes.getAbstractScopesList().size() == NumAbstractScopes
11641183 && "ensureAbstractVariableIsCreated inserted abstract scopes");
11651184 }
1185 // Assure abstract local scope created for each one contains local DIEs.
1186 for (const DILocalScope *LS : getLocalScopes(SP))
1187 LScopes.getOrCreateAbstractScope(LS);
11661188 constructAbstractSubprogramScopeDIE(AScope);
11671189 }
11681190
210210 /// Size of each symbol emitted (for those symbols that have a specific size).
211211 DenseMap SymSize;
212212
213 /// Holder for scopes containing local declaration DI nodes per DI function.
214 DenseMap>
215 LocalScopesMap;
216
213217 /// Collection of abstract variables.
214218 DenseMap> AbstractVariables;
215219 SmallVector, 64> ConcreteVariables;
326330
327331 void finishSubprogramDefinitions();
328332
333 void finishLocalScopeDefinitions();
334
329335 /// Finish off debug information after all functions have been
330336 /// processed.
331337 void finalizeModuleInfo();
423429 /// Construct imported_module or imported_declaration DIE.
424430 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
425431 const DIImportedEntity *N);
432
433 /// Collect MD Node located within local scope node.
434 /// Return true if node was collected, false otherwise.
435 bool collectLocalScopedNode(DIScope *S, const DINode *N,
436 DwarfCompileUnit &CU);
426437
427438 /// Register a source line with debug info. Returns the unique
428439 /// label that was emitted and which provides correspondence to the
566577 SmallPtrSet &getProcessedSPNodes() {
567578 return ProcessedSPNodes;
568579 }
580
581 /// Return collection of function scopes that contains local declararion DIEs.
582 SmallPtrSet &
583 getLocalScopes(const DISubprogram *SP) {
584 return LocalScopesMap[SP];
585 }
569586 };
570587 } // End of namespace llvm
571588
297297 Entry);
298298 }
299299
300 DIE *DwarfUnit::createDIE(unsigned Tag, const DINode *N) {
301 DIE *Die = DIE::get(DIEValueAllocator, (dwarf::Tag)Tag);
302 if (N)
303 insertDIE(N, Die);
304 return Die;
305 }
306
300307 DIE &DwarfUnit::createAndAddDIE(unsigned Tag, DIE &Parent, const DINode *N) {
301 DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator, (dwarf::Tag)Tag));
302 if (N)
303 insertDIE(N, &Die);
308 DIE &Die = Parent.addChild(createDIE(Tag, N));
304309 return Die;
305310 }
306311
726731
727732 // Construct the context before querying for the existence of the DIE in case
728733 // such construction creates the DIE.
734 // For Local Scope, do not construct context DIE.
729735 auto *Context = resolve(Ty->getScope());
730 DIE *ContextDIE = getOrCreateContextDIE(Context);
731 assert(ContextDIE);
736 bool IsLocalScope = Context && isa(Context);
737 DIE *ContextDIE = IsLocalScope ? nullptr : getOrCreateContextDIE(Context);
738 assert(ContextDIE || IsLocalScope);
732739
733740 if (DIE *TyDIE = getDIE(Ty))
734741 return TyDIE;
735742
736 // Create new type.
737 DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
743 // Create new type and add to map.
744 DIE &TyDIE = IsLocalScope ? *createDIE(Ty->getTag(), Ty)
745 : createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
738746
739747 updateAcceleratorTables(Context, Ty, TyDIE);
740748
296296
297297 /// Construct function argument DIEs.
298298 void constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args);
299
300 /// Create a DIE with the given Tag, and call insertDIE if MD is not null.
301 DIE *createDIE(unsigned Tag, const DINode *N = nullptr);
299302
300303 /// Create a DIE with the given Tag, add the DIE to its parent, and
301304 /// call insertDIE if MD is not null.
7373 !1 = distinct !DILexicalBlock(line: 15, column: 12, file: !38, scope: !2)
7474 !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)
7575 !3 = !DIFile(filename: "one.cc", directory: "/tmp")
76 !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)
76 !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)
7777 !5 = !DISubroutineType(types: !6)
7878 !6 = !{!7}
7979 !7 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
111111 !38 = !DIFile(filename: "one.cc", directory: "/tmp")
112112 !39 = !{}
113113 !40 = !{i32 1, !"Debug Info Version", i32 3}
114 !41 = !{!21}
2626
2727 !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)
2828 !1 = !DIFile(filename: "bar.c", directory: "/tmp/")
29 !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)
29 !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)
3030 !3 = !DISubroutineType(types: !4)
3131 !4 = !{!5, !5}
3232 !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
3838
3939 !59 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5)
4040 !60 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12)
41 !61 = !{!12}
4142
4243 !11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0)
4344 !12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13)
3131 ; CHECK: DW_AT_name {{.*}} "func"
3232 ; CHECK: DW_TAG_compile_unit
3333
34 ; FIXME: Maybe we should drop the subprogram here - since the function was
34 ; Check that the subprogram is dropped in this CU - since the function was
3535 ; emitted in one CU, due to linkonce_odr uniquing. We certainly don't emit the
3636 ; subprogram here if the source location for this definition is the same (see
3737 ; test/DebugInfo/cross-cu-linkonce.ll), though it's very easy to tickle that
4242 ; directory of the source file even though the file name is absolute, not
4343 ; relative)
4444
45 ; CHECK: DW_TAG_subprogram
45 ; CHECK-NOT: DW_TAG_subprogram
4646
4747 @x = global i32 (i32)* @_Z4funci, align 8
4848 @y = global i32 (i32)* @_Z4funci, align 8
6363 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" }
6464 attributes #1 = { nounwind readnone }
6565
66 !llvm.dbg.cu = !{!12, !0}
66 !llvm.dbg.cu = !{!0, !12}
6767 !llvm.module.flags = !{!19, !20}
6868 !llvm.ident = !{!21, !21}
6969
2222 ; CHECK-NOT: NULL
2323 ; CHECK: [[BAR:0x[0-9a-f]*]]:{{ *}}DW_TAG_structure_type
2424 ; CHECK-NEXT: DW_AT_name{{.*}}= "bar"
25 ; CHECK: DW_TAG_subprogram
26 ; CHECK-NOT: DW_TAG
27 ; CHECK: DW_AT_MIPS_linkage_name
28 ; CHECK-NOT: DW_TAG
29 ; CHECK: DW_AT_name{{.*}}= "f1"
2530 ; CHECK: [[FUNC1:.*]]: DW_TAG_subprogram
2631 ; CHECK-NOT: DW_TAG
2732 ; CHECK: DW_AT_MIPS_linkage_name
4449 ; CHECK-NOT: DW_TAG
4550 ; CHECK: DW_AT_name{{.*}}= "func_fwd"
4651 ; CHECK-NOT: DW_AT_declaration
47 ; CHECK: DW_TAG_subprogram
48 ; CHECK-NOT: DW_TAG
49 ; CHECK: DW_AT_MIPS_linkage_name
50 ; CHECK-NOT: DW_TAG
51 ; CHECK: DW_AT_name{{.*}}= "f1"
5252 ; CHECK: NULL
5353
5454 ; CHECK-NOT: NULL
7070
7171 ; CHECK: DW_TAG_subprogram
7272 ; CHECK-NOT: DW_TAG
73 ; CHECK: DW_AT_name{{.*}}= "__cxx_global_var_init"
74 ; CHECK-NOT: DW_TAG
75
76 ; CHECK: DW_TAG_subprogram
77 ; CHECK-NOT: DW_TAG
7378 ; CHECK: DW_AT_MIPS_linkage_name
7479 ; CHECK-NOT: DW_TAG
7580 ; CHECK: DW_AT_name{{.*}}= "func"
81 ; CHECK-NOT: NULL
82 ; CHECK: DW_TAG_lexical_block
83 ; CHECK-NOT: NULL
84 ; CHECK: DW_TAG_imported_module
85 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
86 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(23)
87 ; CHECK-NEXT: DW_AT_import{{.*}}=>
88 ; CHECK: NULL
7689 ; CHECK-NOT: NULL
7790 ; CHECK: DW_TAG_imported_module
7891 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
133146 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(37)
134147 ; CHECK-NEXT: DW_AT_import{{.*}}=> {[[FUNC_FWD]]})
135148
136 ; CHECK: DW_TAG_lexical_block
137 ; CHECK-NOT: NULL
138 ; CHECK: DW_TAG_imported_module
139 ; CHECK-NEXT: DW_AT_decl_file{{.*}}([[F2]])
140 ; CHECK-NEXT: DW_AT_decl_line{{.*}}(23)
141 ; CHECK-NEXT: DW_AT_import{{.*}}=>
142 ; CHECK: NULL
143149 ; CHECK: NULL
144150 ; CHECK: NULL
145151
1515 ; f1();
1616 ; }
1717
18 ; Check that there's only one DW_TAG_subprogram, nothing for the 'f2' function.
19 ; CHECK: DW_TAG_subprogram
20 ; CHECK-NOT: DW_TAG
21 ; CHECK: DW_AT_name {{.*}} "f1"
18 ; Check that there is no DW_TAG_subprogram, nothing for the 'f2' function.
19 ; Note: No debug info was emitted for 'f1' function because it has no code.
2220 ; CHECK-NOT: DW_TAG_subprogram
2321
2422 @i = external global i32
2626
2727 !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)
2828 !1 = !DIFile(filename: "bar.c", directory: "/tmp/")
29 !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)
29 !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)
3030 !3 = !DISubroutineType(types: !4)
3131 !4 = !{!5, !5}
3232 !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
3838
3939 !59 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5)
4040 !60 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12)
41 !61 = !{!12}
4142
4243 !11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0)
4344 !12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13)
2626
2727 !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)
2828 !1 = !DIFile(filename: "bar.c", directory: "/tmp/")
29 !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)
29 !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)
3030 !3 = !DISubroutineType(types: !4)
3131 !4 = !{!5, !5}
3232 !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
3838
3939 !109 = !DILocalVariable(name: "j", line: 9, arg: 1, scope: !0, file: !1, type: !5)
4040 !110 = !DILocalVariable(name: "xyz", line: 10, scope: !11, file: !1, type: !12)
41 !111 = !{!12}
4142
4243 !11 = distinct !DILexicalBlock(line: 9, column: 0, file: !1, scope: !0)
4344 !12 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", line: 10, size: 64, align: 32, file: !27, scope: !0, elements: !13)
0 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
1
2 ;; This test checks the following:
3 ;; 1. Compilation does not crash
4 ;; 2. "f1" function is defined.
5 ;; 3. "nested::f2" function is not defined.
6 ;;
7 ;; This test was generated by running following command:
8 ;; clang -cc1 -O0 -g -emit-llvm foo.cpp -o - | opt -S -inline -sroa
9 ;; Where test.cpp
10 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11 ;;void f1() {
12 ;; while (true) {
13 ;; struct nested {
14 ;; static void f2() {}
15 ;; };
16 ;; nested::f2();
17 ;; }
18 ;;}
19 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20
21 ; CHECK: DW_TAG_compile_unit
22 ; CHECK-NOT: {{DW_TAG|NULL}}
23 ; CHECK: DW_TAG_subprogram
24 ; CHECK-NOT: {{DW_TAG|NULL}}
25 ; CHECK: DW_AT_name {{.*}} "f1"
26 ; CHECK: NULL
27
28 ; CHECK-NOT: DW_TAG_subprogram
29
30
31 ; Function Attrs: nounwind
32 define void @_Z2f1v() #0 !dbg !6 {
33 entry:
34 br label %while.body, !dbg !16
35
36 while.body: ; preds = %while.body, %entry
37 br label %while.body, !dbg !16
38
39 return: ; No predecessors!
40 ret void, !dbg !17
41 }
42
43 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" }
44
45 !llvm.dbg.cu = !{!0}
46 !llvm.module.flags = !{!13, !14}
47 !llvm.ident = !{!15}
48
49 !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)
50 !1 = !DIFile(filename: "foo.cpp", directory: "/")
51 !2 = !{}
52 !3 = !{!4}
53 !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "nested", scope: !5, file: !1, line: 3, size: 8, align: 8, elements: !9)
54 !5 = distinct !DILexicalBlock(scope: !6, file: !1, line: 2)
55 !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)
56 !7 = !DISubroutineType(types: !8)
57 !8 = !{null}
58 !9 = !{!10}
59 !10 = distinct !DISubprogram(name: "f2", scope: !4, file: !1, line: 4, type: !7, isLocal: false, isDefinition: false, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false)
60 !11 = !{!6, !12}
61 !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)
62 !13 = !{i32 2, !"Dwarf Version", i32 4}
63 !14 = !{i32 2, !"Debug Info Version", i32 3}
64 !15 = !{!"clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)"}
65 !16 = !DILocation(line: 2, scope: !6)
66 !17 = !DILocation(line: 8, scope: !6)
55 declare i32 @printf(i8*, ...) nounwind
66
77 define i32 @main() nounwind !dbg !6 {
8 ret i32 0
8 ret i32 0, !dbg !13
99 }
1010
1111 !llvm.dbg.cu = !{!2}
2121 !10 = !DIFile(filename: "simple.c", directory: "/Users/manav/one/two")
2222 !11 = !{}
2323 !12 = !{i32 1, !"Debug Info Version", i32 3}
24 !13 = !DILocation(line: 10, scope: !6)
1010 ; return 1;
1111 ; }
1212
13 ; Check that we still have the structure type for X even though we're not
14 ; going to emit a low/high_pc for foo.
15 ; CHECK: DW_TAG_structure_type
13 ; Check that we will not have the structure type for X as we are going to omit
14 ; the function foo.
15 ; CHECK-NOT: DW_TAG_structure_type
1616
1717 ; Function Attrs: nounwind readnone uwtable
1818 define i32 @bar() #0 !dbg !4 {
2626 !llvm.module.flags = !{!18, !19}
2727 !llvm.ident = !{!20}
2828
29 !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)
29 !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)
3030 !1 = !DIFile(filename: "debug-dead-local-var.c", directory: "/usr/local/google/home/echristo")
3131 !2 = !{}
3232 !3 = !{!4, !9}
4848 !19 = !{i32 2, !"Debug Info Version", i32 3}
4949 !20 = !{!"clang version 3.5.0 (trunk 209255) (llvm/trunk 209253)"}
5050 !21 = !DILocation(line: 13, scope: !4)
51 !22 = !{!14}
122122 ; CHECK: DW_AT_linkage_name
123123 ; CHECK-NOT: DW_TAG
124124 ; CHECK: DW_AT_name {{.*}} "global_namespace_function"
125
126 ; CHECK: DW_TAG_subprogram
127 ; CHECK-NOT: DW_TAG
128 ; CHECK: DW_AT_name {{.*}} "f3"
129 ; CHECK-NOT: {{DW_TAG|NULL}}
130 ; CHECK: [[F3_Z:.*]]: DW_TAG_variable
131 ; CHECK-NOT: DW_TAG
132 ; CHECK: DW_AT_name {{.*}} "z"
133 ; CHECK-NOT: {{DW_TAG|NULL}}
134 ; CHECK: DW_AT_location
135 ; CHECK-NOT: {{DW_TAG|NULL}}
136125 ; CHECK: NULL
137126 ; CHECK-NOT: {{DW_TAG|NULL}}
138127
192181 ; CHECK: DW_AT_linkage_name
193182 ; CHECK-NOT: DW_TAG
194183 ; CHECK: DW_AT_name {{.*}} "global_function"
184
185 ; CHECK: DW_TAG_subprogram
186 ; CHECK-NOT: DW_TAG
187 ; CHECK: DW_AT_name {{.*}} "f3"
188 ; CHECK-NOT: {{DW_TAG|NULL}}
189 ; CHECK: [[F3_Z:.*]]: DW_TAG_variable
190 ; CHECK-NOT: DW_TAG
191 ; CHECK: DW_AT_name {{.*}} "z"
192 ; CHECK-NOT: {{DW_TAG|NULL}}
193 ; CHECK: DW_AT_location
194 ; CHECK-NOT: {{DW_TAG|NULL}}
195 ; CHECK: NULL
195196
196197 ; CHECK-LABEL: .debug_gnu_pubnames contents:
197198 ; CHECK-NEXT: length = {{.*}} version = 0x0002 unit_offset = 0x00000000 unit_size = {{.*}}
200201 ; CHECK-NEXT: [[NS]] EXTERNAL TYPE "ns"
201202 ; CHECK-NEXT: [[OUTER_ANON_C]] STATIC VARIABLE "outer::(anonymous namespace)::c"
202203 ; CHECK-NEXT: [[ANON_I]] STATIC VARIABLE "(anonymous namespace)::i"
204 ; CHECK-NEXT: [[ANON]] EXTERNAL TYPE "(anonymous namespace)"
203205 ; GCC Doesn't put local statics in pubnames, but it seems not unreasonable and
204206 ; comes out naturally from LLVM's implementation, so I'm OK with it for now. If
205207 ; it's demonstrated that this is a major size concern or degrades debug info
206208 ; consumer behavior, feel free to change it.
207209 ; CHECK-NEXT: [[F3_Z]] STATIC VARIABLE "f3::z"
208 ; CHECK-NEXT: [[ANON]] EXTERNAL TYPE "(anonymous namespace)"
209210 ; CHECK-NEXT: [[OUTER_ANON]] EXTERNAL TYPE "outer::(anonymous namespace)"
210211 ; CHECK-NEXT: [[ANON_INNER_B]] STATIC VARIABLE "(anonymous namespace)::inner::b"
211212 ; CHECK-NEXT: [[OUTER]] EXTERNAL TYPE "outer"
0 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
1 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -split-dwarf=Enable -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info.dwo - | FileCheck %s
2
3 ;; This test checks the following:
4 ;; 1. Useless lexical block entry is not emitted.
5 ;; 2. Function static variable, typedef, records (structure, class and union)
6 ;; that are defined in lexical basic block are emitted as children to
7 ;; these lexical blocks.
8 ;; * For typedef and record check that both are emitted in lexical block
9 ;; where they are declared and not in the one where they are used.
10 ;; 3. "bar" function, which was inlined into "foo" function, is created as
11 ;; abstract (with DW_AT_inline attribute).
12 ;; All variables and types are defined in this abstract entry.
13 ;; 4. "bar" function is created in "foo" function as inlined function
14 ;; (with DW_TAG_inlined_subroutine attribute), and all its local variables
15 ;; are created as concrete variables pointing to the abstract suitable entry
16 ;; defined under abstract "bar" function.
17 ;; 5. Lexical block entries created in the inline "bar" function entry have
18 ;; "DW_AT_abstract_origin" attribute pointing to the equivalent abstract
19 ;; lexical block entry.
20 ;;
21 ;; This test was generated by running following command:
22 ;; clang -cc1 -O0 -g -emit-llvm foo.cpp -o - | opt -S -inline -sroa
23 ;; Where foo.cpp
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25 ;;__inline int bar(int s) {
26 ;; {
27 ;; {
28 ;; struct X {
29 ;; int x;
30 ;; };
31 ;; typedef int Y;
32 ;; {
33 ;; X a = { s };
34 ;; Y b(s);
35 ;; static int c = 0;
36 ;; return a.x + b + c++;
37 ;; }
38 ;; }
39 ;; }
40 ;;}
41 ;;
42 ;;
43 ;;int foo(int i) {
44 ;; return
45 ;; bar(i);
46 ;;}
47 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
48
49 ; CHECK: [[Offset_bar:0x[0-9abcdef]+]]: DW_TAG_subprogram
50 ; CHECK-NOT: {{DW_TAG|NULL}}
51 ; CHECK: DW_AT_name {{.*}} "bar"
52 ; CHECK: DW_AT_inline
53 ; CHECK-NOT: NULL
54 ; CHECK: DW_TAG_lexical_block
55
56 ; CHECK-NOT: {{DW_TAG|NULL}}
57 ; CHECK: [[Offset_LB2:0x[0-9abcdef]+]]: DW_TAG_lexical_block
58
59 ; CHECK-NOT: {{DW_TAG|NULL}}
60 ; CHECK: [[Offset_a:0x[0-9abcdef]+]]: DW_TAG_variable
61 ; CHECK-NOT: {{DW_TAG|NULL}}
62 ; CHECK: DW_AT_name {{.*}} "a"
63
64 ; CHECK-NOT: {{DW_TAG|NULL}}
65 ; CHECK: [[Offset_b:0x[0-9abcdef]+]]: DW_TAG_variable
66 ; CHECK-NOT: {{DW_TAG|NULL}}
67 ; CHECK: DW_AT_name {{.*}} "b"
68
69 ; CHECK-NOT: {{DW_TAG|NULL}}
70 ; CHECK: [[Offset_c:0x[0-9abcdef]+]]: DW_TAG_variable
71 ; CHECK-NOT: {{DW_TAG|NULL}}
72 ; CHECK: DW_AT_name {{.*}} "c"
73 ; CHECK-NOT: {{DW_TAG|NULL}}
74 ; CHECK: DW_AT_location
75
76 ; CHECK-NOT: {{DW_TAG}}
77 ; CHECK: NULL
78
79 ; CHECK-NOT: {{DW_TAG|NULL}}
80 ; CHECK: [[Offset_X:0x[0-9abcdef]+]]: DW_TAG_structure_type
81 ; CHECK-NOT: {{DW_TAG|NULL}}
82 ; CHECK: DW_AT_name {{.*}} "X"
83 ; CHECK: NULL
84
85 ; CHECK-NOT: {{DW_TAG|NULL}}
86 ; CHECK: [[Offset_Y:0x[0-9abcdef]+]]: DW_TAG_typedef
87 ; CHECK-NOT: {{DW_TAG|NULL}}
88 ; CHECK: DW_AT_name {{.*}} "Y"
89
90 ; CHECK-NOT: {{DW_TAG}}
91 ; CHECK: NULL
92
93
94 ; CHECK: DW_TAG_subprogram
95 ; CHECK-NOT: {{DW_TAG|NULL}}
96 ; CHECK: DW_AT_name {{.*}} "foo"
97 ; CHECK-NOT: {{NULL}}
98 ; CHECK: DW_TAG_inlined_subroutine
99 ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]}
100
101 ; CHECK-NOT: {{NULL}}
102 ; CHECK: DW_TAG_lexical_block
103
104 ; CHECK-NOT: {{DW_TAG|NULL}}
105 ; CHECK: DW_TAG_lexical_block
106 ; CHECK-NOT: {{DW_TAG|NULL}}
107 ; CHECK: DW_AT_abstract_origin {{.*}} {[[Offset_LB2]]}
108
109 ; CHECK-NOT: {{DW_TAG|NULL}}
110 ; CHECK: DW_TAG_variable
111 ; CHECK-NEXT: DW_AT_location
112 ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_a]]}
113
114 ; CHECK-NOT: {{DW_TAG|NULL}}
115 ; CHECK: DW_TAG_variable
116 ; CHECK-NEXT: DW_AT_location
117 ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_b]]}
118
119 ; CHECK-NOT: {{DW_TAG}}
120 ; CHECK: NULL
121
122 ; CHECK-NOT: {{DW_TAG}}
123 ; CHECK: NULL
124
125 %struct.X = type { i32 }
126
127 $_ZZ3bariE1c = comdat any
128
129 @_ZZ3bariE1c = linkonce_odr global i32 0, comdat, align 4
130
131 ; Function Attrs: nounwind
132 define i32 @_Z3fooi(i32 %i) #0 !dbg !15 {
133 entry:
134 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !22, metadata !23), !dbg !24
135 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !25, metadata !23), !dbg !26
136 call void @llvm.dbg.declare(metadata %struct.X* undef, metadata !28, metadata !23), !dbg !29
137 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !28, metadata !23), !dbg !29
138 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !30, metadata !23), !dbg !31
139 %add.i = add nsw i32 %i, %i, !dbg !32
140 %0 = load i32, i32* @_ZZ3bariE1c, align 4, !dbg !32
141 %inc.i = add nsw i32 %0, 1, !dbg !32
142 store i32 %inc.i, i32* @_ZZ3bariE1c, align 4, !dbg !32
143 %add2.i = add nsw i32 %add.i, %0, !dbg !32
144 ret i32 %add2.i, !dbg !33
145 }
146
147 ; Function Attrs: nounwind readnone
148 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
149
150 ; Function Attrs: nounwind readnone
151 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
152
153 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" }
154 attributes #1 = { nounwind readnone }
155
156 !llvm.dbg.cu = !{!0, !34}
157 !llvm.module.flags = !{!19, !20}
158 !llvm.ident = !{!21}
159
160 !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)
161 !1 = !DIFile(filename: "foo.cpp", directory: "/")
162 !2 = !{}
163 !3 = !{!4, !13}
164 !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !11, identifier: "_ZTSZ3bariE1X")
165 !5 = distinct !DILexicalBlock(scope: !6, file: !1, line: 3)
166 !6 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2)
167 !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)
168 !8 = !DISubroutineType(types: !9)
169 !9 = !{!10, !10}
170 !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
171 !11 = !{!12}
172 !12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !"_ZTSZ3bariE1X", file: !1, line: 5, baseType: !10, size: 32, align: 32)
173 !13 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !10)
174 !14 = !{!15, !7}
175 !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)
176 !16 = !{!17}
177 !17 = !DIGlobalVariable(name: "c", scope: !18, file: !1, line: 11, type: !10, isLocal: false, isDefinition: true, variable: i32* @_ZZ3bariE1c)
178 !18 = distinct !DILexicalBlock(scope: !5, file: !1, line: 8)
179 !19 = !{i32 2, !"Dwarf Version", i32 4}
180 !20 = !{i32 2, !"Debug Info Version", i32 3}
181 !21 = !{!"clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)"}
182 !22 = !DILocalVariable(name: "i", arg: 1, scope: !15, file: !1, line: 19, type: !10)
183 !23 = !DIExpression()
184 !24 = !DILocation(line: 19, scope: !15)
185 !25 = !DILocalVariable(name: "s", arg: 1, scope: !7, file: !1, line: 1, type: !10)
186 !26 = !DILocation(line: 1, scope: !7, inlinedAt: !27)
187 !27 = distinct !DILocation(line: 21, scope: !15)
188 !28 = !DILocalVariable(name: "a", scope: !18, file: !1, line: 9, type: !"_ZTSZ3bariE1X")
189 !29 = !DILocation(line: 9, scope: !18, inlinedAt: !27)
190 !30 = !DILocalVariable(name: "b", scope: !18, file: !1, line: 10, type: !13)
191 !31 = !DILocation(line: 10, scope: !18, inlinedAt: !27)
192 !32 = !DILocation(line: 12, scope: !18, inlinedAt: !27)
193 !33 = !DILocation(line: 20, scope: !15)
194
195 ; This line is manually added to check that the test does not crash when having
196 ; more than one compile unit!
197 !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)
0 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
1
2 ;; This test checks the following:
3 ;; 1. Useless lexical block entry is not emitted.
4 ;; 2. Function static variable, typedef, records (structure, class and union)
5 ;; that are defined in lexical basic block are emitted as children to
6 ;; these lexical blocks.
7 ;; * For typedef and record check that both are emitted in lexical block
8 ;; where they are declared and not in the one where they are used.
9 ;;
10 ;; This test was generated by running following command:
11 ;; clang -cc1 -O0 -g -emit-llvm foo.cpp
12 ;; Where foo.cpp
13 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14 ;;int foo(void) {
15 ;; {
16 ;; {
17 ;; struct X {
18 ;; int x;
19 ;; };
20 ;; typedef int Y;
21 ;; {
22 ;; X a;
23 ;; Y b;
24 ;; static int c;
25 ;; return a.x + b + c;
26 ;; }
27 ;; }
28 ;; }
29 ;;}
30 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31
32
33 ; CHECK: DW_TAG_subprogram
34 ; CHECK-NOT: {{DW_TAG|NULL}}
35 ; CHECK: DW_AT_name {{.*}} "foo"
36 ; CHECK-NOT: NULL
37 ; CHECK: DW_TAG_lexical_block
38
39 ; CHECK-NOT: {{DW_TAG|NULL}}
40 ; CHECK: DW_TAG_lexical_block
41
42 ; CHECK-NOT: {{DW_TAG|NULL}}
43 ; CHECK: DW_TAG_variable
44 ; CHECK-NOT: {{DW_TAG|NULL}}
45 ; CHECK: DW_AT_name {{.*}} "a"
46
47 ; CHECK-NOT: {{DW_TAG|NULL}}
48 ; CHECK: DW_TAG_variable
49 ; CHECK-NOT: {{DW_TAG|NULL}}
50 ; CHECK: DW_AT_name {{.*}} "b"
51
52 ; CHECK-NOT: {{DW_TAG|NULL}}
53 ; CHECK: DW_TAG_variable
54 ; CHECK-NOT: {{DW_TAG|NULL}}
55 ; CHECK: DW_AT_name {{.*}} "c"
56
57 ; CHECK-NOT: {{DW_TAG}}
58 ; CHECK: NULL
59
60 ; CHECK-NOT: {{DW_TAG|NULL}}
61 ; CHECK: DW_TAG_structure_type
62 ; CHECK-NOT: {{DW_TAG|NULL}}
63 ; CHECK: DW_AT_name {{.*}} "X"
64 ; CHECK: NULL
65
66 ; CHECK-NOT: {{DW_TAG|NULL}}
67 ; CHECK: DW_TAG_typedef
68 ; CHECK-NOT: {{DW_TAG|NULL}}
69 ; CHECK: DW_AT_name {{.*}} "Y"
70
71 ; CHECK-NOT: {{DW_TAG}}
72 ; CHECK: NULL
73
74 %struct.X = type { i32 }
75
76 @_ZZ3foovE1c = internal global i32 0, align 4
77
78 ; Function Attrs: nounwind
79 define i32 @_Z3foov() #0 !dbg !7 {
80 entry:
81 %a = alloca %struct.X, align 4
82 %b = alloca i32, align 4
83 call void @llvm.dbg.declare(metadata %struct.X* %a, metadata !21, metadata !22), !dbg !23
84 call void @llvm.dbg.declare(metadata i32* %b, metadata !24, metadata !22), !dbg !25
85 %x = getelementptr inbounds %struct.X, %struct.X* %a, i32 0, i32 0, !dbg !26
86 %0 = load i32, i32* %x, align 4, !dbg !26
87 %1 = load i32, i32* %b, align 4, !dbg !26
88 %add = add nsw i32 %0, %1, !dbg !26
89 %2 = load i32, i32* @_ZZ3foovE1c, align 4, !dbg !26
90 %add1 = add nsw i32 %add, %2, !dbg !26
91 ret i32 %add1, !dbg !26
92 }
93
94 ; Function Attrs: nounwind readnone
95 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
96
97 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" }
98 attributes #1 = { nounwind readnone }
99
100 !llvm.dbg.cu = !{!0}
101 !llvm.module.flags = !{!18, !19}
102 !llvm.ident = !{!20}
103
104 !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)
105 !1 = !DIFile(filename: "foo.cpp", directory: "/")
106 !2 = !{}
107 !3 = !{!4, !13}
108 !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !11)
109 !5 = distinct !DILexicalBlock(scope: !6, file: !1, line: 3)
110 !6 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2)
111 !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)
112 !8 = !DISubroutineType(types: !9)
113 !9 = !{!10}
114 !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
115 !11 = !{!12}
116 !12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !4, file: !1, line: 5, baseType: !10, size: 32, align: 32)
117 !13 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !10)
118 !14 = !{!7}
119 !15 = !{!16}
120 !16 = !DIGlobalVariable(name: "c", scope: !17, file: !1, line: 11, type: !10, isLocal: true, isDefinition: true, variable: i32* @_ZZ3foovE1c)
121 !17 = distinct !DILexicalBlock(scope: !5, file: !1, line: 8)
122 !18 = !{i32 2, !"Dwarf Version", i32 4}
123 !19 = !{i32 2, !"Debug Info Version", i32 3}
124 !20 = !{!"clang version 3.7.0 (trunk 237245)"}
125 !21 = !DILocalVariable(name: "a", scope: !17, file: !1, line: 9, type: !4)
126 !22 = !DIExpression()
127 !23 = !DILocation(line: 9, scope: !17)
128 !24 = !DILocalVariable(name: "b", scope: !17, file: !1, line: 10, type: !13)
129 !25 = !DILocation(line: 10, scope: !17)
130 !26 = !DILocation(line: 12, scope: !17)
0 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
1 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -split-dwarf=Enable -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info.dwo - | FileCheck %s
2
3 ;; This test checks the following:
4 ;; 2. Function static variable, typedef, records (structure, class and union)
5 ;; that are defined in lexical function scope are emitted as children to
6 ;; the function scope, directly.
7 ;; 3. "bar" function, which was inlined into "foo" function, is created as
8 ;; abstract (with DW_AT_inline attribute).
9 ;; All variables and types are defined in this abstract entry.
10 ;; 4. "bar" function is created in "foo" function as inlined function
11 ;; (with DW_TAG_inlined_subroutine attribute), and all its local variables
12 ;; are created as concrete variables pointing to the abstract suitable entry
13 ;; defined under abstract "bar" function.
14 ;;
15 ;; This test was generated by running following command:
16 ;; clang -cc1 -O0 -g -emit-llvm foo.cpp -o - | opt -S -inline -sroa
17 ;; Where foo.cpp
18 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19 ;;__inline int bar(int s) {
20 ;;
21 ;;
22 ;; struct X {
23 ;; int x;
24 ;; };
25 ;; typedef int Y;
26 ;;
27 ;; X a = { s };
28 ;; Y b(s);
29 ;; static int c = 0;
30 ;; return a.x + b + c++;
31 ;;
32 ;;
33 ;;
34 ;;}
35 ;;
36 ;;
37 ;;int foo(int i) {
38 ;; return
39 ;; bar(i);
40 ;;}
41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
42
43 ; CHECK: [[Offset_bar:0x[0-9abcdef]+]]: DW_TAG_subprogram
44 ; CHECK-NOT: {{DW_TAG|NULL}}
45 ; CHECK: DW_AT_name {{.*}} "bar"
46 ; CHECK: DW_AT_inline
47 ; CHECK-NOT: NULL
48
49 ; CHECK: [[Offset_a:0x[0-9abcdef]+]]: DW_TAG_variable
50 ; CHECK-NOT: {{DW_TAG|NULL}}
51 ; CHECK: DW_AT_name {{.*}} "a"
52
53 ; CHECK-NOT: {{DW_TAG|NULL}}
54 ; CHECK: [[Offset_b:0x[0-9abcdef]+]]: DW_TAG_variable
55 ; CHECK-NOT: {{DW_TAG|NULL}}
56 ; CHECK: DW_AT_name {{.*}} "b"
57
58 ; CHECK-NOT: {{DW_TAG|NULL}}
59 ; CHECK: [[Offset_c:0x[0-9abcdef]+]]: DW_TAG_variable
60 ; CHECK-NOT: {{DW_TAG|NULL}}
61 ; CHECK: DW_AT_name {{.*}} "c"
62 ; CHECK-NOT: {{DW_TAG|NULL}}
63 ; CHECK: DW_AT_location
64
65 ; CHECK-NOT: {{DW_TAG|NULL}}
66 ; CHECK: [[Offset_X:0x[0-9abcdef]+]]: DW_TAG_structure_type
67 ; CHECK-NOT: {{DW_TAG|NULL}}
68 ; CHECK: DW_AT_name {{.*}} "X"
69 ; CHECK: NULL
70
71 ; CHECK-NOT: {{DW_TAG|NULL}}
72 ; CHECK: [[Offset_Y:0x[0-9abcdef]+]]: DW_TAG_typedef
73 ; CHECK-NOT: {{DW_TAG|NULL}}
74 ; CHECK: DW_AT_name {{.*}} "Y"
75
76 ; CHECK-NOT: {{DW_TAG}}
77 ; CHECK: NULL
78
79
80 ; CHECK: DW_TAG_subprogram
81 ; CHECK-NOT: {{DW_TAG|NULL}}
82 ; CHECK: DW_AT_name {{.*}} "foo"
83 ; CHECK-NOT: {{NULL}}
84 ; CHECK: DW_TAG_inlined_subroutine
85 ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]}
86
87 ; CHECK-NOT: {{NULL}}
88 ; CHECK: DW_TAG_variable
89 ; CHECK-NEXT: DW_AT_location
90 ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_a]]}
91
92 ; CHECK-NOT: {{DW_TAG|NULL}}
93 ; CHECK: DW_TAG_variable
94 ; CHECK-NEXT: DW_AT_location
95 ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_b]]}
96
97 ; CHECK-NOT: {{DW_TAG}}
98 ; CHECK: NULL
99
100 %struct.X = type { i32 }
101
102 $_ZZ3bariE1c = comdat any
103
104 @_ZZ3bariE1c = linkonce_odr global i32 0, comdat, align 4
105
106 ; Function Attrs: nounwind
107 define i32 @_Z3fooi(i32 %i) #0 !dbg !13 {
108 entry:
109 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !18, metadata !19), !dbg !20
110 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !21, metadata !19), !dbg !22
111 call void @llvm.dbg.declare(metadata %struct.X* undef, metadata !24, metadata !19), !dbg !25
112 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !24, metadata !19), !dbg !25
113 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !26, metadata !19), !dbg !27
114 %add.i = add nsw i32 %i, %i, !dbg !28
115 %0 = load i32, i32* @_ZZ3bariE1c, align 4, !dbg !28
116 %inc.i = add nsw i32 %0, 1, !dbg !28
117 store i32 %inc.i, i32* @_ZZ3bariE1c, align 4, !dbg !28
118 %add2.i = add nsw i32 %add.i, %0, !dbg !28
119 ret i32 %add2.i, !dbg !29
120 }
121
122 ; Function Attrs: nounwind readnone
123 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
124
125 ; Function Attrs: nounwind readnone
126 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
127
128 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" }
129 attributes #1 = { nounwind readnone }
130
131 !llvm.dbg.cu = !{!0, !30}
132 !llvm.module.flags = !{!16}
133 !llvm.ident = !{!17}
134
135 !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)
136 !1 = !DIFile(filename: "foo.cpp", directory: "/")
137 !2 = !{}
138 !3 = !{!4, !11}
139 !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !9, identifier: "_ZTSZ3bariE1X")
140 !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)
141 !6 = !DISubroutineType(types: !7)
142 !7 = !{!8, !8}
143 !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
144 !9 = !{!10}
145 !10 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !"_ZTSZ3bariE1X", file: !1, line: 5, baseType: !8, size: 32, align: 32)
146 !11 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !8)
147 !12 = !{!13, !5}
148 !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)
149 !14 = !{!15}
150 !15 = !DIGlobalVariable(name: "c", scope: !5, file: !1, line: 11, type: !8, isLocal: false, isDefinition: true, variable: i32* @_ZZ3bariE1c)
151 !16 = !{i32 2, !"Debug Info Version", i32 3}
152 !17 = !{!"clang version 3.8.0 (trunk 256818)"}
153 !18 = !DILocalVariable(name: "i", arg: 1, scope: !13, file: !1, line: 19, type: !8)
154 !19 = !DIExpression()
155 !20 = !DILocation(line: 19, scope: !13)
156 !21 = !DILocalVariable(name: "s", arg: 1, scope: !5, file: !1, line: 1, type: !8)
157 !22 = !DILocation(line: 1, scope: !5, inlinedAt: !23)
158 !23 = distinct !DILocation(line: 21, scope: !13)
159 !24 = !DILocalVariable(name: "a", scope: !5, file: !1, line: 9, type: !"_ZTSZ3bariE1X")
160 !25 = !DILocation(line: 9, scope: !5, inlinedAt: !23)
161 !26 = !DILocalVariable(name: "b", scope: !5, file: !1, line: 10, type: !11)
162 !27 = !DILocation(line: 10, scope: !5, inlinedAt: !23)
163 !28 = !DILocation(line: 12, scope: !5, inlinedAt: !23)
164 !29 = !DILocation(line: 20, scope: !13)
165
166 ; This line is manually added to check that the test does not crash when having
167 ; more than one compile unit!
168 !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)