Author: Michael Buch Date: 2026-01-21T01:10:58Z New Revision: 8f90efdee83e866781aa226357eaa00d4abba53b
URL: https://github.com/llvm/llvm-project/commit/8f90efdee83e866781aa226357eaa00d4abba53b DIFF: https://github.com/llvm/llvm-project/commit/8f90efdee83e866781aa226357eaa00d4abba53b.diff LOG: [llvm][DebugInfo][NFC] Remove DITypeRefArray in favour of DITypeArray (#177066) `DITypeRefArray` is just an alias (since https://github.com/llvm/llvm-project/pull/176938). Remove it in favour of just using `DITypeArray`. Added: Modified: clang/lib/CodeGen/CGDebugInfo.cpp llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h llvm/lib/IR/DIBuilder.cpp llvm/lib/Target/BPF/BPFISelLowering.cpp llvm/lib/Target/BPF/BTFDebug.cpp llvm/unittests/Transforms/Utils/CloningTest.cpp mlir/lib/Target/LLVMIR/DebugTranslation.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 9e21d3a5626d3..5e452245ee627 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1852,7 +1852,7 @@ llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty, EltTys.push_back(DBuilder.createUnspecifiedParameter()); } - llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys); + llvm::DITypeArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys); llvm::DIType *F = DBuilder.createSubroutineType( EltTypeArray, Flags, getDwarfCC(Ty->getCallConv())); return F; @@ -2254,7 +2254,7 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr, getOrCreateType(CGM.getContext().getFunctionType( Func->getReturnType(), Func->getParamTypes(), EPI), Unit)); - llvm::DITypeRefArray Args = OriginalFunc->getTypeArray(); + llvm::DITypeArray Args = OriginalFunc->getTypeArray(); assert(Args.size() && "Invalid number of arguments!"); SmallVector<llvm::Metadata *, 16> Elts; @@ -2285,7 +2285,7 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType ThisPtr, Elts[1] = DBuilder.createObjectPointerType(Args[1], /*Implicit=*/false); } - llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts); + llvm::DITypeArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts); return DBuilder.createSubroutineType(EltTypeArray, OriginalFunc->getFlags(), getDwarfCC(Func->getCallConv())); @@ -2762,7 +2762,7 @@ llvm::DIType *CGDebugInfo::getOrCreateVTablePtrType(llvm::DIFile *Unit) { /* Function type */ llvm::Metadata *STy = getOrCreateType(Context.IntTy, Unit); - llvm::DITypeRefArray SElements = DBuilder.getOrCreateTypeArray(STy); + llvm::DITypeArray SElements = DBuilder.getOrCreateTypeArray(STy); llvm::DIType *SubTy = DBuilder.createSubroutineType(SElements); unsigned Size = Context.getTypeSize(Context.VoidPtrTy); unsigned VtblPtrAddressSpace = CGM.getTarget().getVtblPtrAddressSpace(); @@ -4755,7 +4755,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D, if (OMethod->isVariadic()) Elts.push_back(DBuilder.createUnspecifiedParameter()); - llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts); + llvm::DITypeArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts); return DBuilder.createSubroutineType(EltTypeArray, llvm::DINode::FlagZero, getDwarfCC(CC)); } @@ -4770,7 +4770,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D, for (QualType ParamType : FPT->param_types()) EltTys.push_back(getOrCreateType(ParamType, F)); EltTys.push_back(DBuilder.createUnspecifiedParameter()); - llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys); + llvm::DITypeArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys); return DBuilder.createSubroutineType(EltTypeArray, llvm::DINode::FlagZero, getDwarfCC(CC)); } @@ -4962,7 +4962,7 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc, // DISubprogram's retainedNodes in the DIBuilder::finalize() call. if (IsDeclForCallSite && CGM.getTarget().getTriple().isBPF()) { if (auto *FD = dyn_cast<FunctionDecl>(D)) { - llvm::DITypeRefArray ParamTypes = STy->getTypeArray(); + llvm::DITypeArray ParamTypes = STy->getTypeArray(); unsigned ArgNo = 1; for (ParmVarDecl *PD : FD->parameters()) { llvm::DINodeArray ParamAnnotations = CollectBTFDeclTagAnnotations(PD); diff --git a/llvm/include/llvm/IR/DIBuilder.h b/llvm/include/llvm/IR/DIBuilder.h index 49d9e686aeffa..9677c4b2bc200 100644 --- a/llvm/include/llvm/IR/DIBuilder.h +++ b/llvm/include/llvm/IR/DIBuilder.h @@ -777,7 +777,7 @@ namespace llvm { /// These flags are used to emit dwarf attributes. /// \param CC Calling convention, e.g. dwarf::DW_CC_normal LLVM_ABI DISubroutineType * - createSubroutineType(DITypeRefArray ParameterTypes, + createSubroutineType(DITypeArray ParameterTypes, DINode::DIFlags Flags = DINode::FlagZero, unsigned CC = 0); @@ -842,8 +842,8 @@ namespace llvm { LLVM_ABI DIMacroNodeArray getOrCreateMacroArray(ArrayRef<Metadata *> Elements); - /// Get a DITypeRefArray, create one if required. - LLVM_ABI DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements); + /// Get a DITypeArray, create one if required. + LLVM_ABI DITypeArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements); /// Create a descriptor for a value range. This /// implicitly uniques the values returned. diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 43d658327b8d3..a41379b974069 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -119,8 +119,6 @@ class DbgVariableRecord; LLVM_ABI extern cl::opt<bool> EnableFSDiscriminator; -using DITypeRefArray = DITypeArray; - /// Tagged DWARF-like metadata node. /// /// A metadata node with a DWARF tag (i.e., a constant named \c DW_TAG_*, @@ -1948,7 +1946,7 @@ class DISubroutineType : public DIType { ~DISubroutineType() = default; static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags, - uint8_t CC, DITypeRefArray TypeArray, + uint8_t CC, DITypeArray TypeArray, StorageType Storage, bool ShouldCreate = true) { return getImpl(Context, Flags, CC, TypeArray.get(), Storage, ShouldCreate); @@ -1964,7 +1962,7 @@ class DISubroutineType : public DIType { public: DEFINE_MDNODE_GET(DISubroutineType, - (DIFlags Flags, uint8_t CC, DITypeRefArray TypeArray), + (DIFlags Flags, uint8_t CC, DITypeArray TypeArray), (Flags, CC, TypeArray)) DEFINE_MDNODE_GET(DISubroutineType, (DIFlags Flags, uint8_t CC, Metadata *TypeArray), @@ -1980,7 +1978,7 @@ class DISubroutineType : public DIType { uint8_t getCC() const { return CC; } - DITypeRefArray getTypeArray() const { + DITypeArray getTypeArray() const { return cast_or_null<MDTuple>(getRawTypeArray()); } diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index c63dc8f00785e..a12176d5bfdbb 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -165,11 +165,11 @@ class BitcodeReaderMetadataList { /// Upgrade a type that had an MDString reference. Metadata *upgradeTypeRef(Metadata *MaybeUUID); - /// Upgrade a type ref array that may have MDString references. - Metadata *upgradeTypeRefArray(Metadata *MaybeTuple); + /// Upgrade a type array that may have MDString references. + Metadata *upgradeTypeArray(Metadata *MaybeTuple); private: - Metadata *resolveTypeRefArray(Metadata *MaybeTuple); + Metadata *resolveTypeArray(Metadata *MaybeTuple); }; } // namespace @@ -246,7 +246,7 @@ void BitcodeReaderMetadataList::tryToResolveCycles() { // Upgrade from old type ref arrays. In strange cases, this could add to // OldTypeRefs.Unknown. for (const auto &Array : OldTypeRefs.Arrays) - Array.second->replaceAllUsesWith(resolveTypeRefArray(Array.first.get())); + Array.second->replaceAllUsesWith(resolveTypeArray(Array.first.get())); OldTypeRefs.Arrays.clear(); // Replace old string-based type refs with the resolved node, if possible. @@ -302,29 +302,29 @@ Metadata *BitcodeReaderMetadataList::upgradeTypeRef(Metadata *MaybeUUID) { return Ref.get(); } -Metadata *BitcodeReaderMetadataList::upgradeTypeRefArray(Metadata *MaybeTuple) { +Metadata *BitcodeReaderMetadataList::upgradeTypeArray(Metadata *MaybeTuple) { auto *Tuple = dyn_cast_or_null<MDTuple>(MaybeTuple); if (!Tuple || Tuple->isDistinct()) return MaybeTuple; // Look through the array immediately if possible. if (!Tuple->isTemporary()) - return resolveTypeRefArray(Tuple); + return resolveTypeArray(Tuple); // Create and return a placeholder to use for now. Eventually - // resolveTypeRefArrays() will be resolve this forward reference. + // resolveTypeArrays() will be resolve this forward reference. OldTypeRefs.Arrays.emplace_back( std::piecewise_construct, std::forward_as_tuple(Tuple), std::forward_as_tuple(MDTuple::getTemporary(Context, {}))); return OldTypeRefs.Arrays.back().second.get(); } -Metadata *BitcodeReaderMetadataList::resolveTypeRefArray(Metadata *MaybeTuple) { +Metadata *BitcodeReaderMetadataList::resolveTypeArray(Metadata *MaybeTuple) { auto *Tuple = dyn_cast_or_null<MDTuple>(MaybeTuple); if (!Tuple || Tuple->isDistinct()) return MaybeTuple; - // Look through the DITypeRefArray, upgrading each DIType *. + // Look through the DITypeArray, upgrading each DIType *. SmallVector<Metadata *, 32> Ops; Ops.reserve(Tuple->getNumOperands()); for (Metadata *MD : Tuple->operands()) @@ -1800,14 +1800,14 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( case bitc::METADATA_SUBROUTINE_TYPE: { if (Record.size() < 3 || Record.size() > 4) return error("Invalid record"); - bool IsOldTypeRefArray = Record[0] < 2; + bool IsOldTypeArray = Record[0] < 2; unsigned CC = (Record.size() > 3) ? Record[3] : 0; IsDistinct = Record[0] & 0x1; DINode::DIFlags Flags = static_cast<DINode::DIFlags>(Record[1]); Metadata *Types = getMDOrNull(Record[2]); - if (LLVM_UNLIKELY(IsOldTypeRefArray)) - Types = MetadataList.upgradeTypeRefArray(Types); + if (LLVM_UNLIKELY(IsOldTypeArray)) + Types = MetadataList.upgradeTypeArray(Types); MetadataList.assignValue( GET_OR_DISTINCT(DISubroutineType, (Context, Flags, CC, Types)), diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 2ebccee6aa68c..4b6b76c48dcbf 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -2122,7 +2122,7 @@ TypeIndex CodeViewDebug::lowerTypeMemberFunction(const DISubroutineType *Ty, // Lower the containing class type. TypeIndex ClassType = getTypeIndex(ClassTy); - DITypeRefArray ReturnAndArgs = Ty->getTypeArray(); + DITypeArray ReturnAndArgs = Ty->getTypeArray(); unsigned Index = 0; SmallVector<TypeIndex, 8> ArgTypeIndices; diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index bf7ef1bbbc793..b815386e400cb 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -1141,7 +1141,7 @@ DIE &DwarfCompileUnit::constructSubprogramScopeDIE(const DISubprogram *Sub, } // If this is a variadic function, add an unspecified parameter. - DITypeRefArray FnArgs = Sub->getType()->getTypeArray(); + DITypeArray FnArgs = Sub->getType()->getTypeArray(); // If we have a single element of null, it is a function that returns void. // If we have more than one elements and the last one is null, it is a diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index d55b462feed7b..baffd81b4f336 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -919,7 +919,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy) { } std::optional<unsigned> -DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args) { +DwarfUnit::constructSubprogramArguments(DIE &Buffer, DITypeArray Args) { // Args[0] is the return type. std::optional<unsigned> ObjectPointerIndex; for (unsigned i = 1, N = Args.size(); i < N; ++i) { @@ -1398,7 +1398,7 @@ bool DwarfUnit::applySubprogramDefinitionAttributes(const DISubprogram *SP, StringRef DeclLinkageName; if (auto *SPDecl = SP->getDeclaration()) { if (!Minimal) { - DITypeRefArray DeclArgs, DefinitionArgs; + DITypeArray DeclArgs, DefinitionArgs; DeclArgs = SPDecl->getType()->getTypeArray(); DefinitionArgs = SP->getType()->getTypeArray(); @@ -1475,7 +1475,7 @@ void DwarfUnit::applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, addFlag(SPDie, dwarf::DW_AT_APPLE_objc_direct); unsigned CC = 0; - DITypeRefArray Args; + DITypeArray Args; if (const DISubroutineType *SPTy = SP->getType()) { Args = SPTy->getTypeArray(); CC = SPTy->getCC(); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h index 740e5a80ca619..22eef85a1dffa 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -284,7 +284,7 @@ class DwarfUnit : public DIEUnit { /// \returns The index of the object parameter in \c Args if one exists. /// Returns std::nullopt otherwise. std::optional<unsigned> constructSubprogramArguments(DIE &Buffer, - DITypeRefArray Args); + DITypeArray Args); /// Create a DIE with the given Tag, add the DIE to its parent, and /// call insertDIE if MD is not null. diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index b01860dba74a9..05c9d58bf6e85 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -647,7 +647,7 @@ DIBuilder::createVariantPart(DIScope *Scope, StringRef Name, DIFile *File, return R; } -DISubroutineType *DIBuilder::createSubroutineType(DITypeRefArray ParameterTypes, +DISubroutineType *DIBuilder::createSubroutineType(DITypeArray ParameterTypes, DINode::DIFlags Flags, unsigned CC) { return DISubroutineType::get(VMContext, Flags, CC, ParameterTypes); @@ -814,7 +814,7 @@ DIBuilder::getOrCreateMacroArray(ArrayRef<Metadata *> Elements) { return MDTuple::get(VMContext, Elements); } -DITypeRefArray DIBuilder::getOrCreateTypeArray(ArrayRef<Metadata *> Elements) { +DITypeArray DIBuilder::getOrCreateTypeArray(ArrayRef<Metadata *> Elements) { SmallVector<llvm::Metadata *, 16> Elts; for (Metadata *E : Elements) { if (isa_and_nonnull<MDNode>(E)) @@ -822,7 +822,7 @@ DITypeRefArray DIBuilder::getOrCreateTypeArray(ArrayRef<Metadata *> Elements) { else Elts.push_back(E); } - return DITypeRefArray(MDNode::get(VMContext, Elts)); + return DITypeArray(MDNode::get(VMContext, Elts)); } DISubrange *DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) { diff --git a/llvm/lib/Target/BPF/BPFISelLowering.cpp b/llvm/lib/Target/BPF/BPFISelLowering.cpp index 5c03776dd6653..50b30bb97f19e 100644 --- a/llvm/lib/Target/BPF/BPFISelLowering.cpp +++ b/llvm/lib/Target/BPF/BPFISelLowering.cpp @@ -787,7 +787,7 @@ static Function *createBPFUnreachable(Module *M) { return NewF; DIBuilder DBuilder(*M); - DITypeRefArray ParamTypes = + DITypeArray ParamTypes = DBuilder.getOrCreateTypeArray({nullptr /*void return*/}); DISubroutineType *FuncType = DBuilder.createSubroutineType(ParamTypes); DICompileUnit *CU = *M->debug_compile_units_begin(); diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp index fb90a2ca5b383..54d60c05e3c3e 100644 --- a/llvm/lib/Target/BPF/BTFDebug.cpp +++ b/llvm/lib/Target/BPF/BTFDebug.cpp @@ -408,7 +408,7 @@ void BTFTypeFuncProto::completeType(BTFDebug &BDebug) { return; IsCompleted = true; - DITypeRefArray Elements = STy->getTypeArray(); + DITypeArray Elements = STy->getTypeArray(); auto RetType = tryRemoveAtomicType(Elements[0]); BTFType.Type = RetType ? BDebug.getTypeId(RetType) : 0; BTFType.NameOff = 0; @@ -626,7 +626,7 @@ void BTFDebug::visitSubroutineType( const DISubroutineType *STy, bool ForSubprog, const std::unordered_map<uint32_t, StringRef> &FuncArgNames, uint32_t &TypeId) { - DITypeRefArray Elements = STy->getTypeArray(); + DITypeArray Elements = STy->getTypeArray(); uint32_t VLen = Elements.size() - 1; if (VLen > BTF::MAX_VLEN) return; diff --git a/llvm/unittests/Transforms/Utils/CloningTest.cpp b/llvm/unittests/Transforms/Utils/CloningTest.cpp index 56890587bda32..545ca7c16af71 100644 --- a/llvm/unittests/Transforms/Utils/CloningTest.cpp +++ b/llvm/unittests/Transforms/Utils/CloningTest.cpp @@ -480,7 +480,7 @@ class CloneFunc : public ::testing::Test { // Function DI auto *File = DBuilder.createFile("filename.c", "/file/dir/"); - DITypeRefArray ParamTypes = DBuilder.getOrCreateTypeArray({}); + DITypeArray ParamTypes = DBuilder.getOrCreateTypeArray({}); DISubroutineType *FuncType = DBuilder.createSubroutineType(ParamTypes); auto *CU = DBuilder.createCompileUnit( @@ -973,7 +973,7 @@ class CloneModule : public ::testing::Test { // Create debug info auto *File = DBuilder.createFile("filename.c", "/file/dir/"); - DITypeRefArray ParamTypes = DBuilder.getOrCreateTypeArray({}); + DITypeArray ParamTypes = DBuilder.getOrCreateTypeArray({}); DISubroutineType *DFuncType = DBuilder.createSubroutineType(ParamTypes); auto *CU = DBuilder.createCompileUnit( DISourceLanguageName(dwarf::DW_LANG_C99), diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp index e3bcf2749be13..627bcf4bee504 100644 --- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp @@ -441,7 +441,7 @@ DebugTranslation::translateImpl(DISubroutineTypeAttr attr) { types.push_back(translate(type)); return llvm::DISubroutineType::get( llvmCtx, llvm::DINode::FlagZero, attr.getCallingConvention(), - llvm::DITypeRefArray(llvm::MDNode::get(llvmCtx, types))); + llvm::DITypeArray(llvm::MDNode::get(llvmCtx, types))); } llvm::DIType *DebugTranslation::translateImpl(DITypeAttr attr) { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
