summaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Metadata.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/Metadata.cpp')
-rw-r--r--llvm/lib/IR/Metadata.cpp31
1 files changed, 25 insertions, 6 deletions
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<Metadata *> ReplaceableMetadataImpl::getAllArgListUsers() {
+ SmallVector<std::pair<OwnerTy, uint64_t> *> MDUsersWithID;
+ for (auto Pair : UseMap) {
+ OwnerTy Owner = Pair.second.first;
+ if (!Owner.is<Metadata *>())
+ continue;
+ Metadata *OwnerMD = Owner.get<Metadata *>();
+ if (OwnerMD->getMetadataID() == Metadata::DIArgListKind)
+ MDUsersWithID.push_back(&UseMap[Pair.first]);
+ }
+ llvm::sort(MDUsersWithID, [](auto UserA, auto UserB) {
+ return UserA->second < UserB->second;
+ });
+ SmallVector<Metadata *> MDUsers;
+ for (auto UserWithID : MDUsersWithID)
+ MDUsers.push_back(UserWithID->first.get<Metadata *>());
+ 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);