From f95bd18b5faa6a5af4b5786312c373c5b2dce687 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Martin=20Storsj=C3=B6?= Date: Fri, 5 Nov 2021 10:12:20 +0200 Subject: [PATCH] Revert "[Attr] support btf_type_tag attribute" This reverts commits 737e4216c537c33aab8ec51880f06b8a54325b94 and ce7ac9e66aba2b937b3d3b5505ce6cc75dcc56ac. After those commits, the compiler can crash with a reduced testcase like this: $ cat reduced.c void a(*); void a() {} $ clang -c reduced.c -O2 -g --- clang/lib/CodeGen/CGDebugInfo.cpp | 185 ++++----------------- clang/lib/CodeGen/CGDebugInfo.h | 21 +-- clang/test/CodeGen/attr-btf_type_tag-func.c | 20 --- .../test/CodeGen/attr-btf_type_tag-typedef-field.c | 35 ---- clang/test/CodeGen/attr-btf_type_tag-var.c | 31 ---- llvm/include/llvm/IR/DIBuilder.h | 11 +- llvm/lib/IR/DIBuilder.cpp | 15 +- llvm/test/Bitcode/attr-btf_type_tag.ll | 36 ---- llvm/test/DebugInfo/attr-btf_type_tag.ll | 62 ------- 9 files changed, 55 insertions(+), 361 deletions(-) delete mode 100644 clang/test/CodeGen/attr-btf_type_tag-func.c delete mode 100644 clang/test/CodeGen/attr-btf_type_tag-typedef-field.c delete mode 100644 clang/test/CodeGen/attr-btf_type_tag-var.c delete mode 100644 llvm/test/Bitcode/attr-btf_type_tag.ll delete mode 100644 llvm/test/DebugInfo/attr-btf_type_tag.ll diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 9813c01..64dd70f 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -929,28 +929,8 @@ static llvm::dwarf::Tag getNextQualifier(Qualifiers &Q) { return (llvm::dwarf::Tag)0; } -// Strip MacroQualifiedTypeLoc and AttributedTypeLoc -// as their corresponding types will be ignored -// during code generation. Stripping them allows -// to maintain proper TypeLoc for a given type -// during code generation. -static TypeLoc StripMacroAttributed(TypeLoc TL) { - if (!TL) - return TL; - - while (true) { - if (auto MTL = TL.getAs()) - TL = MTL.getInnerLoc(); - else if (auto ATL = TL.getAs()) - TL = ATL.getModifiedLoc(); - else - break; - } - return TL; -} - -llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty, llvm::DIFile *Unit, - TypeLoc TL) { +llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty, + llvm::DIFile *Unit) { QualifierCollector Qc; const Type *T = Qc.strip(Ty); @@ -964,15 +944,7 @@ llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty, llvm::DIFile *Unit, return getOrCreateType(QualType(T, 0), Unit); } - QualType NextTy = Qc.apply(CGM.getContext(), T); - TypeLoc NextTL; - if (NextTy.hasQualifiers()) - NextTL = TL; - else if (TL) { - if (auto QTL = TL.getAs()) - NextTL = StripMacroAttributed(QTL.getNextTypeLoc()); - } - auto *FromTy = getOrCreateType(NextTy, Unit, NextTL); + auto *FromTy = getOrCreateType(Qc.apply(CGM.getContext(), T), Unit); // No need to fill in the Name, Line, Size, Alignment, Offset in case of // CVR derived types. @@ -1016,10 +988,10 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty, Ty->getPointeeType(), Unit); } -llvm::DIType *CGDebugInfo::CreateType(const PointerType *Ty, llvm::DIFile *Unit, - TypeLoc TL) { +llvm::DIType *CGDebugInfo::CreateType(const PointerType *Ty, + llvm::DIFile *Unit) { return CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty, - Ty->getPointeeType(), Unit, TL); + Ty->getPointeeType(), Unit); } /// \return whether a C++ mangling exists for the type defined by TD. @@ -1160,8 +1132,7 @@ CGDebugInfo::getOrCreateRecordFwdDecl(const RecordType *Ty, llvm::DIType *CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag, const Type *Ty, QualType PointeeTy, - llvm::DIFile *Unit, - TypeLoc TL) { + llvm::DIFile *Unit) { // Bit size, align and offset of the type. // Size is always the size of a pointer. We can't use getTypeSize here // because that does not return the correct value for references. @@ -1171,52 +1142,13 @@ llvm::DIType *CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag, Optional DWARFAddressSpace = CGM.getTarget().getDWARFAddressSpace(AddressSpace); - llvm::DINodeArray Annotations = nullptr; - TypeLoc NextTL; - if (TL) { - SmallVector Annots; - NextTL = TL.getNextTypeLoc(); - if (NextTL) { - // Traverse all MacroQualifiedTypeLoc, QualifiedTypeLoc and - // AttributedTypeLoc type locations so we can collect - // BTFTypeTag attributes for this pointer. - while (true) { - if (auto MTL = NextTL.getAs()) { - NextTL = MTL.getInnerLoc(); - } else if (auto QTL = NextTL.getAs()) { - NextTL = QTL.getNextTypeLoc(); - } else if (auto ATL = NextTL.getAs()) { - if (const auto *A = ATL.getAttrAs()) { - StringRef BTFTypeTag = A->getBTFTypeTag(); - if (!BTFTypeTag.empty()) { - llvm::Metadata *Ops[2] = { - llvm::MDString::get(CGM.getLLVMContext(), - StringRef("btf_type_tag")), - llvm::MDString::get(CGM.getLLVMContext(), BTFTypeTag)}; - Annots.insert(Annots.begin(), - llvm::MDNode::get(CGM.getLLVMContext(), Ops)); - } - } - NextTL = ATL.getModifiedLoc(); - } else { - break; - } - } - } - - NextTL = StripMacroAttributed(TL.getNextTypeLoc()); - if (Annots.size() > 0) - Annotations = DBuilder.getOrCreateArray(Annots); - } - if (Tag == llvm::dwarf::DW_TAG_reference_type || Tag == llvm::dwarf::DW_TAG_rvalue_reference_type) return DBuilder.createReferenceType(Tag, getOrCreateType(PointeeTy, Unit), Size, Align, DWARFAddressSpace); else - return DBuilder.createPointerType(getOrCreateType(PointeeTy, Unit, NextTL), - Size, Align, DWARFAddressSpace, - StringRef(), Annotations); + return DBuilder.createPointerType(getOrCreateType(PointeeTy, Unit), Size, + Align, DWARFAddressSpace); } llvm::DIType *CGDebugInfo::getOrCreateStructPtrType(StringRef Name, @@ -1333,11 +1265,8 @@ llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty, llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty, llvm::DIFile *Unit) { - TypeLoc TL; - if (const TypeSourceInfo *TSI = Ty->getDecl()->getTypeSourceInfo()) - TL = TSI->getTypeLoc(); llvm::DIType *Underlying = - getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit, TL); + getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit); if (Ty->getDecl()->hasAttr()) return Underlying; @@ -1411,7 +1340,7 @@ static llvm::DINode::DIFlags getRefFlags(const FunctionProtoType *Func) { } llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty, - llvm::DIFile *Unit, TypeLoc TL) { + llvm::DIFile *Unit) { const auto *FPT = dyn_cast(Ty); if (FPT) { if (llvm::DIType *QTy = CreateQualifiedType(FPT, Unit)) @@ -1423,41 +1352,17 @@ llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty, SmallVector EltTys; // Add the result type at least. - TypeLoc RetTL; - if (TL) { - if (auto FTL = TL.getAs()) - RetTL = FTL.getReturnLoc(); - } - EltTys.push_back(getOrCreateType(Ty->getReturnType(), Unit, RetTL)); + EltTys.push_back(getOrCreateType(Ty->getReturnType(), Unit)); llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero; // Set up remainder of arguments if there is a prototype. // otherwise emit it as a variadic function. - if (!FPT) { + if (!FPT) EltTys.push_back(DBuilder.createUnspecifiedParameter()); - } else { + else { Flags = getRefFlags(FPT); - bool DoneWithTL = false; - if (TL) { - if (auto FTL = TL.getAs()) { - DoneWithTL = true; - int Idx = 0; - for (const QualType &ParamType : FPT->param_types()) { - TypeLoc ParamTL; - if (ParmVarDecl *Param = FTL.getParam(Idx)) { - if (const TypeSourceInfo *TSI = Param->getTypeSourceInfo()) - ParamTL = TSI->getTypeLoc(); - } - EltTys.push_back(getOrCreateType(ParamType, Unit, ParamTL)); - Idx++; - } - } - } - - if (!DoneWithTL) { - for (const QualType &ParamType : FPT->param_types()) - EltTys.push_back(getOrCreateType(ParamType, Unit)); - } + for (const QualType &ParamType : FPT->param_types()) + EltTys.push_back(getOrCreateType(ParamType, Unit)); if (FPT->isVariadic()) EltTys.push_back(DBuilder.createUnspecifiedParameter()); } @@ -1528,13 +1433,11 @@ llvm::DIType *CGDebugInfo::createBitFieldType(const FieldDecl *BitFieldDecl, Flags, DebugType, Annotations); } -llvm::DIType * -CGDebugInfo::createFieldType(StringRef name, QualType type, SourceLocation loc, - AccessSpecifier AS, uint64_t offsetInBits, - uint32_t AlignInBits, llvm::DIFile *tunit, - llvm::DIScope *scope, const RecordDecl *RD, - llvm::DINodeArray Annotations, TypeLoc TL) { - llvm::DIType *debugType = getOrCreateType(type, tunit, TL); +llvm::DIType *CGDebugInfo::createFieldType( + StringRef name, QualType type, SourceLocation loc, AccessSpecifier AS, + uint64_t offsetInBits, uint32_t AlignInBits, llvm::DIFile *tunit, + llvm::DIScope *scope, const RecordDecl *RD, llvm::DINodeArray Annotations) { + llvm::DIType *debugType = getOrCreateType(type, tunit); // Get the location for the field. llvm::DIFile *file = getOrCreateFile(loc); @@ -1642,12 +1545,9 @@ void CGDebugInfo::CollectRecordNormalField( } else { auto Align = getDeclAlignIfRequired(field, CGM.getContext()); llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(field); - TypeLoc TL; - if (const TypeSourceInfo *TSI = field->getTypeSourceInfo()) - TL = TSI->getTypeLoc(); - FieldType = createFieldType(name, type, field->getLocation(), - field->getAccess(), OffsetInBits, Align, tunit, - RecordTy, RD, Annotations, TL); + FieldType = + createFieldType(name, type, field->getLocation(), field->getAccess(), + OffsetInBits, Align, tunit, RecordTy, RD, Annotations); } elements.push_back(FieldType); @@ -3405,8 +3305,7 @@ void CGDebugInfo::completeUnusedClass(const CXXRecordDecl &D) { RetainedTypes.push_back(CGM.getContext().getRecordType(&D).getAsOpaquePtr()); } -llvm::DIType *CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile *Unit, - TypeLoc TL) { +llvm::DIType *CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile *Unit) { if (Ty.isNull()) return nullptr; @@ -3423,7 +3322,7 @@ llvm::DIType *CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile *Unit, if (auto *T = getTypeOrNull(Ty)) return T; - llvm::DIType *Res = CreateTypeNode(Ty, Unit, TL); + llvm::DIType *Res = CreateTypeNode(Ty, Unit); void *TyPtr = Ty.getAsOpaquePtr(); // And update the type cache. @@ -3467,11 +3366,10 @@ llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) { return nullptr; } -llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit, - TypeLoc TL) { +llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit) { // Handle qualifiers, which recursively handles what they refer to. if (Ty.hasLocalQualifiers()) - return CreateQualifiedType(Ty, Unit, TL); + return CreateQualifiedType(Ty, Unit); // Work out details of type. switch (Ty->getTypeClass()) { @@ -3500,7 +3398,7 @@ llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit, case Type::Complex: return CreateType(cast(Ty)); case Type::Pointer: - return CreateType(cast(Ty), Unit, TL); + return CreateType(cast(Ty), Unit); case Type::BlockPointer: return CreateType(cast(Ty), Unit); case Type::Typedef: @@ -3511,7 +3409,7 @@ llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit, return CreateEnumType(cast(Ty)); case Type::FunctionProto: case Type::FunctionNoProto: - return CreateType(cast(Ty), Unit, TL); + return CreateType(cast(Ty), Unit); case Type::ConstantArray: case Type::VariableArray: case Type::IncompleteArray: @@ -4056,12 +3954,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D, getDwarfCC(CC)); } - TypeLoc TL; - if (const auto *FD = dyn_cast(D)) { - if (const TypeSourceInfo *TSI = FD->getTypeSourceInfo()) - TL = TSI->getTypeLoc(); - } - return cast(getOrCreateType(FnType, F, TL)); + return cast(getOrCreateType(FnType, F)); } QualType @@ -4463,12 +4356,8 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD, uint64_t XOffset = 0; if (VD->hasAttr()) Ty = EmitTypeForVarWithBlocksAttr(VD, &XOffset).WrappedType; - else { - TypeLoc TL; - if (const TypeSourceInfo *TSI = VD->getTypeSourceInfo()) - TL = TSI->getTypeLoc(); - Ty = getOrCreateType(VD->getType(), Unit, TL); - } + else + Ty = getOrCreateType(VD->getType(), Unit); // If there is no debug info for this type then do not emit debug info // for this variable. @@ -5192,14 +5081,10 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, } AppendAddressSpaceXDeref(AddressSpace, Expr); - TypeLoc TL; - if (const TypeSourceInfo *TSI = D->getTypeSourceInfo()) - TL = TSI->getTypeLoc(); - llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(D); GVE = DBuilder.createGlobalVariableExpression( - DContext, DeclName, LinkageName, Unit, LineNo, - getOrCreateType(T, Unit, TL), Var->hasLocalLinkage(), true, + DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType(T, Unit), + Var->hasLocalLinkage(), true, Expr.empty() ? nullptr : DBuilder.createExpression(Expr), getOrCreateStaticDataMemberDeclarationOrNull(D), TemplateParameters, Align, Annotations); diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index a7b72fa..d6b9bdd 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -178,19 +178,16 @@ class CGDebugInfo { llvm::DIType *CreateType(const ComplexType *Ty); llvm::DIType *CreateType(const AutoType *Ty); llvm::DIType *CreateType(const ExtIntType *Ty); - llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg, - TypeLoc TL = TypeLoc()); + llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg); llvm::DIType *CreateQualifiedType(const FunctionProtoType *Ty, llvm::DIFile *Fg); llvm::DIType *CreateType(const TypedefType *Ty, llvm::DIFile *Fg); llvm::DIType *CreateType(const TemplateSpecializationType *Ty, llvm::DIFile *Fg); llvm::DIType *CreateType(const ObjCObjectPointerType *Ty, llvm::DIFile *F); - llvm::DIType *CreateType(const PointerType *Ty, llvm::DIFile *F, - TypeLoc TL = TypeLoc()); + llvm::DIType *CreateType(const PointerType *Ty, llvm::DIFile *F); llvm::DIType *CreateType(const BlockPointerType *Ty, llvm::DIFile *F); - llvm::DIType *CreateType(const FunctionType *Ty, llvm::DIFile *F, - TypeLoc TL = TypeLoc()); + llvm::DIType *CreateType(const FunctionType *Ty, llvm::DIFile *F); /// Get structure or union type. llvm::DIType *CreateType(const RecordType *Tyg); llvm::DIType *CreateTypeDefinition(const RecordType *Ty); @@ -245,8 +242,7 @@ class CGDebugInfo { /// \return namespace descriptor for the given namespace decl. llvm::DINamespace *getOrCreateNamespace(const NamespaceDecl *N); llvm::DIType *CreatePointerLikeType(llvm::dwarf::Tag Tag, const Type *Ty, - QualType PointeeTy, llvm::DIFile *F, - TypeLoc TL = TypeLoc()); + QualType PointeeTy, llvm::DIFile *F); llvm::DIType *getOrCreateStructPtrType(StringRef Name, llvm::DIType *&Cache); /// A helper function to create a subprogram for a single member @@ -312,8 +308,7 @@ class CGDebugInfo { uint64_t offsetInBits, uint32_t AlignInBits, llvm::DIFile *tunit, llvm::DIScope *scope, const RecordDecl *RD = nullptr, - llvm::DINodeArray Annotations = nullptr, - TypeLoc TL = TypeLoc()); + llvm::DINodeArray Annotations = nullptr); llvm::DIType *createFieldType(StringRef name, QualType type, SourceLocation loc, AccessSpecifier AS, @@ -633,8 +628,7 @@ private: Optional Source); /// Get the type from the cache or create a new type if necessary. - llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg, - TypeLoc TL = TypeLoc()); + llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg); /// Get a reference to a clang module. If \p CreateSkeletonCU is true, /// this also creates a split dwarf skeleton compile unit. @@ -649,8 +643,7 @@ private: llvm::DICompositeType *getOrCreateLimitedType(const RecordType *Ty); /// Create type metadata for a source language type. - llvm::DIType *CreateTypeNode(QualType Ty, llvm::DIFile *Fg, - TypeLoc TL = TypeLoc()); + llvm::DIType *CreateTypeNode(QualType Ty, llvm::DIFile *Fg); /// Create new member and increase Offset by FType's size. llvm::DIType *CreateMemberType(llvm::DIFile *Unit, QualType FType, diff --git a/clang/test/CodeGen/attr-btf_type_tag-func.c b/clang/test/CodeGen/attr-btf_type_tag-func.c deleted file mode 100644 index 016e106..0000000 --- a/clang/test/CodeGen/attr-btf_type_tag-func.c +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s - -#define __tag1 __attribute__((btf_type_tag("tag1"))) -#define __tag2 __attribute__((btf_type_tag("tag2"))) -#define __tag3 __attribute__((btf_type_tag("tag3"))) -#define __tag4 __attribute__((btf_type_tag("tag4"))) - -int __tag1 * __tag2 *foo(int __tag1 * __tag2 *arg) { return arg; } - -// CHECK: distinct !DISubprogram(name: "foo", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[L9:[0-9]+]] -// CHECK: ![[L9]] = !DISubroutineType(types: ![[L10:[0-9]+]] -// CHECK: ![[L10]] = !{![[L11:[0-9]+]], ![[L11]]} -// CHECK: ![[L11]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L12:[0-9]+]], size: [[#]], annotations: ![[L16:[0-9]+]] -// CHECK: ![[L12]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L13:[0-9]+]], size: [[#]], annotations: ![[L14:[0-9]+]] -// CHECK: ![[L13]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed -// CHECK: ![[L14]] = !{![[L15:[0-9]+]]} -// CHECK: ![[L15]] = !{!"btf_type_tag", !"tag1"} -// CHECK: ![[L16]] = !{![[L17:[0-9]+]]} -// CHECK: ![[L17]] = !{!"btf_type_tag", !"tag2"} -// CHECK: !DILocalVariable(name: "arg", arg: 1, scope: ![[#]], file: ![[#]], line: [[#]], type: ![[L11]]) diff --git a/clang/test/CodeGen/attr-btf_type_tag-typedef-field.c b/clang/test/CodeGen/attr-btf_type_tag-typedef-field.c deleted file mode 100644 index c80c7e9..0000000 --- a/clang/test/CodeGen/attr-btf_type_tag-typedef-field.c +++ /dev/null @@ -1,35 +0,0 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s - -#define __tag1 __attribute__((btf_type_tag("tag1"))) -#define __tag2 __attribute__((btf_type_tag("tag2"))) - -typedef void __fn_t(int); -typedef __fn_t __tag1 __tag2 *__fn2_t; -struct t { - int __tag1 * __tag2 *a; - __fn2_t b; - long c; -}; -int *foo1(struct t *a1) { - return (int *)a1->c; -} - -// CHECK: ![[L4:[0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t", file: ![[#]], line: [[#]], size: [[#]], elements: ![[L16:[0-9]+]]) -// CHECK: ![[L16]] = !{![[L17:[0-9]+]], ![[L24:[0-9]+]], ![[L31:[0-9]+]]} -// CHECK: ![[L17]] = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[L18:[0-9]+]], size: [[#]]) -// CHECK: ![[L18]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L19:[0-9]+]], size: [[#]], annotations: ![[L22:[0-9]+]]) -// CHECK: ![[L19]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L4]], size: [[#]], annotations: ![[L20:[0-9]+]]) -// CHECK: ![[L20]] = !{![[L21:[0-9]+]]} -// CHECK: ![[L21]] = !{!"btf_type_tag", !"tag1"} -// CHECK: ![[L22]] = !{![[L23:[0-9]+]]} -// CHECK: ![[L23]] = !{!"btf_type_tag", !"tag2"} -// CHECK: ![[L24]] = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[L25:[0-9]+]] -// CHECK: ![[L25]] = !DIDerivedType(tag: DW_TAG_typedef, name: "__fn2_t", file: ![[#]], line: [[#]], baseType: ![[L26:[0-9]+]]) -// CHECK: ![[L26]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L27:[0-9]+]], size: [[#]], annotations: ![[L30:[0-9]+]]) -// CHECK: ![[L27]] = !DIDerivedType(tag: DW_TAG_typedef, name: "__fn_t", file: ![[#]], line: [[#]], baseType: ![[L28:[0-9]+]]) -// CHECK: ![[L28]] = !DISubroutineType(types: ![[L29:[0-9]+]]) -// CHECK: ![[L29]] = !{null, ![[L4]]} -// CHECK: ![[L30]] = !{![[L21]], ![[L23]]} -// CHECK: ![[L31]] = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: ![[#]], file: ![[#]], line: [[#]]1, baseType: ![[L32:[0-9]+]] -// CHECK: ![[L32]] = !DIBasicType(name: "long", size: [[#]], encoding: DW_ATE_signed) diff --git a/clang/test/CodeGen/attr-btf_type_tag-var.c b/clang/test/CodeGen/attr-btf_type_tag-var.c deleted file mode 100644 index 3493d8f..0000000 --- a/clang/test/CodeGen/attr-btf_type_tag-var.c +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s - -#define __tag1 __attribute__((btf_type_tag("tag1"))) -#define __tag2 __attribute__((btf_type_tag("tag2"))) -#define __tag3 __attribute__((btf_type_tag("tag3"))) -#define __tag4 __attribute__((btf_type_tag("tag4"))) -#define __tag5 __attribute__((btf_type_tag("tag5"))) -#define __tag6 __attribute__((btf_type_tag("tag6"))) - -const int __tag1 __tag2 volatile * const __tag3 __tag4 volatile * __tag5 __tag6 const volatile * g; - -// CHECK: distinct !DIGlobalVariable(name: "g", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[L6:[0-9]+]] -// CHECK: ![[L6]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L7:[0-9]+]], size: [[#]], annotations: ![[L22:[0-9]+]] -// CHECK: ![[L7]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[L8:[0-9]+]] -// CHECK: ![[L8]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: ![[L9:[0-9]+]] -// CHECK: ![[L9]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L10:[0-9]+]], size: [[#]], annotations: ![[L19:[0-9]+]] -// CHECK: ![[L10]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[L11:[0-9]+]] -// CHECK: ![[L11]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: ![[L12:[0-9]+]] -// CHECK: ![[L12]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L13:[0-9]+]], size: [[#]], annotations: ![[L16:[0-9]+]] -// CHECK: ![[L13]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[L14:[0-9]+]] -// CHECK: ![[L14]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: ![[L15:[0-9]+]] -// CHECK: ![[L15]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed -// CHECK: ![[L16]] = !{![[L17:[0-9]+]], ![[L18:[0-9]+]]} -// CHECK: ![[L17]] = !{!"btf_type_tag", !"tag1"} -// CHECK: ![[L18]] = !{!"btf_type_tag", !"tag2"} -// CHECK: ![[L19]] = !{![[L20:[0-9]+]], ![[L21:[0-9]+]]} -// CHECK: ![[L20]] = !{!"btf_type_tag", !"tag3"} -// CHECK: ![[L21]] = !{!"btf_type_tag", !"tag4"} -// CHECK: ![[L22]] = !{![[L23:[0-9]+]], ![[L24:[0-9]+]]} -// CHECK: ![[L23]] = !{!"btf_type_tag", !"tag5"} -// CHECK: ![[L24]] = !{!"btf_type_tag", !"tag6"} diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h index 61c6dd8..9016509 100644 --- a/llvm/include/llvm/IR/DIBuilder.h +++ b/llvm/include/llvm/IR/DIBuilder.h @@ -219,12 +219,11 @@ namespace llvm { /// \param AlignInBits Alignment. (optional) /// \param DWARFAddressSpace DWARF address space. (optional) /// \param Name Pointer type name. (optional) - /// \param Annotations Member annotations. - DIDerivedType * - createPointerType(DIType *PointeeTy, uint64_t SizeInBits, - uint32_t AlignInBits = 0, - Optional DWARFAddressSpace = None, - StringRef Name = "", DINodeArray Annotations = nullptr); + DIDerivedType *createPointerType(DIType *PointeeTy, uint64_t SizeInBits, + uint32_t AlignInBits = 0, + Optional DWARFAddressSpace = + None, + StringRef Name = ""); /// Create debugging information entry for a pointer to member. /// \param PointeeTy Type pointed to by this pointer. diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 12320cf..de4ab59 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -287,16 +287,17 @@ DIDerivedType *DIBuilder::createQualifiedType(unsigned Tag, DIType *FromTy) { 0, 0, None, DINode::FlagZero); } -DIDerivedType * -DIBuilder::createPointerType(DIType *PointeeTy, uint64_t SizeInBits, - uint32_t AlignInBits, - Optional DWARFAddressSpace, - StringRef Name, DINodeArray Annotations) { +DIDerivedType *DIBuilder::createPointerType( + DIType *PointeeTy, + uint64_t SizeInBits, + uint32_t AlignInBits, + Optional DWARFAddressSpace, + StringRef Name) { // FIXME: Why is there a name here? return DIDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name, nullptr, 0, nullptr, PointeeTy, SizeInBits, - AlignInBits, 0, DWARFAddressSpace, DINode::FlagZero, - nullptr, Annotations); + AlignInBits, 0, DWARFAddressSpace, + DINode::FlagZero); } DIDerivedType *DIBuilder::createMemberPointerType(DIType *PointeeTy, diff --git a/llvm/test/Bitcode/attr-btf_type_tag.ll b/llvm/test/Bitcode/attr-btf_type_tag.ll deleted file mode 100644 index ab0634b..0000000 --- a/llvm/test/Bitcode/attr-btf_type_tag.ll +++ /dev/null @@ -1,36 +0,0 @@ -; RUN: llvm-as < %s | llvm-dis | FileCheck %s -; -; Source: -; #define __tag1 __attribute__((btf_type_tag("tag1"))) -; int __tag1 *g; -; Compilation flag: -; clang -S -g -emit-llvm test.c - -@g = dso_local global i32* null, align 8, !dbg !0 - -!llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!9, !10, !11, !12, !13} -!llvm.ident = !{!14} - -!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 2, type: !5, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 14.0.0 (https://github.com/llvm/llvm-project.git 248122328bfefe82608a2e110af3a3ff04279ddf)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm/btf_tag_type") -!4 = !{!0} -!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64, annotations: !7) -!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!7 = !{!8} -!8 = !{!"btf_type_tag", !"tag1"} - -; CHECK: distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 2, type: !5 -; CHECK: !5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64, annotations: !7) -; CHECK-NEXT: !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -; CHECK-NEXT: !7 = !{!8} -; CHECK-NEXT: !8 = !{!"btf_type_tag", !"tag1"} - -!9 = !{i32 7, !"Dwarf Version", i32 4} -!10 = !{i32 2, !"Debug Info Version", i32 3} -!11 = !{i32 1, !"wchar_size", i32 4} -!12 = !{i32 7, !"uwtable", i32 1} -!13 = !{i32 7, !"frame-pointer", i32 2} -!14 = !{!"clang version 14.0.0 (https://github.com/llvm/llvm-project.git 248122328bfefe82608a2e110af3a3ff04279ddf)"} diff --git a/llvm/test/DebugInfo/attr-btf_type_tag.ll b/llvm/test/DebugInfo/attr-btf_type_tag.ll deleted file mode 100644 index 4561d05..0000000 --- a/llvm/test/DebugInfo/attr-btf_type_tag.ll +++ /dev/null @@ -1,62 +0,0 @@ -; REQUIRES: x86-registered-target -; RUN: llc -filetype=obj -o %t %s -; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s -; Source: -; #define __tag1 __attribute__((btf_type_tag("tag1"))) -; #define __tag2 __attribute__((btf_type_tag("tag2"))) -; -; int * __tag1 * __tag2 *g; -; Compilation flag: -; clang -target x86_64 -g -S -emit-llvm t.c - -@g = dso_local global i32*** null, align 8, !dbg !0 - -!llvm.dbg.cu = !{!2} -!llvm.module.flags = !{!13, !14, !15, !16, !17} -!llvm.ident = !{!18} - -!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 4, type: !5, isLocal: false, isDefinition: true) -!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 14.0.0 (https://github.com/llvm/llvm-project.git 2c240a5eefae1a945dfd36cdaa0c677eca90dd82)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None) -!3 = !DIFile(filename: "t.c", directory: "/home/yhs/work/tests/llvm/btf_tag_type") -!4 = !{!0} -!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64, annotations: !11) -!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, annotations: !9) -!7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64) -!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!9 = !{!10} -!10 = !{!"btf_type_tag", !"tag1"} -!11 = !{!12} -!12 = !{!"btf_type_tag", !"tag2"} - -; CHECK: DW_TAG_variable -; CHECK-NEXT: DW_AT_name ("g") -; CHECK-NEXT: DW_AT_type (0x[[T1:[0-9a-f]+]] "int ***") - -; CHECK: 0x[[T1]]: DW_TAG_pointer_type -; CHECK-NEXT: DW_AT_type (0x[[T2:[0-9a-f]+]] "int **") - -; CHECK: DW_TAG_LLVM_annotation -; CHECK-NEXT: DW_AT_name ("btf_type_tag") -; CHECK-NEXT: DW_AT_const_value ("tag2") - -; CHECK: NULL - -; CHECK: 0x[[T2]]: DW_TAG_pointer_type -; CHECK-NEXT: DW_AT_type (0x[[T3:[0-9a-f]+]] "int *") - -; CHECK: DW_TAG_LLVM_annotation -; CHECK-NEXT: DW_AT_name ("btf_type_tag") -; CHECK-NEXT: DW_AT_const_value ("tag1") - -; CHECK: NULL - -; CHECK: 0x[[T3]]: DW_TAG_pointer_type -; CHECK-NEXT: DW_AT_type (0x{{[0-9a-f]+}} "int") - -!13 = !{i32 7, !"Dwarf Version", i32 4} -!14 = !{i32 2, !"Debug Info Version", i32 3} -!15 = !{i32 1, !"wchar_size", i32 4} -!16 = !{i32 7, !"uwtable", i32 1} -!17 = !{i32 7, !"frame-pointer", i32 2} -!18 = !{!"clang version 14.0.0 (https://github.com/llvm/llvm-project.git 2c240a5eefae1a945dfd36cdaa0c677eca90dd82)"} -- 2.7.4