llvm.org GIT mirror llvm / eaa7353
[DebugInfo] DISubprogram flags get their own flags word. NFC. This will hold flags specific to subprograms. In the future we could potentially free up scarce bits in DIFlags by moving subprogram-specific flags from there to the new flags word. This patch does not change IR/bitcode formats, that will be done in a follow-up. Differential Revision: https://reviews.llvm.org/D54597 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347239 91177308-0d34-0410-b5e6-96231b3b80d8 Paul Robinson 9 months ago
16 changed file(s) with 350 addition(s) and 320 deletion(s). Raw diff Collapse all Expand all
652652 /// \param File File where this variable is defined.
653653 /// \param LineNo Line number.
654654 /// \param Ty Function type.
655 /// \param isLocalToUnit True if this function is not externally visible.
656 /// \param isDefinition True if this is a function definition.
657655 /// \param ScopeLine Set to the beginning of the scope this starts
658656 /// \param Flags e.g. is this function prototyped or not.
659657 /// These flags are used to emit dwarf attributes.
660 /// \param isOptimized True if optimization is ON.
658 /// \param SPFlags Additional flags specific to subprograms.
661659 /// \param TParams Function template parameters.
662660 /// \param ThrownTypes Exception types this function may throw.
663 DISubprogram *createFunction(
664 DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
665 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
666 bool isDefinition, unsigned ScopeLine,
667 DINode::DIFlags Flags = DINode::FlagZero, bool isOptimized = false,
668 DITemplateParameterArray TParams = nullptr,
669 DISubprogram *Decl = nullptr, DITypeArray ThrownTypes = nullptr);
661 DISubprogram *
662 createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName,
663 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
664 unsigned ScopeLine, DINode::DIFlags Flags = DINode::FlagZero,
665 DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
666 DITemplateParameterArray TParams = nullptr,
667 DISubprogram *Decl = nullptr,
668 DITypeArray ThrownTypes = nullptr);
670669
671670 /// Identical to createFunction,
672671 /// except that the resulting DbgNode is meant to be RAUWed.
673672 DISubprogram *createTempFunctionFwdDecl(
674673 DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
675 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
676 bool isDefinition, unsigned ScopeLine,
677 DINode::DIFlags Flags = DINode::FlagZero, bool isOptimized = false,
674 unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
675 DINode::DIFlags Flags = DINode::FlagZero,
676 DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
678677 DITemplateParameterArray TParams = nullptr,
679678 DISubprogram *Decl = nullptr, DITypeArray ThrownTypes = nullptr);
680679
686685 /// \param File File where this variable is defined.
687686 /// \param LineNo Line number.
688687 /// \param Ty Function type.
689 /// \param isLocalToUnit True if this function is not externally visible..
690 /// \param isDefinition True if this is a function definition.
691 /// \param Virtuality Attributes describing virtualness. e.g. pure
692 /// virtual function.
693688 /// \param VTableIndex Index no of this method in virtual table, or -1u if
694689 /// unrepresentable.
695690 /// \param ThisAdjustment
698693 /// \param VTableHolder Type that holds vtable.
699694 /// \param Flags e.g. is this function prototyped or not.
700695 /// This flags are used to emit dwarf attributes.
701 /// \param isOptimized True if optimization is ON.
696 /// \param SPFlags Additional flags specific to subprograms.
702697 /// \param TParams Function template parameters.
703698 /// \param ThrownTypes Exception types this function may throw.
704 DISubprogram *createMethod(
705 DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
706 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
707 bool isDefinition, unsigned Virtuality = 0, unsigned VTableIndex = 0,
708 int ThisAdjustment = 0, DIType *VTableHolder = nullptr,
709 DINode::DIFlags Flags = DINode::FlagZero, bool isOptimized = false,
710 DITemplateParameterArray TParams = nullptr,
711 DITypeArray ThrownTypes = nullptr);
699 DISubprogram *
700 createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName,
701 DIFile *File, unsigned LineNo, DISubroutineType *Ty,
702 unsigned VTableIndex = 0, int ThisAdjustment = 0,
703 DIType *VTableHolder = nullptr,
704 DINode::DIFlags Flags = DINode::FlagZero,
705 DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
706 DITemplateParameterArray TParams = nullptr,
707 DITypeArray ThrownTypes = nullptr);
712708
713709 /// This creates new descriptor for a namespace with the specified
714710 /// parent scope.
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 // TODO: Add other DW-based macros.
13 #if !(defined HANDLE_DI_FLAG || defined HANDLE_DISP_FLAG)
14 #error "Missing macro definition of HANDLE_DI*"
15 #endif
16
1417 #ifndef HANDLE_DI_FLAG
15 #error "Missing macro definition of HANDLE_DI_FLAG"
18 #define HANDLE_DI_FLAG(ID, NAME)
1619 #endif
20
21 #ifndef HANDLE_DISP_FLAG
22 #define HANDLE_DISP_FLAG(ID, NAME)
23 #endif
24
25 // General flags kept in DINode.
1726
1827 HANDLE_DI_FLAG(0, Zero) // Use it as zero value.
1928 // For example: void foo(DIFlags Flags = FlagZero).
6372 #undef DI_FLAG_LARGEST_NEEDED
6473 #endif
6574
75 // Subprogram-specific flags kept in DISubprogram.
76
77 // Use this as a zero/initialization value.
78 // For example: void foo(DISPFlags Flags = SPFlagZero).
79 HANDLE_DISP_FLAG(0, Zero)
80 // Virtuality is a two-bit valued field.
81 HANDLE_DISP_FLAG(0u, Nonvirtual)
82 HANDLE_DISP_FLAG(1u, Virtual)
83 HANDLE_DISP_FLAG(2u, PureVirtual)
84 HANDLE_DISP_FLAG((1u << 2), LocalToUnit)
85 HANDLE_DISP_FLAG((1u << 3), Definition)
86 HANDLE_DISP_FLAG((1u << 4), Optimized)
87
88 #ifdef DISP_FLAG_LARGEST_NEEDED
89 // Intended to be used with ADT/BitmaskEnum.h.
90 // NOTE: Always must be equal to largest flag, check this when adding new flags.
91 HANDLE_DISP_FLAG((1 << 4), Largest)
92 #undef DISP_FLAG_LARGEST_NEEDED
93 #endif
94
6695 #undef HANDLE_DI_FLAG
96 #undef HANDLE_DISP_FLAG
16131613 /// negative.
16141614 int ThisAdjustment;
16151615
1616 // Virtuality can only assume three values, so we can pack
1617 // in 2 bits (none/pure/pure_virtual).
1618 unsigned Virtuality : 2;
1619
1620 // These are boolean flags so one bit is enough.
1621 // MSVC starts a new container field every time the base
1622 // type changes so we can't use 'bool' to ensure these bits
1623 // are packed.
1624 unsigned IsLocalToUnit : 1;
1625 unsigned IsDefinition : 1;
1626 unsigned IsOptimized : 1;
1627
1628 unsigned Padding : 3;
1629
1616 public:
1617 /// Debug info subprogram flags.
1618 enum DISPFlags : uint32_t {
1619 #define HANDLE_DISP_FLAG(ID, NAME) SPFlag##NAME = ID,
1620 #define DISP_FLAG_LARGEST_NEEDED
1621 #include "llvm/IR/DebugInfoFlags.def"
1622 SPFlagVirtuality = SPFlagNonvirtual | SPFlagVirtual | SPFlagPureVirtual,
1623 LLVM_MARK_AS_BITMASK_ENUM(SPFlagLargest)
1624 };
1625 // Helper for converting old bitfields to new flags word.
1626 static DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition,
1627 bool IsOptimized,
1628 unsigned Virtuality = SPFlagNonvirtual) {
1629 // We're assuming virtuality is the low-order field.
1630 static_assert(SPFlagVirtual == dwarf::DW_VIRTUALITY_virtual &&
1631 SPFlagPureVirtual == dwarf::DW_VIRTUALITY_pure_virtual,
1632 "Virtuality constant mismatch");
1633 return static_cast((Virtuality & SPFlagVirtuality) |
1634 (IsLocalToUnit ? SPFlagLocalToUnit : 0) |
1635 (IsDefinition ? SPFlagDefinition : 0) |
1636 (IsOptimized ? SPFlagOptimized : 0));
1637 }
1638
1639 private:
16301640 DIFlags Flags;
1641 DISPFlags SPFlags;
16311642
16321643 DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
1633 unsigned ScopeLine, unsigned Virtuality, unsigned VirtualIndex,
1634 int ThisAdjustment, DIFlags Flags, bool IsLocalToUnit,
1635 bool IsDefinition, bool IsOptimized, ArrayRef Ops)
1644 unsigned ScopeLine, unsigned VirtualIndex, int ThisAdjustment,
1645 DIFlags Flags, DISPFlags SPFlags, ArrayRef Ops)
16361646 : DILocalScope(C, DISubprogramKind, Storage, dwarf::DW_TAG_subprogram,
16371647 Ops),
16381648 Line(Line), ScopeLine(ScopeLine), VirtualIndex(VirtualIndex),
1639 ThisAdjustment(ThisAdjustment), Virtuality(Virtuality),
1640 IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition),
1641 IsOptimized(IsOptimized), Flags(Flags) {
1649 ThisAdjustment(ThisAdjustment), Flags(Flags), SPFlags(SPFlags) {
16421650 static_assert(dwarf::DW_VIRTUALITY_max < 4, "Virtuality out of range");
1643 assert(Virtuality < 4 && "Virtuality out of range");
16441651 }
16451652 ~DISubprogram() = default;
16461653
16471654 static DISubprogram *
16481655 getImpl(LLVMContext &Context, DIScopeRef Scope, StringRef Name,
16491656 StringRef LinkageName, DIFile *File, unsigned Line,
1650 DISubroutineType *Type, bool IsLocalToUnit, bool IsDefinition,
1651 unsigned ScopeLine, DITypeRef ContainingType, unsigned Virtuality,
1657 DISubroutineType *Type, unsigned ScopeLine, DITypeRef ContainingType,
16521658 unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
1653 bool IsOptimized, DICompileUnit *Unit,
1659 DISPFlags SPFlags, DICompileUnit *Unit,
16541660 DITemplateParameterArray TemplateParams, DISubprogram *Declaration,
16551661 DINodeArray RetainedNodes, DITypeArray ThrownTypes,
16561662 StorageType Storage, bool ShouldCreate = true) {
16571663 return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
16581664 getCanonicalMDString(Context, LinkageName), File, Line, Type,
1659 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1660 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1661 Unit, TemplateParams.get(), Declaration, RetainedNodes.get(),
1662 ThrownTypes.get(), Storage, ShouldCreate);
1663 }
1664 static DISubprogram *
1665 getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
1666 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
1667 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
1668 Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
1669 int ThisAdjustment, DIFlags Flags, bool IsOptimized, Metadata *Unit,
1670 Metadata *TemplateParams, Metadata *Declaration, Metadata *RetainedNodes,
1671 Metadata *ThrownTypes, StorageType Storage, bool ShouldCreate = true);
1665 ScopeLine, ContainingType, VirtualIndex, ThisAdjustment,
1666 Flags, SPFlags, Unit, TemplateParams.get(), Declaration,
1667 RetainedNodes.get(), ThrownTypes.get(), Storage,
1668 ShouldCreate);
1669 }
1670 static DISubprogram *getImpl(LLVMContext &Context, Metadata *Scope,
1671 MDString *Name, MDString *LinkageName,
1672 Metadata *File, unsigned Line, Metadata *Type,
1673 unsigned ScopeLine, Metadata *ContainingType,
1674 unsigned VirtualIndex, int ThisAdjustment,
1675 DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
1676 Metadata *TemplateParams, Metadata *Declaration,
1677 Metadata *RetainedNodes, Metadata *ThrownTypes,
1678 StorageType Storage, bool ShouldCreate = true);
16721679
16731680 TempDISubprogram cloneImpl() const {
16741681 return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
1675 getFile(), getLine(), getType(), isLocalToUnit(),
1676 isDefinition(), getScopeLine(), getContainingType(),
1677 getVirtuality(), getVirtualIndex(), getThisAdjustment(),
1678 getFlags(), isOptimized(), getUnit(),
1679 getTemplateParams(), getDeclaration(), getRetainedNodes(),
1680 getThrownTypes());
1681 }
1682
1683 public:
1684 DEFINE_MDNODE_GET(DISubprogram,
1685 (DIScopeRef Scope, StringRef Name, StringRef LinkageName,
1686 DIFile *File, unsigned Line, DISubroutineType *Type,
1687 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
1688 DITypeRef ContainingType, unsigned Virtuality,
1689 unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
1690 bool IsOptimized, DICompileUnit *Unit,
1691 DITemplateParameterArray TemplateParams = nullptr,
1692 DISubprogram *Declaration = nullptr,
1693 DINodeArray RetainedNodes = nullptr,
1694 DITypeArray ThrownTypes = nullptr),
1695 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
1696 IsDefinition, ScopeLine, ContainingType, Virtuality,
1697 VirtualIndex, ThisAdjustment, Flags, IsOptimized, Unit,
1698 TemplateParams, Declaration, RetainedNodes, ThrownTypes))
1682 getFile(), getLine(), getType(), getScopeLine(),
1683 getContainingType(), getVirtualIndex(),
1684 getThisAdjustment(), getFlags(), getSPFlags(),
1685 getUnit(), getTemplateParams(), getDeclaration(),
1686 getRetainedNodes(), getThrownTypes());
1687 }
1688
1689 public:
1690 DEFINE_MDNODE_GET(
1691 DISubprogram,
1692 (DIScopeRef Scope, StringRef Name, StringRef LinkageName, DIFile *File,
1693 unsigned Line, DISubroutineType *Type, unsigned ScopeLine,
1694 DITypeRef ContainingType, unsigned VirtualIndex, int ThisAdjustment,
1695 DIFlags Flags, DISPFlags SPFlags, DICompileUnit *Unit,
1696 DITemplateParameterArray TemplateParams = nullptr,
1697 DISubprogram *Declaration = nullptr, DINodeArray RetainedNodes = nullptr,
1698 DITypeArray ThrownTypes = nullptr),
1699 (Scope, Name, LinkageName, File, Line, Type, ScopeLine, ContainingType,
1700 VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams,
1701 Declaration, RetainedNodes, ThrownTypes))
1702
16991703 DEFINE_MDNODE_GET(
17001704 DISubprogram,
17011705 (Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File,
1702 unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
1703 unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality,
1704 unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
1705 bool IsOptimized, Metadata *Unit, Metadata *TemplateParams = nullptr,
1706 Metadata *Declaration = nullptr, Metadata *RetainedNodes = nullptr,
1707 Metadata *ThrownTypes = nullptr),
1708 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
1709 ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment,
1710 Flags, IsOptimized, Unit, TemplateParams, Declaration, RetainedNodes,
1711 ThrownTypes))
1706 unsigned Line, Metadata *Type, unsigned ScopeLine,
1707 Metadata *ContainingType, unsigned VirtualIndex, int ThisAdjustment,
1708 DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
1709 Metadata *TemplateParams = nullptr, Metadata *Declaration = nullptr,
1710 Metadata *RetainedNodes = nullptr, Metadata *ThrownTypes = nullptr),
1711 (Scope, Name, LinkageName, File, Line, Type, ScopeLine, ContainingType,
1712 VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit, TemplateParams,
1713 Declaration, RetainedNodes, ThrownTypes))
17121714
17131715 TempDISubprogram clone() const { return cloneImpl(); }
17141716
17211723
17221724 public:
17231725 unsigned getLine() const { return Line; }
1724 unsigned getVirtuality() const { return Virtuality; }
1726 unsigned getVirtuality() const { return getSPFlags() & SPFlagVirtuality; }
17251727 unsigned getVirtualIndex() const { return VirtualIndex; }
17261728 int getThisAdjustment() const { return ThisAdjustment; }
17271729 unsigned getScopeLine() const { return ScopeLine; }
17281730 DIFlags getFlags() const { return Flags; }
1729 bool isLocalToUnit() const { return IsLocalToUnit; }
1730 bool isDefinition() const { return IsDefinition; }
1731 bool isOptimized() const { return IsOptimized; }
1731 DISPFlags getSPFlags() const { return SPFlags; }
1732 bool isLocalToUnit() const { return getSPFlags() & SPFlagLocalToUnit; }
1733 bool isDefinition() const { return getSPFlags() & SPFlagDefinition; }
1734 bool isOptimized() const { return getSPFlags() & SPFlagOptimized; }
17321735
17331736 bool isArtificial() const { return getFlags() & FlagArtificial; }
17341737 bool isPrivate() const {
45484548 return Lex.Error(
45494549 Loc,
45504550 "missing 'distinct', required for !DISubprogram when 'isDefinition'");
4551
4551 DISubprogram::DISPFlags SPFlags = DISubprogram::toSPFlags(
4552 isLocal.Val, isDefinition.Val, isOptimized.Val, virtuality.Val);
45524553 Result = GET_OR_DISTINCT(
45534554 DISubprogram,
45544555 (Context, scope.Val, name.Val, linkageName.Val, file.Val, line.Val,
4555 type.Val, isLocal.Val, isDefinition.Val, scopeLine.Val,
4556 containingType.Val, virtuality.Val, virtualIndex.Val, thisAdjustment.Val,
4557 flags.Val, isOptimized.Val, unit.Val, templateParams.Val,
4556 type.Val, scopeLine.Val, containingType.Val, virtualIndex.Val,
4557 thisAdjustment.Val, flags.Val, SPFlags, unit.Val, templateParams.Val,
45584558 declaration.Val, retainedNodes.Val, thrownTypes.Val));
45594559 return false;
45604560 }
14191419 bool HasFn = Offset && !HasUnit;
14201420 bool HasThisAdj = Record.size() >= 20;
14211421 bool HasThrownTypes = Record.size() >= 21;
1422 DISubprogram::DISPFlags SPFlags = DISubprogram::toSPFlags(
1423 /*IsLocalToUnit=*/Record[7], /*IsDefinition=*/Record[8],
1424 /*IsOptimized=*/Record[14], /*Virtuality=*/Record[11]);
14221425 DISubprogram *SP = GET_OR_DISTINCT(
14231426 DISubprogram,
14241427 (Context,
14281431 getMDOrNull(Record[4]), // file
14291432 Record[5], // line
14301433 getMDOrNull(Record[6]), // type
1431 Record[7], // isLocal
1432 Record[8], // isDefinition
14331434 Record[9], // scopeLine
14341435 getDITypeRefOrNull(Record[10]), // containingType
1435 Record[11], // virtuality
14361436 Record[12], // virtualIndex
14371437 HasThisAdj ? Record[19] : 0, // thisAdjustment
14381438 static_cast(Record[13]), // flags
1439 Record[14], // isOptimized
1439 SPFlags, // SPFlags
14401440 HasUnit ? CUorFn : nullptr, // unit
14411441 getMDOrNull(Record[15 + Offset]), // templateParams
14421442 getMDOrNull(Record[16 + Offset]), // declaration
13941394 Unit /* File */,
13951395 0 /* Line 0 is reserved for compiler-generated code. */,
13961396 DB.createSubroutineType(DB.getOrCreateTypeArray(None)), /* void type */
1397 false, true, 0, /* Line 0 is reserved for compiler-generated code. */
1397 0, /* Line 0 is reserved for compiler-generated code. */
13981398 DINode::DIFlags::FlagArtificial /* Compiler-generated code. */,
1399 true /* Outlined code is optimized code by definition. */);
1399 /* Outlined code is optimized code by definition. */
1400 DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
14001401
14011402 // Don't add any new variables to the subprogram.
14021403 DB.finalizeSubprogram(OutlinedSP);
750750
751751 DISubprogram *DIBuilder::createFunction(
752752 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
753 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
754 bool isDefinition, unsigned ScopeLine, DINode::DIFlags Flags,
755 bool isOptimized, DITemplateParameterArray TParams, DISubprogram *Decl,
753 unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
754 DINode::DIFlags Flags, DISubprogram::DISPFlags SPFlags,
755 DITemplateParameterArray TParams, DISubprogram *Decl,
756756 DITypeArray ThrownTypes) {
757 bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
757758 auto *Node = getSubprogram(
758 /* IsDistinct = */ isDefinition, VMContext,
759 getNonCompileUnitScope(Context), Name, LinkageName, File, LineNo, Ty,
760 isLocalToUnit, isDefinition, ScopeLine, nullptr, 0, 0, 0, Flags,
761 isOptimized, isDefinition ? CUNode : nullptr, TParams, Decl,
759 /*IsDistinct=*/IsDefinition, VMContext, getNonCompileUnitScope(Context),
760 Name, LinkageName, File, LineNo, Ty, ScopeLine, nullptr, 0, 0, Flags,
761 SPFlags, IsDefinition ? CUNode : nullptr, TParams, Decl,
762762 MDTuple::getTemporary(VMContext, None).release(), ThrownTypes);
763763
764 if (isDefinition)
764 if (IsDefinition)
765765 AllSubprograms.push_back(Node);
766766 trackIfUnresolved(Node);
767767 return Node;
769769
770770 DISubprogram *DIBuilder::createTempFunctionFwdDecl(
771771 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
772 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
773 bool isDefinition, unsigned ScopeLine, DINode::DIFlags Flags,
774 bool isOptimized, DITemplateParameterArray TParams, DISubprogram *Decl,
772 unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
773 DINode::DIFlags Flags, DISubprogram::DISPFlags SPFlags,
774 DITemplateParameterArray TParams, DISubprogram *Decl,
775775 DITypeArray ThrownTypes) {
776 return DISubprogram::getTemporary(
777 VMContext, getNonCompileUnitScope(Context), Name, LinkageName,
778 File, LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine, nullptr,
779 0, 0, 0, Flags, isOptimized, isDefinition ? CUNode : nullptr,
780 TParams, Decl, nullptr, ThrownTypes)
776 bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
777 return DISubprogram::getTemporary(VMContext, getNonCompileUnitScope(Context),
778 Name, LinkageName, File, LineNo, Ty,
779 ScopeLine, nullptr, 0, 0, Flags, SPFlags,
780 IsDefinition ? CUNode : nullptr, TParams,
781 Decl, nullptr, ThrownTypes)
781782 .release();
782783 }
783784
784785 DISubprogram *DIBuilder::createMethod(
785786 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
786 unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
787 bool isDefinition, unsigned VK, unsigned VIndex, int ThisAdjustment,
788 DIType *VTableHolder, DINode::DIFlags Flags, bool isOptimized,
789 DITemplateParameterArray TParams, DITypeArray ThrownTypes) {
787 unsigned LineNo, DISubroutineType *Ty, unsigned VIndex, int ThisAdjustment,
788 DIType *VTableHolder, DINode::DIFlags Flags,
789 DISubprogram::DISPFlags SPFlags, DITemplateParameterArray TParams,
790 DITypeArray ThrownTypes) {
790791 assert(getNonCompileUnitScope(Context) &&
791792 "Methods should have both a Context and a context that isn't "
792793 "the compile unit.");
793794 // FIXME: Do we want to use different scope/lines?
795 bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
794796 auto *SP = getSubprogram(
795 /* IsDistinct = */ isDefinition, VMContext, cast(Context), Name,
796 LinkageName, F, LineNo, Ty, isLocalToUnit, isDefinition, LineNo,
797 VTableHolder, VK, VIndex, ThisAdjustment, Flags, isOptimized,
798 isDefinition ? CUNode : nullptr, TParams, nullptr, nullptr, ThrownTypes);
799
800 if (isDefinition)
797 /*IsDistinct=*/IsDefinition, VMContext, cast(Context), Name,
798 LinkageName, F, LineNo, Ty, LineNo, VTableHolder, VIndex, ThisAdjustment,
799 Flags, SPFlags, IsDefinition ? CUNode : nullptr, TParams, nullptr,
800 nullptr, ThrownTypes);
801
802 if (IsDefinition)
801803 AllSubprograms.push_back(SP);
802804 trackIfUnresolved(SP);
803805 return SP;
437437 auto distinctMDSubprogram = [&]() {
438438 return DISubprogram::getDistinct(
439439 MDS->getContext(), FileAndScope, MDS->getName(), LinkageName,
440 FileAndScope, MDS->getLine(), Type, MDS->isLocalToUnit(),
441 MDS->isDefinition(), MDS->getScopeLine(), ContainingType,
442 MDS->getVirtuality(), MDS->getVirtualIndex(),
443 MDS->getThisAdjustment(), MDS->getFlags(), MDS->isOptimized(), Unit,
444 TemplateParams, Declaration, Variables);
440 FileAndScope, MDS->getLine(), Type, MDS->getScopeLine(),
441 ContainingType, MDS->getVirtualIndex(), MDS->getThisAdjustment(),
442 MDS->getFlags(), MDS->getSPFlags(), Unit, TemplateParams, Declaration,
443 Variables);
445444 };
446445
447446 if (MDS->isDistinct())
449448
450449 auto *NewMDS = DISubprogram::get(
451450 MDS->getContext(), FileAndScope, MDS->getName(), LinkageName,
452 FileAndScope, MDS->getLine(), Type, MDS->isLocalToUnit(),
453 MDS->isDefinition(), MDS->getScopeLine(), ContainingType,
454 MDS->getVirtuality(), MDS->getVirtualIndex(), MDS->getThisAdjustment(),
455 MDS->getFlags(), MDS->isOptimized(), Unit, TemplateParams, Declaration,
456 Variables);
451 FileAndScope, MDS->getLine(), Type, MDS->getScopeLine(), ContainingType,
452 MDS->getVirtualIndex(), MDS->getThisAdjustment(), MDS->getFlags(),
453 MDS->getSPFlags(), Unit, TemplateParams, Declaration, Variables);
457454
458455 StringRef OldLinkageName = MDS->getLinkageName();
459456
719716 return static_cast(Flags);
720717 }
721718
719 static DISubprogram::DISPFlags
720 pack_into_DISPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized) {
721 return DISubprogram::toSPFlags(IsLocalToUnit, IsDefinition, IsOptimized);
722 }
723
722724 unsigned LLVMDebugMetadataVersion() {
723725 return DEBUG_METADATA_VERSION;
724726 }
802804 unsigned ScopeLine, LLVMDIFlags Flags, LLVMBool IsOptimized) {
803805 return wrap(unwrap(Builder)->createFunction(
804806 unwrapDI(Scope), {Name, NameLen}, {LinkageName, LinkageNameLen},
805 unwrapDI(File), LineNo, unwrapDI(Ty),
806 IsLocalToUnit, IsDefinition, ScopeLine, map_from_llvmDIFlags(Flags),
807 IsOptimized, nullptr, nullptr, nullptr));
807 unwrapDI(File), LineNo, unwrapDI(Ty), ScopeLine,
808 map_from_llvmDIFlags(Flags),
809 pack_into_DISPFlags(IsLocalToUnit, IsDefinition, IsOptimized), nullptr,
810 nullptr, nullptr));
808811 }
809812
810813
544544 DISubprogram *DISubprogram::getImpl(
545545 LLVMContext &Context, Metadata *Scope, MDString *Name,
546546 MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
547 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
548 Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
549 int ThisAdjustment, DIFlags Flags, bool IsOptimized, Metadata *Unit,
547 unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex,
548 int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
550549 Metadata *TemplateParams, Metadata *Declaration, Metadata *RetainedNodes,
551550 Metadata *ThrownTypes, StorageType Storage, bool ShouldCreate) {
552551 assert(isCanonical(Name) && "Expected canonical MDString");
553552 assert(isCanonical(LinkageName) && "Expected canonical MDString");
554 DEFINE_GETIMPL_LOOKUP(
555 DISubprogram, (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
556 IsDefinition, ScopeLine, ContainingType, Virtuality,
557 VirtualIndex, ThisAdjustment, Flags, IsOptimized, Unit,
558 TemplateParams, Declaration, RetainedNodes, ThrownTypes));
553 DEFINE_GETIMPL_LOOKUP(DISubprogram,
554 (Scope, Name, LinkageName, File, Line, Type, ScopeLine,
555 ContainingType, VirtualIndex, ThisAdjustment, Flags,
556 SPFlags, Unit, TemplateParams, Declaration,
557 RetainedNodes, ThrownTypes));
559558 SmallVector Ops = {
560559 File, Scope, Name, LinkageName, Type, Unit,
561560 Declaration, RetainedNodes, ContainingType, TemplateParams, ThrownTypes};
567566 Ops.pop_back();
568567 }
569568 }
570 DEFINE_GETIMPL_STORE_N(DISubprogram,
571 (Line, ScopeLine, Virtuality, VirtualIndex,
572 ThisAdjustment, Flags, IsLocalToUnit, IsDefinition,
573 IsOptimized),
574 Ops, Ops.size());
569 DEFINE_GETIMPL_STORE_N(
570 DISubprogram,
571 (Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags, SPFlags), Ops,
572 Ops.size());
575573 }
576574
577575 bool DISubprogram::describes(const Function *F) const {
611611 Metadata *File;
612612 unsigned Line;
613613 Metadata *Type;
614 bool IsLocalToUnit;
615 bool IsDefinition;
616614 unsigned ScopeLine;
617615 Metadata *ContainingType;
618 unsigned Virtuality;
619616 unsigned VirtualIndex;
620617 int ThisAdjustment;
621618 unsigned Flags;
622 bool IsOptimized;
619 unsigned SPFlags;
623620 Metadata *Unit;
624621 Metadata *TemplateParams;
625622 Metadata *Declaration;
628625
629626 MDNodeKeyImpl(Metadata *Scope, MDString *Name, MDString *LinkageName,
630627 Metadata *File, unsigned Line, Metadata *Type,
631 bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
632 Metadata *ContainingType, unsigned Virtuality,
628 unsigned ScopeLine, Metadata *ContainingType,
633629 unsigned VirtualIndex, int ThisAdjustment, unsigned Flags,
634 bool IsOptimized, Metadata *Unit, Metadata *TemplateParams,
630 unsigned SPFlags, Metadata *Unit, Metadata *TemplateParams,
635631 Metadata *Declaration, Metadata *RetainedNodes,
636632 Metadata *ThrownTypes)
637633 : Scope(Scope), Name(Name), LinkageName(LinkageName), File(File),
638 Line(Line), Type(Type), IsLocalToUnit(IsLocalToUnit),
639 IsDefinition(IsDefinition), ScopeLine(ScopeLine),
640 ContainingType(ContainingType), Virtuality(Virtuality),
641 VirtualIndex(VirtualIndex), ThisAdjustment(ThisAdjustment),
642 Flags(Flags), IsOptimized(IsOptimized), Unit(Unit),
643 TemplateParams(TemplateParams), Declaration(Declaration),
634 Line(Line), Type(Type), ScopeLine(ScopeLine),
635 ContainingType(ContainingType), VirtualIndex(VirtualIndex),
636 ThisAdjustment(ThisAdjustment), Flags(Flags), SPFlags(SPFlags),
637 Unit(Unit), TemplateParams(TemplateParams), Declaration(Declaration),
644638 RetainedNodes(RetainedNodes), ThrownTypes(ThrownTypes) {}
645639 MDNodeKeyImpl(const DISubprogram *N)
646640 : Scope(N->getRawScope()), Name(N->getRawName()),
647641 LinkageName(N->getRawLinkageName()), File(N->getRawFile()),
648 Line(N->getLine()), Type(N->getRawType()),
649 IsLocalToUnit(N->isLocalToUnit()), IsDefinition(N->isDefinition()),
650 ScopeLine(N->getScopeLine()), ContainingType(N->getRawContainingType()),
651 Virtuality(N->getVirtuality()), VirtualIndex(N->getVirtualIndex()),
642 Line(N->getLine()), Type(N->getRawType()), ScopeLine(N->getScopeLine()),
643 ContainingType(N->getRawContainingType()),
644 VirtualIndex(N->getVirtualIndex()),
652645 ThisAdjustment(N->getThisAdjustment()), Flags(N->getFlags()),
653 IsOptimized(N->isOptimized()), Unit(N->getRawUnit()),
646 SPFlags(N->getSPFlags()), Unit(N->getRawUnit()),
654647 TemplateParams(N->getRawTemplateParams()),
655 Declaration(N->getRawDeclaration()), RetainedNodes(N->getRawRetainedNodes()),
648 Declaration(N->getRawDeclaration()),
649 RetainedNodes(N->getRawRetainedNodes()),
656650 ThrownTypes(N->getRawThrownTypes()) {}
657651
658652 bool isKeyOf(const DISubprogram *RHS) const {
659653 return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
660654 LinkageName == RHS->getRawLinkageName() &&
661655 File == RHS->getRawFile() && Line == RHS->getLine() &&
662 Type == RHS->getRawType() && IsLocalToUnit == RHS->isLocalToUnit() &&
663 IsDefinition == RHS->isDefinition() &&
664 ScopeLine == RHS->getScopeLine() &&
656 Type == RHS->getRawType() && ScopeLine == RHS->getScopeLine() &&
665657 ContainingType == RHS->getRawContainingType() &&
666 Virtuality == RHS->getVirtuality() &&
667658 VirtualIndex == RHS->getVirtualIndex() &&
668659 ThisAdjustment == RHS->getThisAdjustment() &&
669 Flags == RHS->getFlags() && IsOptimized == RHS->isOptimized() &&
660 Flags == RHS->getFlags() && SPFlags == RHS->getSPFlags() &&
670661 Unit == RHS->getUnit() &&
671662 TemplateParams == RHS->getRawTemplateParams() &&
672663 Declaration == RHS->getRawDeclaration() &&
674665 ThrownTypes == RHS->getRawThrownTypes();
675666 }
676667
668 bool isDefinition() const { return SPFlags & DISubprogram::SPFlagDefinition; }
669
677670 unsigned getHashValue() const {
678671 // If this is a declaration inside an ODR type, only hash the type and the
679672 // name. Otherwise the hash will be stronger than
680673 // MDNodeSubsetEqualImpl::isDeclarationOfODRMember().
681 if (!IsDefinition && LinkageName)
674 if (!isDefinition() && LinkageName)
682675 if (auto *CT = dyn_cast_or_null(Scope))
683676 if (CT->getRawIdentifier())
684677 return hash_combine(LinkageName, Scope);
695688 using KeyTy = MDNodeKeyImpl;
696689
697690 static bool isSubsetEqual(const KeyTy &LHS, const DISubprogram *RHS) {
698 return isDeclarationOfODRMember(LHS.IsDefinition, LHS.Scope,
691 return isDeclarationOfODRMember(LHS.isDefinition(), LHS.Scope,
699692 LHS.LinkageName, LHS.TemplateParams, RHS);
700693 }
701694
9595 continue;
9696
9797 auto SPType = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
98 bool IsLocalToUnit = F.hasPrivateLinkage() || F.hasInternalLinkage();
99 auto SP =
100 DIB.createFunction(CU, F.getName(), F.getName(), File, NextLine, SPType,
101 IsLocalToUnit, /*isDefinition=*/true, NextLine,
102 DINode::FlagZero, /*isOptimized=*/true);
98 DISubprogram::DISPFlags SPFlags =
99 DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized;
100 if (F.hasPrivateLinkage() || F.hasInternalLinkage())
101 SPFlags |= DISubprogram::SPFlagLocalToUnit;
102 auto SP = DIB.createFunction(CU, F.getName(), F.getName(), File, NextLine,
103 SPType, NextLine, DINode::FlagZero, SPFlags);
103104 F.setSubprogram(SP);
104105 for (BasicBlock &BB : F) {
105106 // Attach debug locations.
256256 LLVMContext Ctx;
257257 DIFile *DIF = DIFile::getDistinct(Ctx, "filename", "");
258258 DISubprogram *DIS = DISubprogram::getDistinct(
259 Ctx, nullptr, "", "", DIF, 0, nullptr, false, false, 0, nullptr, 0, 0, 0,
260 DINode::FlagZero, false, nullptr);
259 Ctx, nullptr, "", "", DIF, 0, nullptr, 0, nullptr, 0, 0, DINode::FlagZero,
260 DISubprogram::SPFlagZero, nullptr);
261261 DILocation *DIL = DILocation::get(Ctx, 1, 5, DIS);
262262 DebugLoc DL(DIL);
263263 MachineInstr *MI = MF->CreateMachineInstr(MCID, DL);
480480 auto CU =
481481 DIB.createCompileUnit(dwarf::DW_LANG_Swift, File, "swiftc", true, "", 0);
482482 auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
483 auto NoErr = DIB.createFunction(CU, "noerr", "", File, 1, Type, false, true, 1,
484 DINode::FlagZero, true);
483 auto NoErr = DIB.createFunction(
484 CU, "noerr", "", File, 1, Type, 1, DINode::FlagZero,
485 DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
485486 EXPECT_TRUE(!NoErr->getThrownTypes());
486487 auto Int = DIB.createBasicType("Int", 64, dwarf::DW_ATE_signed);
487488 auto Error = DIB.getOrCreateArray({Int});
488 auto Err =
489 DIB.createFunction(CU, "err", "", File, 1, Type, false, true, 1,
490 DINode::FlagZero, true, nullptr, nullptr, Error.get());
489 auto Err = DIB.createFunction(
490 CU, "err", "", File, 1, Type, 1, DINode::FlagZero,
491 DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized, nullptr,
492 nullptr, Error.get());
491493 EXPECT_TRUE(Err->getThrownTypes().get() == Error.get());
492494 DIB.finalize();
493495 }
500502 DIB.createFile("F.CBL", "/"), "llvm-cobol74",
501503 true, "", 0);
502504 auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
503 auto SP = DIB.createFunction(CU, "foo", "", File, 1, Type, false, true, 1,
504 DINode::FlagZero, true);
505 auto SP = DIB.createFunction(
506 CU, "foo", "", File, 1, Type, 1, DINode::FlagZero,
507 DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
505508 F->setSubprogram(SP);
506509 AllocaInst *I = Builder.CreateAlloca(Builder.getInt8Ty());
507 auto BarSP = DIB.createFunction(CU, "bar", "", File, 1, Type, false, true, 1,
508 DINode::FlagZero, true);
510 auto BarSP = DIB.createFunction(
511 CU, "bar", "", File, 1, Type, 1, DINode::FlagZero,
512 DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
509513 auto BadScope = DIB.createLexicalBlockFile(BarSP, File, 0);
510514 I->setDebugLoc(DebugLoc::get(2, 0, BadScope));
511515 DIB.finalize();
520524 /*isOptimized=*/true, /*Flags=*/"",
521525 /*Runtime Version=*/0);
522526 auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
523 auto SP = DIB.createFunction(CU, "foo", /*LinkageName=*/"", File,
524 /*LineNo=*/1, Type, /*isLocalToUnit=*/false,
525 /*isDefinition=*/true, /*ScopeLine=*/2,
526 DINode::FlagZero, /*isOptimized=*/true);
527 auto SP = DIB.createFunction(
528 CU, "foo", /*LinkageName=*/"", File,
529 /*LineNo=*/1, Type, /*ScopeLine=*/2, DINode::FlagZero,
530 DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
527531 EXPECT_TRUE(SP->isDistinct());
528532
529533 F->setSubprogram(SP);
610614 0);
611615 auto SPType = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
612616 auto SP =
613 DIB.createFunction(CU, "foo", "foo", File, 1, SPType, false, true, 1);
617 DIB.createFunction(CU, "foo", "foo", File, 1, SPType, 1, DINode::FlagZero,
618 DISubprogram::SPFlagDefinition);
614619 DebugLoc DL1 = DILocation::get(Ctx, 2, 0, SP);
615620 DebugLoc DL2 = DILocation::get(Ctx, 3, 0, SP);
616621
8383 getNode(nullptr));
8484 }
8585 DISubprogram *getSubprogram() {
86 return DISubprogram::getDistinct(Context, nullptr, "", "", nullptr, 0,
87 nullptr, false, false, 0, nullptr, 0, 0, 0,
88 DINode::FlagZero, false, nullptr);
86 return DISubprogram::getDistinct(
87 Context, nullptr, "", "", nullptr, 0, nullptr, 0, nullptr, 0, 0,
88 DINode::FlagZero, DISubprogram::SPFlagZero, nullptr);
8989 }
9090 DIFile *getFile() {
9191 return DIFile::getDistinct(Context, "file.c", "/path/to/dir");
928928 // Different function, same inlined-at.
929929 auto *F = getFile();
930930 auto *SP1 = DISubprogram::getDistinct(Context, F, "a", "a", F, 0, nullptr,
931 false, false, 0, nullptr, 0, 0, 0,
932 DINode::FlagZero, false, nullptr);
931 0, nullptr, 0, 0, DINode::FlagZero,
932 DISubprogram::SPFlagZero, nullptr);
933933 auto *SP2 = DISubprogram::getDistinct(Context, F, "b", "b", F, 0, nullptr,
934 false, false, 0, nullptr, 0, 0, 0,
935 DINode::FlagZero, false, nullptr);
934 0, nullptr, 0, 0, DINode::FlagZero,
935 DISubprogram::SPFlagZero, nullptr);
936936
937937 auto *I = DILocation::get(Context, 2, 7, N);
938938 auto *A = DILocation::get(Context, 1, 6, SP1, I);
17041704 MDTuple *RetainedNodes = getTuple();
17051705 MDTuple *ThrownTypes = getTuple();
17061706 DICompileUnit *Unit = getUnit();
1707 DISubprogram::DISPFlags SPFlags =
1708 static_cast(Virtuality);
1709 assert(!IsLocalToUnit && IsDefinition && !IsOptimized &&
1710 "bools and SPFlags have to match");
1711 SPFlags |= DISubprogram::SPFlagDefinition;
17071712
17081713 auto *N = DISubprogram::get(
1709 Context, Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
1710 IsDefinition, ScopeLine, ContainingType, Virtuality, VirtualIndex,
1711 ThisAdjustment, Flags, IsOptimized, Unit, TemplateParams, Declaration,
1712 RetainedNodes, ThrownTypes);
1714 Context, Scope, Name, LinkageName, File, Line, Type, ScopeLine,
1715 ContainingType, VirtualIndex, ThisAdjustment, Flags, SPFlags, Unit,
1716 TemplateParams, Declaration, RetainedNodes, ThrownTypes);
17131717
17141718 EXPECT_EQ(dwarf::DW_TAG_subprogram, N->getTag());
17151719 EXPECT_EQ(Scope, N->getScope());
17321736 EXPECT_EQ(Declaration, N->getDeclaration());
17331737 EXPECT_EQ(RetainedNodes, N->getRetainedNodes().get());
17341738 EXPECT_EQ(ThrownTypes, N->getThrownTypes().get());
1735 EXPECT_EQ(N, DISubprogram::get(
1736 Context, Scope, Name, LinkageName, File, Line, Type,
1737 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1738 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1739 Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1740
1741 EXPECT_NE(N, DISubprogram::get(
1742 Context, getCompositeType(), Name, LinkageName, File, Line,
1743 Type, IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1744 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1745 Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1746 EXPECT_NE(N, DISubprogram::get(
1747 Context, Scope, "other", LinkageName, File, Line, Type,
1748 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1749 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1750 Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1751 EXPECT_NE(N, DISubprogram::get(
1752 Context, Scope, Name, "other", File, Line, Type,
1753 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1754 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1755 Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1756 EXPECT_NE(N, DISubprogram::get(
1757 Context, Scope, Name, LinkageName, getFile(), Line, Type,
1758 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1759 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1760 Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1761 EXPECT_NE(N, DISubprogram::get(
1762 Context, Scope, Name, LinkageName, File, Line + 1, Type,
1763 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1764 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1765 Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1739 EXPECT_EQ(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1740 Type, ScopeLine, ContainingType, VirtualIndex,
1741 ThisAdjustment, Flags, SPFlags, Unit,
1742 TemplateParams, Declaration, RetainedNodes,
1743 ThrownTypes));
1744
1745 EXPECT_NE(N, DISubprogram::get(Context, getCompositeType(), Name, LinkageName,
1746 File, Line, Type, ScopeLine, ContainingType,
1747 VirtualIndex, ThisAdjustment, Flags, SPFlags,
1748 Unit, TemplateParams, Declaration,
1749 RetainedNodes, ThrownTypes));
1750 EXPECT_NE(N, DISubprogram::get(Context, Scope, "other", LinkageName, File,
1751 Line, Type, ScopeLine, ContainingType,
1752 VirtualIndex, ThisAdjustment, Flags, SPFlags,
1753 Unit, TemplateParams, Declaration,
1754 RetainedNodes, ThrownTypes));
1755 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, "other", File, Line,
1756 Type, ScopeLine, ContainingType, VirtualIndex,
1757 ThisAdjustment, Flags, SPFlags, Unit,
1758 TemplateParams, Declaration, RetainedNodes,
1759 ThrownTypes));
1760 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, getFile(),
1761 Line, Type, ScopeLine, ContainingType,
1762 VirtualIndex, ThisAdjustment, Flags, SPFlags,
1763 Unit, TemplateParams, Declaration,
1764 RetainedNodes, ThrownTypes));
1765 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File,
1766 Line + 1, Type, ScopeLine, ContainingType,
1767 VirtualIndex, ThisAdjustment, Flags, SPFlags,
1768 Unit, TemplateParams, Declaration,
1769 RetainedNodes, ThrownTypes));
17661770 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1767 getSubroutineType(), IsLocalToUnit,
1768 IsDefinition, ScopeLine, ContainingType,
1769 Virtuality, VirtualIndex, ThisAdjustment,
1770 Flags, IsOptimized, Unit, TemplateParams,
1771 Declaration, RetainedNodes, ThrownTypes));
1771 getSubroutineType(), ScopeLine, ContainingType,
1772 VirtualIndex, ThisAdjustment, Flags, SPFlags,
1773 Unit, TemplateParams, Declaration,
1774 RetainedNodes, ThrownTypes));
17721775 EXPECT_NE(N, DISubprogram::get(
17731776 Context, Scope, Name, LinkageName, File, Line, Type,
1774 !IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1775 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1776 Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1777 ScopeLine, ContainingType, VirtualIndex, ThisAdjustment,
1778 Flags, SPFlags ^ DISubprogram::SPFlagLocalToUnit, Unit,
1779 TemplateParams, Declaration, RetainedNodes, ThrownTypes));
17771780 EXPECT_NE(N, DISubprogram::get(
17781781 Context, Scope, Name, LinkageName, File, Line, Type,
1779 IsLocalToUnit, !IsDefinition, ScopeLine, ContainingType,
1780 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1781 Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1782 ScopeLine, ContainingType, VirtualIndex, ThisAdjustment,
1783 Flags, SPFlags ^ DISubprogram::SPFlagDefinition, Unit,
1784 TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1785 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1786 Type, ScopeLine + 1, ContainingType,
1787 VirtualIndex, ThisAdjustment, Flags, SPFlags,
1788 Unit, TemplateParams, Declaration,
1789 RetainedNodes, ThrownTypes));
1790 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1791 Type, ScopeLine, getCompositeType(),
1792 VirtualIndex, ThisAdjustment, Flags, SPFlags,
1793 Unit, TemplateParams, Declaration,
1794 RetainedNodes, ThrownTypes));
17821795 EXPECT_NE(N, DISubprogram::get(
17831796 Context, Scope, Name, LinkageName, File, Line, Type,
1784 IsLocalToUnit, IsDefinition, ScopeLine + 1, ContainingType,
1785 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1786 Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1797 ScopeLine, ContainingType, VirtualIndex, ThisAdjustment,
1798 Flags, SPFlags ^ DISubprogram::SPFlagVirtual, Unit,
1799 TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1800 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1801 Type, ScopeLine, ContainingType,
1802 VirtualIndex + 1, ThisAdjustment, Flags,
1803 SPFlags, Unit, TemplateParams, Declaration,
1804 RetainedNodes, ThrownTypes));
17871805 EXPECT_NE(N, DISubprogram::get(
17881806 Context, Scope, Name, LinkageName, File, Line, Type,
1789 IsLocalToUnit, IsDefinition, ScopeLine, getCompositeType(),
1790 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1791 Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes));
1807 ScopeLine, ContainingType, VirtualIndex, ThisAdjustment,
1808 Flags, SPFlags ^ DISubprogram::SPFlagOptimized, Unit,
1809 TemplateParams, Declaration, RetainedNodes, ThrownTypes));
17921810 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1793 Type, IsLocalToUnit, IsDefinition, ScopeLine,
1794 ContainingType, Virtuality + 1, VirtualIndex,
1795 ThisAdjustment, Flags, IsOptimized, Unit,
1811 Type, ScopeLine, ContainingType, VirtualIndex,
1812 ThisAdjustment, Flags, SPFlags, nullptr,
17961813 TemplateParams, Declaration, RetainedNodes,
17971814 ThrownTypes));
1815 EXPECT_NE(N,
1816 DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1817 Type, ScopeLine, ContainingType, VirtualIndex,
1818 ThisAdjustment, Flags, SPFlags, Unit, getTuple(),
1819 Declaration, RetainedNodes, ThrownTypes));
17981820 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1799 Type, IsLocalToUnit, IsDefinition, ScopeLine,
1800 ContainingType, Virtuality, VirtualIndex + 1,
1801 ThisAdjustment, Flags, IsOptimized, Unit,
1802 TemplateParams, Declaration, RetainedNodes,
1803 ThrownTypes));
1804 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1805 Type, IsLocalToUnit, IsDefinition, ScopeLine,
1806 ContainingType, Virtuality, VirtualIndex,
1807 ThisAdjustment, Flags, !IsOptimized, Unit,
1808 TemplateParams, Declaration, RetainedNodes,
1809 ThrownTypes));
1810 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1811 Type, IsLocalToUnit, IsDefinition, ScopeLine,
1812 ContainingType, Virtuality, VirtualIndex,
1813 ThisAdjustment, Flags, IsOptimized, nullptr,
1814 TemplateParams, Declaration, RetainedNodes,
1815 ThrownTypes));
1816 EXPECT_NE(N, DISubprogram::get(
1817 Context, Scope, Name, LinkageName, File, Line, Type,
1818 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1819 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1820 Unit, getTuple(), Declaration, RetainedNodes, ThrownTypes));
1821 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1822 Type, IsLocalToUnit, IsDefinition, ScopeLine,
1823 ContainingType, Virtuality, VirtualIndex,
1824 ThisAdjustment, Flags, IsOptimized, Unit,
1821 Type, ScopeLine, ContainingType, VirtualIndex,
1822 ThisAdjustment, Flags, SPFlags, Unit,
18251823 TemplateParams, getSubprogram(), RetainedNodes,
18261824 ThrownTypes));
18271825 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1828 Type, IsLocalToUnit, IsDefinition, ScopeLine,
1829 ContainingType, Virtuality, VirtualIndex,
1830 ThisAdjustment, Flags, IsOptimized, Unit,
1826 Type, ScopeLine, ContainingType, VirtualIndex,
1827 ThisAdjustment, Flags, SPFlags, Unit,
18311828 TemplateParams, Declaration, getTuple()));
1832 EXPECT_NE(N, DISubprogram::get(
1833 Context, Scope, Name, LinkageName, File, Line, Type,
1834 IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
1835 Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
1836 Unit, TemplateParams, Declaration, RetainedNodes, getTuple()));
1829 EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line,
1830 Type, ScopeLine, ContainingType, VirtualIndex,
1831 ThisAdjustment, Flags, SPFlags, Unit,
1832 TemplateParams, Declaration, RetainedNodes,
1833 getTuple()));
18371834
18381835 TempDISubprogram Temp = N->clone();
18391836 EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
177177 "f", FunctionType::get(Type::getVoidTy(C), false)));
178178 IRBuilder<> Builder(BasicBlock::Create(C, "", F));
179179 Builder.CreateUnreachable();
180 F->setSubprogram(DIB.createFunction(CU, "f", "f",
181 DIB.createFile("broken.c", "/"), 1,
182 nullptr, true, true, 1));
180 F->setSubprogram(DIB.createFunction(
181 CU, "f", "f", DIB.createFile("broken.c", "/"), 1, nullptr, 1,
182 DINode::FlagZero,
183 DISubprogram::SPFlagLocalToUnit | DISubprogram::SPFlagDefinition));
183184 DIB.finalize();
184185 EXPECT_FALSE(verifyModule(M));
185186
390390 "/file/dir"),
391391 "CloneFunc", false, "", 0);
392392
393 auto *Subprogram =
394 DBuilder.createFunction(CU, "f", "f", File, 4, FuncType, true, true, 3,
395 DINode::FlagZero, false);
393 auto *Subprogram = DBuilder.createFunction(
394 CU, "f", "f", File, 4, FuncType, 3, DINode::FlagZero,
395 DISubprogram::SPFlagLocalToUnit | DISubprogram::SPFlagDefinition);
396396 OldFunc->setSubprogram(Subprogram);
397397
398398 // Function body
420420 auto *StructType = DICompositeType::getDistinct(
421421 C, dwarf::DW_TAG_structure_type, "some_struct", nullptr, 0, nullptr,
422422 nullptr, 32, 32, 0, DINode::FlagZero, nullptr, 0, nullptr, nullptr);
423 auto *InlinedSP =
424 DBuilder.createFunction(CU, "inlined", "inlined", File, 8, FuncType,
425 true, true, 9, DINode::FlagZero, false);
423 auto *InlinedSP = DBuilder.createFunction(
424 CU, "inlined", "inlined", File, 8, FuncType, 9, DINode::FlagZero,
425 DISubprogram::SPFlagLocalToUnit | DISubprogram::SPFlagDefinition);
426426 auto *InlinedVar =
427427 DBuilder.createAutoVariable(InlinedSP, "inlined", File, 5, StructType, true);
428428 auto *Scope = DBuilder.createLexicalBlock(
605605 "/file/dir"),
606606 "CloneModule", false, "", 0);
607607 // Function DI
608 auto *Subprogram =
609 DBuilder.createFunction(CU, "f", "f", File, 4, DFuncType, true, true, 3,
610 DINode::FlagZero, false);
608 auto *Subprogram = DBuilder.createFunction(
609 CU, "f", "f", File, 4, DFuncType, 3, DINode::FlagZero,
610 DISubprogram::SPFlagLocalToUnit | DISubprogram::SPFlagDefinition);
611611 F->setSubprogram(Subprogram);
612612
613613 // Create and assign DIGlobalVariableExpression to gv