[PATCH] D24871: Get non debug metadata ids.
Aditya Kumar via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 23 09:14:38 PDT 2016
hiraditya created this revision.
hiraditya added reviewers: danielcdh, spatel.
hiraditya added subscribers: sebpop, llvm-commits.
https://reviews.llvm.org/D24871
Files:
llvm/include/llvm/IR/Instruction.h
llvm/lib/IR/LLVMContextImpl.h
llvm/lib/IR/Metadata.cpp
Index: llvm/lib/IR/Metadata.cpp
===================================================================
--- llvm/lib/IR/Metadata.cpp
+++ llvm/lib/IR/Metadata.cpp
@@ -1106,6 +1106,11 @@
array_pod_sort(Result.begin(), Result.end());
}
+void MDAttachmentMap::getAllIDs(SmallVectorImpl<unsigned> &Result) const {
+ for (auto &A : Attachments)
+ Result.push_back(A.first);
+}
+
void MDGlobalAttachmentMap::insert(unsigned ID, MDNode &MD) {
Attachments.push_back({ID, TrackingMDNodeRef(&MD)});
}
@@ -1270,6 +1275,15 @@
Info.getAll(Result);
}
+void
+Instruction::getAllNonDebugMetadataIDs(SmallVectorImpl<unsigned> &MDIDs) const {
+ if (!hasMetadataOtherThanDebugLoc())
+ return;
+ const auto &Info = getContext().pImpl->InstructionMetadata.find(this)->second;
+ assert(!Info.empty() && "Shouldn't have called this");
+ Info.getAllIDs(MDIDs);
+}
+
bool Instruction::extractProfMetadata(uint64_t &TrueVal,
uint64_t &FalseVal) const {
assert(
Index: llvm/lib/IR/LLVMContextImpl.h
===================================================================
--- llvm/lib/IR/LLVMContextImpl.h
+++ llvm/lib/IR/LLVMContextImpl.h
@@ -993,6 +993,7 @@
/// Copies all the current attachments into \c Result, sorting by attachment
/// ID. This function does \em not clear \c Result.
void getAll(SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const;
+ void getAllIDs(SmallVectorImpl<unsigned> &Result) const;
/// \brief Erase matching attachments.
///
Index: llvm/include/llvm/IR/Instruction.h
===================================================================
--- llvm/include/llvm/IR/Instruction.h
+++ llvm/include/llvm/IR/Instruction.h
@@ -188,6 +188,10 @@
getAllMetadataOtherThanDebugLocImpl(MDs);
}
+ /// Get all the metadata IDs attached to this Instruction except the ones
+ /// associated with debug location. The Vector \p MDIDs is not cleared.
+ void getAllNonDebugMetadataIDs(SmallVectorImpl<unsigned> &MDIDs) const;
+
/// Fills the AAMDNodes structure with AA metadata from this instruction.
/// When Merge is true, the existing AA metadata is merged with that from this
/// instruction providing the most-general result.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24871.72297.patch
Type: text/x-patch
Size: 2228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160923/2462ab73/attachment.bin>
More information about the llvm-commits
mailing list