From 344a3780b2e33f6ca763666c380202b18aab72a3 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Thu, 29 Jul 2021 22:15:26 +0200 Subject: Vendor import of llvm-project main 88e66fa60ae5, the last commit before the upstream release/13.x branch was created. --- llvm/lib/IR/Metadata.cpp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'llvm/lib/IR/Metadata.cpp') diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index 7ca538995db2..4f87ef537765 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -195,6 +195,25 @@ bool MetadataTracking::isReplaceable(const Metadata &MD) { return ReplaceableMetadataImpl::isReplaceable(MD); } +SmallVector ReplaceableMetadataImpl::getAllArgListUsers() { + SmallVector *> MDUsersWithID; + for (auto Pair : UseMap) { + OwnerTy Owner = Pair.second.first; + if (!Owner.is()) + continue; + Metadata *OwnerMD = Owner.get(); + if (OwnerMD->getMetadataID() == Metadata::DIArgListKind) + MDUsersWithID.push_back(&UseMap[Pair.first]); + } + llvm::sort(MDUsersWithID, [](auto UserA, auto UserB) { + return UserA->second < UserB->second; + }); + SmallVector MDUsers; + for (auto UserWithID : MDUsersWithID) + MDUsers.push_back(UserWithID->first.get()); + return MDUsers; +} + void ReplaceableMetadataImpl::addRef(void *Ref, OwnerTy Owner) { bool WasInserted = UseMap.insert(std::make_pair(Ref, std::make_pair(Owner, NextIndex))) @@ -1400,12 +1419,12 @@ bool Instruction::extractProfMetadata(uint64_t &TrueVal, } bool Instruction::extractProfTotalWeight(uint64_t &TotalVal) const { - assert((getOpcode() == Instruction::Br || - getOpcode() == Instruction::Select || - getOpcode() == Instruction::Call || - getOpcode() == Instruction::Invoke || - getOpcode() == Instruction::Switch) && - "Looking for branch weights on something besides branch"); + assert( + (getOpcode() == Instruction::Br || getOpcode() == Instruction::Select || + getOpcode() == Instruction::Call || getOpcode() == Instruction::Invoke || + getOpcode() == Instruction::IndirectBr || + getOpcode() == Instruction::Switch) && + "Looking for branch weights on something besides branch"); TotalVal = 0; auto *ProfileData = getMetadata(LLVMContext::MD_prof); -- cgit v1.3