[llvm] [IR][Attribute] Add support for intersecting AttributeLists; NFC (PR #109719)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 09:08:18 PDT 2024
================
@@ -903,6 +916,98 @@ AttributeSet AttributeSet::removeAttributes(LLVMContext &C,
return get(C, B);
}
+std::optional<AttributeSet>
+AttributeSet::intersectWith(LLVMContext &C, AttributeSet Other) const {
+ if (*this == Other)
+ return *this;
+ AttrBuilder Intersected(C);
+ // Get common set of all attributes then handle each attr according to its
+ // intersect rule.
+ AttributeSet Merged = addAttributes(C, Other);
----------------
nikic wrote:
It's possible to do this by iterating over both AttributeSets at once. They are sorted, so you would increment either the left or the right iterator depending on which has the larger kind.
https://github.com/llvm/llvm-project/pull/109719
More information about the llvm-commits
mailing list