diff options
Diffstat (limited to 'llvm/lib/IR/Metadata.cpp')
-rw-r--r-- | llvm/lib/IR/Metadata.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index f0448b0..0dbd07f 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -1303,6 +1303,24 @@ static void addRange(SmallVectorImpl<ConstantInt *> &EndPoints, EndPoints.push_back(High); } +MDNode *MDNode::getMergedCalleeTypeMetadata(const MDNode *A, const MDNode *B) { + // Drop the callee_type metadata if either of the call instructions do not + // have it. + if (!A || !B) + return nullptr; + SmallVector<Metadata *, 8> AB; + SmallPtrSet<Metadata *, 8> MergedCallees; + auto AddUniqueCallees = [&AB, &MergedCallees](const MDNode *N) { + for (Metadata *MD : N->operands()) { + if (MergedCallees.insert(MD).second) + AB.push_back(MD); + } + }; + AddUniqueCallees(A); + AddUniqueCallees(B); + return MDNode::get(A->getContext(), AB); +} + MDNode *MDNode::getMostGenericRange(MDNode *A, MDNode *B) { // Given two ranges, we want to compute the union of the ranges. This // is slightly complicated by having to combine the intervals and merge |