llvm.org GIT mirror llvm / 2b53089
Debug Info: In DIBuilder, the derived-from field of a DW_TAG_pointer_type is updated to use DITypeRef. Move isUnsignedDIType and getOriginalTypeSize from DebugInfo.h to be static helper functions in DwarfCompileUnit. We already have a static helper function "isTypeSigned" in DwarfCompileUnit, and a pointer to DwarfDebug is added to resolve the derived-from field. All three functions need to go across link for derived-from fields, so we need to get hold of a type identifier map. A pointer to DwarfDebug is also added to DbgVariable in order to resolve the derived-from field. Debug info verifier is updated to check a derived-from field is a TypeRef. Verifier will not go across link for derived-from fields, in debug info finder, we go across the link to add derived-from fields to types. Function getDICompositeType is only used by dragonegg and since dragonegg does not generate identifier for types, we use an empty map to resolve the derived-from field. When printing a derived-from field, we use DITypeRef::getName to either return the type identifier or getName of the DIType. A paired commit at clang is required due to changes to DIBuilder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191800 91177308-0d34-0410-b5e6-96231b3b80d8 Manman Ren 6 years ago
10 changed file(s) with 273 addition(s) and 96 deletion(s). Raw diff Collapse all Expand all
2121 #include "llvm/ADT/SmallPtrSet.h"
2222 #include "llvm/ADT/SmallVector.h"
2323 #include "llvm/ADT/StringRef.h"
24 #include "llvm/IR/Metadata.h"
2425 #include "llvm/Support/Dwarf.h"
2526
2627 namespace llvm {
205206 /// Gets the parent scope for this scope node or returns a
206207 /// default constructed scope.
207208 DIScopeRef getContext() const;
209 /// If the scope node has a name, return that, else return an empty string.
210 StringRef getName() const;
208211 StringRef getFilename() const;
209212 StringRef getDirectory() const;
210213
241244 assert(DIDescriptor(Iter->second).isType() &&
242245 "MDNode in DITypeIdentifierMap should be a DIType.");
243246 return T(Iter->second);
247 }
248 StringRef getName() const {
249 if (!Val)
250 return StringRef();
251
252 if (const MDNode *MD = dyn_cast(Val))
253 return T(MD).getName();
254
255 const MDString *MS = cast(Val);
256 return MS->getString();
244257 }
245258 operator Value *() const { return const_cast(Val); }
246259 };
320333 return DbgNode && isType();
321334 }
322335
323 /// isUnsignedDIType - Return true if type encoding is unsigned.
324 bool isUnsignedDIType();
325
326336 /// replaceAllUsesWith - Replace all uses of debug info referenced by
327337 /// this descriptor.
328338 void replaceAllUsesWith(DIDescriptor &D);
350360 public:
351361 explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {}
352362
353 DIType getTypeDerivedFrom() const { return getFieldAs(9); }
354
355 /// getOriginalTypeSize - If this type is derived from a base type then
356 /// return base type size.
357 uint64_t getOriginalTypeSize() const;
363 DITypeRef getTypeDerivedFrom() const { return getFieldAs(9); }
358364
359365 /// getObjCProperty - Return property node, if this ivar is
360366 /// associated with one.
533533
534534 if (Tag == dwarf::DW_TAG_pointer_type) {
535535 DIDerivedType DTy = DIDerivedType(Ty);
536 TmpTy = DTy.getTypeDerivedFrom();
536 TmpTy = DD->resolve(DTy.getTypeDerivedFrom());
537537 isPointer = true;
538538 }
539539
600600 }
601601
602602 /// isTypeSigned - Return true if the type is signed.
603 static bool isTypeSigned(DIType Ty, int *SizeInBits) {
603 static bool isTypeSigned(DwarfDebug *DD, DIType Ty, int *SizeInBits) {
604604 if (Ty.isDerivedType())
605 return isTypeSigned(DIDerivedType(Ty).getTypeDerivedFrom(), SizeInBits);
605 return isTypeSigned(DD, DD->resolve(DIDerivedType(Ty).getTypeDerivedFrom()),
606 SizeInBits);
606607 if (Ty.isBasicType())
607608 if (DIBasicType(Ty).getEncoding() == dwarf::DW_ATE_signed
608609 || DIBasicType(Ty).getEncoding() == dwarf::DW_ATE_signed_char) {
610611 return true;
611612 }
612613 return false;
614 }
615
616 /// Return true if type encoding is unsigned.
617 static bool isUnsignedDIType(DwarfDebug *DD, DIType Ty) {
618 DIDerivedType DTy(Ty);
619 if (DTy.isDerivedType())
620 return isUnsignedDIType(DD, DD->resolve(DTy.getTypeDerivedFrom()));
621
622 DIBasicType BTy(Ty);
623 if (BTy.isBasicType()) {
624 unsigned Encoding = BTy.getEncoding();
625 if (Encoding == dwarf::DW_ATE_unsigned ||
626 Encoding == dwarf::DW_ATE_unsigned_char ||
627 Encoding == dwarf::DW_ATE_boolean)
628 return true;
629 }
630 return false;
631 }
632
633 /// If this type is derived from a base type then return base type size.
634 static uint64_t getOriginalTypeSize(DwarfDebug *DD, DIDerivedType Ty) {
635 unsigned Tag = Ty.getTag();
636
637 if (Tag != dwarf::DW_TAG_member && Tag != dwarf::DW_TAG_typedef &&
638 Tag != dwarf::DW_TAG_const_type && Tag != dwarf::DW_TAG_volatile_type &&
639 Tag != dwarf::DW_TAG_restrict_type)
640 return Ty.getSizeInBits();
641
642 DIType BaseType = DD->resolve(Ty.getTypeDerivedFrom());
643
644 // If this type is not derived from any type then take conservative approach.
645 if (!BaseType.isValid())
646 return Ty.getSizeInBits();
647
648 // If this is a derived type, go ahead and get the base type, unless it's a
649 // reference then it's just the size of the field. Pointer types have no need
650 // of this since they're a different type of qualification on the type.
651 if (BaseType.getTag() == dwarf::DW_TAG_reference_type ||
652 BaseType.getTag() == dwarf::DW_TAG_rvalue_reference_type)
653 return Ty.getSizeInBits();
654
655 if (BaseType.isDerivedType())
656 return getOriginalTypeSize(DD, DIDerivedType(BaseType));
657
658 return BaseType.getSizeInBits();
613659 }
614660
615661 /// addConstantValue - Add constant value entry in variable DIE.
620666 // udata/sdata over dataN as suggested by the DWARF spec)
621667 assert(MO.isImm() && "Invalid machine operand!");
622668 int SizeInBits = -1;
623 bool SignedConstant = isTypeSigned(Ty, &SizeInBits);
669 bool SignedConstant = isTypeSigned(DD, Ty, &SizeInBits);
624670 uint16_t Form;
625671
626672 // If we're a signed constant definitely use sdata.
937983 Buffer.setTag(Tag);
938984
939985 // Map to main type, void will not have a type.
940 DIType FromTy = DTy.getTypeDerivedFrom();
986 DIType FromTy = DD->resolve(DTy.getTypeDerivedFrom());
941987 if (FromTy)
942988 addType(&Buffer, FromTy);
943989
10151061 Buffer.addChild(ElemDie);
10161062 }
10171063 }
1018 DIType DTy = CTy.getTypeDerivedFrom();
1064 DIType DTy = DD->resolve(CTy.getTypeDerivedFrom());
10191065 if (DTy) {
10201066 addType(&Buffer, DTy);
10211067 addUInt(&Buffer, dwarf::DW_AT_enum_class, dwarf::DW_FORM_flag, 1);
10811127 DIDerivedType DDTy(Element);
10821128 if (DDTy.getTag() == dwarf::DW_TAG_friend) {
10831129 ElemDie = new DIE(dwarf::DW_TAG_friend);
1084 addType(ElemDie, DDTy.getTypeDerivedFrom(), dwarf::DW_AT_friend);
1130 addType(ElemDie, DD->resolve(DDTy.getTypeDerivedFrom()),
1131 dwarf::DW_AT_friend);
10851132 } else if (DDTy.isStaticMember())
10861133 ElemDie = createStaticMemberDIE(DDTy);
10871134 else
12231270 addString(ParamDIE, dwarf::DW_AT_name, VP.getName());
12241271 if (Value *Val = VP.getValue()) {
12251272 if (ConstantInt *CI = dyn_cast(Val))
1226 addConstantValue(ParamDIE, CI, VP.getType().isUnsignedDIType());
1273 addConstantValue(ParamDIE, CI, isUnsignedDIType(DD, VP.getType()));
12271274 else if (GlobalValue *GV = dyn_cast(Val)) {
12281275 // For declaration non-type template parameters (such as global values and
12291276 // functions)
15101557 // emitting AT_const_value multiple times, we only add AT_const_value when
15111558 // it is not a static member.
15121559 if (!IsStaticMember)
1513 addConstantValue(VariableDIE, CI, GTy.isUnsignedDIType());
1560 addConstantValue(VariableDIE, CI, isUnsignedDIType(DD, GTy));
15141561 } else if (const ConstantExpr *CE = getMergedGlobalExpr(N->getOperand(11))) {
15151562 addToAccelTable = true;
15161563 // GV is a merged global.
15711618 addFlag(&Buffer, dwarf::DW_AT_GNU_vector);
15721619
15731620 // Emit the element type.
1574 addType(&Buffer, CTy->getTypeDerivedFrom());
1621 addType(&Buffer, DD->resolve(CTy->getTypeDerivedFrom()));
15751622
15761623 // Get an anonymous type for index type.
15771624 // FIXME: This type should be passed down from the front end
16781725 addConstantFPValue(VariableDie, DVInsn->getOperand(0));
16791726 else if (DVInsn->getOperand(0).isCImm())
16801727 addConstantValue(VariableDie, DVInsn->getOperand(0).getCImm(),
1681 DV->getType().isUnsignedDIType());
1728 isUnsignedDIType(DD, DV->getType()));
16821729
16831730 DV->setDIE(VariableDie);
16841731 return VariableDie;
17061753 if (!Name.empty())
17071754 addString(MemberDie, dwarf::DW_AT_name, Name);
17081755
1709 addType(MemberDie, DT.getTypeDerivedFrom());
1756 addType(MemberDie, DD->resolve(DT.getTypeDerivedFrom()));
17101757
17111758 addSourceLine(MemberDie, DT);
17121759
17141761 addUInt(MemLocationDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
17151762
17161763 uint64_t Size = DT.getSizeInBits();
1717 uint64_t FieldSize = DT.getOriginalTypeSize();
1764 uint64_t FieldSize = getOriginalTypeSize(DD, DT);
17181765
17191766 if (Size != FieldSize) {
17201767 // Handle bitfield.
1721 addUInt(MemberDie, dwarf::DW_AT_byte_size, 0, DT.getOriginalTypeSize()>>3);
1768 addUInt(MemberDie, dwarf::DW_AT_byte_size, 0,
1769 getOriginalTypeSize(DD, DT)>>3);
17221770 addUInt(MemberDie, dwarf::DW_AT_bit_size, 0, DT.getSizeInBits());
17231771
17241772 uint64_t Offset = DT.getOffsetInBits();
17931841 return NULL;
17941842
17951843 DIE *StaticMemberDIE = new DIE(DT.getTag());
1796 DIType Ty = DT.getTypeDerivedFrom();
1844 DIType Ty = DD->resolve(DT.getTypeDerivedFrom());
17971845
17981846 addString(StaticMemberDIE, dwarf::DW_AT_name, DT.getName());
17991847 addType(StaticMemberDIE, Ty);
18141862 dwarf::DW_ACCESS_public);
18151863
18161864 if (const ConstantInt *CI = dyn_cast_or_null(DT.getConstant()))
1817 addConstantValue(StaticMemberDIE, CI, Ty.isUnsignedDIType());
1865 addConstantValue(StaticMemberDIE, CI, isUnsignedDIType(DD, Ty));
18181866 if (const ConstantFP *CFP = dyn_cast_or_null(DT.getConstant()))
18191867 addConstantFPValue(StaticMemberDIE, CFP);
18201868
148148 uint16_t tag = Ty.getTag();
149149
150150 if (tag == dwarf::DW_TAG_pointer_type)
151 subType = DIDerivedType(Ty).getTypeDerivedFrom();
151 subType = DD->resolve(DIDerivedType(Ty).getTypeDerivedFrom());
152152
153153 DIArray Elements = DICompositeType(subType).getTypeArray();
154154 for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
155155 DIDerivedType DT = DIDerivedType(Elements.getElement(i));
156156 if (getName() == DT.getName())
157 return (DT.getTypeDerivedFrom());
157 return (DD->resolve(DT.getTypeDerivedFrom()));
158158 }
159159 }
160160 return Ty;
995995 for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
996996 DIVariable DV(Variables.getElement(vi));
997997 if (!DV.isVariable()) continue;
998 DbgVariable NewVar(DV, NULL);
998 DbgVariable NewVar(DV, NULL, this);
999999 if (DIE *VariableDIE =
10001000 SPCU->constructVariableDIE(&NewVar, Scope->isAbstractScope()))
10011001 ScopeDIE->addChild(VariableDIE);
12511251 if (!Scope)
12521252 return NULL;
12531253
1254 AbsDbgVariable = new DbgVariable(Var, NULL);
1254 AbsDbgVariable = new DbgVariable(Var, NULL, this);
12551255 addScopeVariable(Scope, AbsDbgVariable);
12561256 AbstractVariables[Var] = AbsDbgVariable;
12571257 return AbsDbgVariable;
13001300 continue;
13011301
13021302 DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.second);
1303 DbgVariable *RegVar = new DbgVariable(DV, AbsDbgVariable);
1303 DbgVariable *RegVar = new DbgVariable(DV, AbsDbgVariable, this);
13041304 RegVar->setFrameIndex(VP.first);
13051305 if (!addCurrentFnArgument(MF, RegVar, Scope))
13061306 addScopeVariable(Scope, RegVar);
13851385 Processed.insert(DV);
13861386 assert(MInsn->isDebugValue() && "History must begin with debug value");
13871387 DbgVariable *AbsVar = findAbstractVariable(DV, MInsn->getDebugLoc());
1388 DbgVariable *RegVar = new DbgVariable(DV, AbsVar);
1388 DbgVariable *RegVar = new DbgVariable(DV, AbsVar, this);
13891389 if (!addCurrentFnArgument(MF, RegVar, Scope))
13901390 addScopeVariable(Scope, RegVar);
13911391 if (AbsVar)
14481448 if (!DV || !DV.isVariable() || !Processed.insert(DV))
14491449 continue;
14501450 if (LexicalScope *Scope = LScopes.findLexicalScope(DV.getContext()))
1451 addScopeVariable(Scope, new DbgVariable(DV, NULL));
1451 addScopeVariable(Scope, new DbgVariable(DV, NULL, this));
14521452 }
14531453 }
14541454
18441844 if (AbstractVariables.lookup(CleanDV))
18451845 continue;
18461846 if (LexicalScope *Scope = LScopes.findAbstractScope(DV.getContext()))
1847 addScopeVariable(Scope, new DbgVariable(DV, NULL));
1847 addScopeVariable(Scope, new DbgVariable(DV, NULL, this));
18481848 }
18491849 }
18501850 if (ProcessedSPNodes.count(AScope->getScopeNode()) == 0)
149149 DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
150150 const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
151151 int FrameIndex;
152 DwarfDebug *DD;
152153 public:
153154 // AbsVar may be NULL.
154 DbgVariable(DIVariable V, DbgVariable *AV)
155 DbgVariable(DIVariable V, DbgVariable *AV, DwarfDebug *DD)
155156 : Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
156 FrameIndex(~0) {}
157 FrameIndex(~0), DD(DD) {}
157158
158159 // Accessors.
159160 DIVariable getVariable() const { return Var; }
302302 ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
303303 ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
304304 ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
305 PointeeTy
305 PointeeTy.getRef()
306306 };
307307 return DIDerivedType(MDNode::get(VMContext, Elts));
308308 }
367367 }
368368 }
369369
370 /// isUnsignedDIType - Return true if type encoding is unsigned.
371 bool DIType::isUnsignedDIType() {
372 DIDerivedType DTy(DbgNode);
373 if (DTy.Verify())
374 return DTy.getTypeDerivedFrom().isUnsignedDIType();
375
376 DIBasicType BTy(DbgNode);
377 if (BTy.Verify()) {
378 unsigned Encoding = BTy.getEncoding();
379 if (Encoding == dwarf::DW_ATE_unsigned ||
380 Encoding == dwarf::DW_ATE_unsigned_char ||
381 Encoding == dwarf::DW_ATE_boolean)
382 return true;
383 }
384 return false;
385 }
386
387370 /// Verify - Verify that a compile unit is well formed.
388371 bool DICompileUnit::Verify() const {
389372 if (!isCompileUnit())
492475
493476 /// Verify - Verify that a derived type descriptor is well formed.
494477 bool DIDerivedType::Verify() const {
495 // Make sure DerivedFrom @ field 9 is MDNode.
496 if (!fieldIsMDNode(DbgNode, 9))
478 // Make sure DerivedFrom @ field 9 is TypeRef.
479 if (!fieldIsTypeRef(DbgNode, 9))
497480 return false;
498481 if (getTag() == dwarf::DW_TAG_ptr_to_member_type)
499482 // Make sure ClassType @ field 10 is a TypeRef.
509492 if (!isCompositeType())
510493 return false;
511494
512 // Make sure DerivedFrom @ field 9 and ContainingType @ field 12 are MDNodes.
513 if (!fieldIsMDNode(DbgNode, 9))
495 // Make sure DerivedFrom @ field 9 and ContainingType @ field 12 are TypeRef.
496 if (!fieldIsTypeRef(DbgNode, 9))
514497 return false;
515498 if (!fieldIsTypeRef(DbgNode, 12))
516499 return false;
518501 // Make sure the type identifier at field 14 is MDString, it can be null.
519502 if (!fieldIsMDString(DbgNode, 14))
520503 return false;
521
522 // If this is an array type verify that we have a DIType in the derived type
523 // field as that's the type of our element.
524 if (getTag() == dwarf::DW_TAG_array_type)
525 if (!DIType(getTypeDerivedFrom()))
526 return false;
527504
528505 return DbgNode->getNumOperands() == 15;
529506 }
635612 bool DIImportedEntity::Verify() const {
636613 return isImportedEntity() &&
637614 (DbgNode->getNumOperands() == 4 || DbgNode->getNumOperands() == 5);
638 }
639
640 /// getOriginalTypeSize - If this type is derived from a base type then
641 /// return base type size.
642 uint64_t DIDerivedType::getOriginalTypeSize() const {
643 uint16_t Tag = getTag();
644
645 if (Tag != dwarf::DW_TAG_member && Tag != dwarf::DW_TAG_typedef &&
646 Tag != dwarf::DW_TAG_const_type && Tag != dwarf::DW_TAG_volatile_type &&
647 Tag != dwarf::DW_TAG_restrict_type)
648 return getSizeInBits();
649
650 DIType BaseType = getTypeDerivedFrom();
651
652 // If this type is not derived from any type then take conservative approach.
653 if (!BaseType.isValid())
654 return getSizeInBits();
655
656 // If this is a derived type, go ahead and get the base type, unless it's a
657 // reference then it's just the size of the field. Pointer types have no need
658 // of this since they're a different type of qualification on the type.
659 if (BaseType.getTag() == dwarf::DW_TAG_reference_type ||
660 BaseType.getTag() == dwarf::DW_TAG_rvalue_reference_type)
661 return getSizeInBits();
662
663 if (BaseType.isDerivedType())
664 return DIDerivedType(BaseType).getOriginalTypeSize();
665
666 return BaseType.getSizeInBits();
667615 }
668616
669617 /// getObjCProperty - Return property node, if this ivar is associated with one.
807755 return DIScopeRef(NULL);
808756 }
809757
758 // If the scope node has a name, return that, else return an empty string.
759 StringRef DIScope::getName() const {
760 if (isType())
761 return DIType(DbgNode).getName();
762 if (isSubprogram())
763 return DISubprogram(DbgNode).getName();
764 if (isNameSpace())
765 return DINameSpace(DbgNode).getName();
766 assert((isLexicalBlock() || isLexicalBlockFile() || isFile() ||
767 isCompileUnit()) && "Unhandled type of scope.");
768 return StringRef();
769 }
770
810771 StringRef DIScope::getFilename() const {
811772 if (!DbgNode)
812773 return StringRef();
941902 if (T.isCompositeType())
942903 return DICompositeType(T);
943904
944 if (T.isDerivedType())
945 return getDICompositeType(DIDerivedType(T).getTypeDerivedFrom());
905 if (T.isDerivedType()) {
906 // This function is currently used by dragonegg and dragonegg does
907 // not generate identifier for types, so using an empty map to resolve
908 // DerivedFrom should be fine.
909 DITypeIdentifierMap EmptyMap;
910 return getDICompositeType(DIDerivedType(T).getTypeDerivedFrom()
911 .resolve(EmptyMap));
912 }
946913
947914 return DICompositeType();
948915 }
10431010 processScope(DT.getContext().resolve(TypeIdentifierMap));
10441011 if (DT.isCompositeType()) {
10451012 DICompositeType DCT(DT);
1046 processType(DCT.getTypeDerivedFrom());
1013 processType(DCT.getTypeDerivedFrom().resolve(TypeIdentifierMap));
10471014 DIArray DA = DCT.getTypeArray();
10481015 for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) {
10491016 DIDescriptor D = DA.getElement(i);
10541021 }
10551022 } else if (DT.isDerivedType()) {
10561023 DIDerivedType DDT(DT);
1057 processType(DDT.getTypeDerivedFrom());
1024 processType(DDT.getTypeDerivedFrom().resolve(TypeIdentifierMap));
10581025 }
10591026 }
10601027
0 ; CHECK: 0x[[INT:.*]]: DW_TAG_base_type
1 ; CHECK-NEXT: DW_AT_name {{.*}} = "int"
2 ; CHECK-NOT: DW_TAG_base_type
3 ; CHECK: 0x[[BASE:.*]]: DW_TAG_structure_type
4 ; CHECK-NEXT: DW_AT_name {{.*}} = "Base"
5 ; CHECK-NOT: DW_TAG_structure_type
6 ; CHECK: DW_TAG_formal_parameter
7 ; CHECK: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[INT]])
8 ; CHECK: DW_TAG_variable
9 ; CHECK: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[BASE]])
10
11 ; LINK: DW_TAG_structure_type
12 ; LINK-NOT: DW_TAG_structure_type
13
14 ; Content of header files:
15 ; struct Base {
16 ; int a;
17 ; Base *b;
18 ; };
19 ; Content of foo.cpp:
20 ;
21 ; #include "a.hpp"
22 ; void f(int a) {
23 ; Base t;
24 ; }
25 ; Content of bar.cpp:
26 ;
27 ; #include "a.hpp"
28 ; void f(int);
29 ; void g(int a) {
30 ; Base t;
31 ; }
32 ; int main() {
33 ; f(0);
34 ; g(1);
35 ; return 0;
36 ; }
37 ; ModuleID = 'foo.cpp'
38
39 %struct.Base = type { i32, %struct.Base* }
40
41 ; Function Attrs: nounwind ssp uwtable
42 define void @_Z1fi(i32 %a) #0 {
43 entry:
44 %a.addr = alloca i32, align 4
45 %t = alloca %struct.Base, align 8
46 store i32 %a, i32* %a.addr, align 4
47 call void @llvm.dbg.declare(metadata !{i32* %a.addr}, metadata !17), !dbg !18
48 call void @llvm.dbg.declare(metadata !{%struct.Base* %t}, metadata !19), !dbg !20
49 ret void, !dbg !21
50 }
51
52 ; Function Attrs: nounwind readnone
53 declare void @llvm.dbg.declare(metadata, metadata) #1
54
55 attributes #0 = { nounwind ssp 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" }
56 attributes #1 = { nounwind readnone }
57
58 !llvm.dbg.cu = !{!0}
59 !llvm.module.flags = !{!16}
60
61 !0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 (http://llvm.org/git/clang.git 8a3f9e46cb988d2c664395b21910091e3730ae82) (http://llvm.org/git/llvm.git 4699e9549358bc77824a59114548eecc3f7c523c)", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !11, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [foo.cpp] [DW_LANG_C_plus_plus]
62 !1 = metadata !{metadata !"foo.cpp", metadata !"."}
63 !2 = metadata !{i32 0}
64 !3 = metadata !{metadata !4}
65 !4 = metadata !{i32 786451, metadata !5, null, metadata !"Base", i32 1, i64 128, i64 64, i32 0, i32 0, null, metadata !6, i32 0, null, null, metadata !"_ZTS4Base"} ; [ DW_TAG_structure_type ] [Base] [line 1, size 128, align 64, offset 0] [def] [from ]
66 !5 = metadata !{metadata !"./a.hpp", metadata !"."}
67 !6 = metadata !{metadata !7, metadata !9}
68 !7 = metadata !{i32 786445, metadata !5, metadata !"_ZTS4Base", metadata !"a", i32 2, i64 32, i64 32, i64 0, i32 0, metadata !8} ; [ DW_TAG_member ] [a] [line 2, size 32, align 32, offset 0] [from int]
69 !8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
70 !9 = metadata !{i32 786445, metadata !5, metadata !"_ZTS4Base", metadata !"b", i32 3, i64 64, i64 64, i64 64, i32 0, metadata !10} ; [ DW_TAG_member ] [b] [line 3, size 64, align 64, offset 64] [from ]
71 !10 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !"_ZTS4Base"}
72 !11 = metadata !{metadata !12}
73 !12 = metadata !{i32 786478, metadata !1, metadata !13, metadata !"f", metadata !"f", metadata !"_Z1fi", i32 3, metadata !14, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32)* @_Z1fi, null, null, metadata !2, i32 3} ; [ DW_TAG_subprogram ] [line 3] [def] [f]
74 !13 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [foo.cpp]
75 !14 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !15, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
76 !15 = metadata !{null, metadata !8}
77 !16 = metadata !{i32 2, metadata !"Dwarf Version", i32 2}
78 !17 = metadata !{i32 786689, metadata !12, metadata !"a", metadata !13, i32 16777219, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [a] [line 3]
79 !18 = metadata !{i32 3, i32 0, metadata !12, null}
80 !19 = metadata !{i32 786688, metadata !12, metadata !"t", metadata !13, i32 4, metadata !4, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [t] [line 4]
81 !20 = metadata !{i32 4, i32 0, metadata !12, null}
82 !21 = metadata !{i32 5, i32 0, metadata !12, null}
0 ; ModuleID = 'bar.cpp'
1
2 %struct.Base = type { i32, %struct.Base* }
3
4 ; Function Attrs: nounwind ssp uwtable
5 define void @_Z1gi(i32 %a) #0 {
6 entry:
7 %a.addr = alloca i32, align 4
8 %t = alloca %struct.Base, align 8
9 store i32 %a, i32* %a.addr, align 4
10 call void @llvm.dbg.declare(metadata !{i32* %a.addr}, metadata !20), !dbg !21
11 call void @llvm.dbg.declare(metadata !{%struct.Base* %t}, metadata !22), !dbg !23
12 ret void, !dbg !24
13 }
14
15 ; Function Attrs: nounwind readnone
16 declare void @llvm.dbg.declare(metadata, metadata) #1
17
18 ; Function Attrs: ssp uwtable
19 define i32 @main() #2 {
20 entry:
21 %retval = alloca i32, align 4
22 store i32 0, i32* %retval
23 call void @_Z1fi(i32 0), !dbg !25
24 call void @_Z1gi(i32 1), !dbg !26
25 ret i32 0, !dbg !27
26 }
27
28 declare void @_Z1fi(i32) #3
29
30 attributes #0 = { nounwind ssp 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" }
31 attributes #1 = { nounwind readnone }
32 attributes #2 = { ssp 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" }
33 attributes #3 = { "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" }
34
35 !llvm.dbg.cu = !{!0}
36 !llvm.module.flags = !{!19}
37
38 !0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 (http://llvm.org/git/clang.git 8a3f9e46cb988d2c664395b21910091e3730ae82) (http://llvm.org/git/llvm.git 4699e9549358bc77824a59114548eecc3f7c523c)", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !11, metadata !2, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [bar.cpp] [DW_LANG_C_plus_plus]
39 !1 = metadata !{metadata !"bar.cpp", metadata !"."}
40 !2 = metadata !{i32 0}
41 !3 = metadata !{metadata !4}
42 !4 = metadata !{i32 786451, metadata !5, null, metadata !"Base", i32 1, i64 128, i64 64, i32 0, i32 0, null, metadata !6, i32 0, null, null, metadata !"_ZTS4Base"} ; [ DW_TAG_structure_type ] [Base] [line 1, size 128, align 64, offset 0] [def] [from ]
43 !5 = metadata !{metadata !"./a.hpp", metadata !"."}
44 !6 = metadata !{metadata !7, metadata !9}
45 !7 = metadata !{i32 786445, metadata !5, metadata !"_ZTS4Base", metadata !"a", i32 2, i64 32, i64 32, i64 0, i32 0, metadata !8} ; [ DW_TAG_member ] [a] [line 2, size 32, align 32, offset 0] [from int]
46 !8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
47 !9 = metadata !{i32 786445, metadata !5, metadata !"_ZTS4Base", metadata !"b", i32 3, i64 64, i64 64, i64 64, i32 0, metadata !10} ; [ DW_TAG_member ] [b] [line 3, size 64, align 64, offset 64] [from ]
48 !10 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 0, metadata !"_ZTS4Base"}
49 !11 = metadata !{metadata !12, metadata !16}
50 !12 = metadata !{i32 786478, metadata !1, metadata !13, metadata !"g", metadata !"g", metadata !"_Z1gi", i32 4, metadata !14, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32)* @_Z1gi, null, null, metadata !2, i32 4} ; [ DW_TAG_subprogram ] [line 4] [def] [g]
51 !13 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [bar.cpp]
52 !14 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !15, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
53 !15 = metadata !{null, metadata !8}
54 !16 = metadata !{i32 786478, metadata !1, metadata !13, metadata !"main", metadata !"main", metadata !"", i32 7, metadata !17, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @main, null, null, metadata !2, i32 7} ; [ DW_TAG_subprogram ] [line 7] [def] [main]
55 !17 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !18, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
56 !18 = metadata !{metadata !8}
57 !19 = metadata !{i32 2, metadata !"Dwarf Version", i32 2}
58 !20 = metadata !{i32 786689, metadata !12, metadata !"a", metadata !13, i32 16777220, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [a] [line 4]
59 !21 = metadata !{i32 4, i32 0, metadata !12, null}
60 !22 = metadata !{i32 786688, metadata !12, metadata !"t", metadata !13, i32 5, metadata !4, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [t] [line 5]
61 !23 = metadata !{i32 5, i32 0, metadata !12, null}
62 !24 = metadata !{i32 6, i32 0, metadata !12, null}
63 !25 = metadata !{i32 8, i32 0, metadata !16, null} ; [ DW_TAG_imported_declaration ]
64 !26 = metadata !{i32 9, i32 0, metadata !16, null}
65 !27 = metadata !{i32 10, i32 0, metadata !16, null}
0 ; REQUIRES: object-emission
1
2 ; RUN: llvm-link %S/Inputs/type-unique-simple2-a.ll %S/Inputs/type-unique-simple2-b.ll -S -o %t
3 ; RUN: cat %t | FileCheck %S/Inputs/type-unique-simple2-a.ll -check-prefix=LINK
4 ; RUN: llc -filetype=obj -O0 < %t > %t2
5 ; RUN: llvm-dwarfdump -debug-dump=info %t2 | FileCheck %S/Inputs/type-unique-simple2-a.ll
3737 !0 = metadata !{i32 589870, metadata !25, metadata !1, metadata !"idamax", metadata !"idamax", metadata !"", i32 112, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 false, null, null, null, null, i32 0} ; [ DW_TAG_subprogram ]
3838 !1 = metadata !{i32 589865, metadata !25} ; [ DW_TAG_file_type ]
3939 !2 = metadata !{i32 589841, metadata !25, i32 12, metadata !"clang version 2.9 (trunk 127169)", i1 true, metadata !"", i32 0, metadata !8, metadata !8, metadata !8, null, null, metadata !""} ; [ DW_TAG_compile_unit ]
40 !3 = metadata !{i32 589845, metadata !25, metadata !1, metadata !"", i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
40 !3 = metadata !{i32 589845, metadata !25, metadata !1, metadata !"", i32 0, i64 0, i64 0, i32 0, i32 0, null, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
4141 !4 = metadata !{metadata !5}
4242 !5 = metadata !{i32 589860, null, metadata !2, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
4343 !6 = metadata !{i32 589870, metadata !25, metadata !1, metadata !"dscal", metadata !"dscal", metadata !"", i32 206, metadata !7, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 false, null, null, null, null, i32 0} ; [ DW_TAG_subprogram ]