[llvm] [IR][Attribute] Add support for intersecting AttributeLists; NFC (PR #109719)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 1 20:04:14 PDT 2024
================
@@ -386,4 +389,342 @@ TEST(Attributes, CalleeAttributes) {
}
}
+TEST(Attributes, SetIntersect) {
+ LLVMContext C0, C1;
+ std::optional<AttributeSet> Res;
+ auto BuildAttr = [&](LLVMContext &C, Attribute::AttrKind Kind, uint64_t Int,
+ Type *Ty, ConstantRange &CR,
+ ArrayRef<ConstantRange> CRList) {
+ if (Attribute::isEnumAttrKind(Kind))
+ return Attribute::get(C, Kind);
+ if (Attribute::isTypeAttrKind(Kind))
+ return Attribute::get(C, Kind, Ty);
+ if (Attribute::isIntAttrKind(Kind))
+ return Attribute::get(C, Kind, Int);
+ if (Attribute::isConstantRangeAttrKind(Kind))
+ return Attribute::get(C, Kind, CR);
+ if (Attribute::isConstantRangeListAttrKind(Kind))
+ return Attribute::get(C, Kind, CRList);
+ std::abort();
+ };
+ for (unsigned i = Attribute::AttrKind::None + 1,
+ e = Attribute::AttrKind::EndAttrKinds;
+ i < e; ++i) {
+ Attribute::AttrKind Kind = static_cast<Attribute::AttrKind>(i);
+
+ Attribute::AttrKind Other =
+ Kind == Attribute::NoUndef ? Attribute::NonNull : Attribute::NoUndef;
+ AttributeSet AS0, AS1;
+ AttrBuilder AB0(C0);
+ AttrBuilder AB1(C1);
+ uint64_t V0, V1;
+ V0 = 0;
+ V1 = 0;
+ if (Attribute::intersectWithCustom(Kind)) {
+ switch (Kind) {
+ case Attribute::Alignment:
+ V0 = 2;
+ V1 = 4;
+ break;
+ case Attribute::Memory:
+ V0 = MemoryEffects::readOnly().toIntValue();
+ V1 = MemoryEffects::none().toIntValue();
+ break;
+ case Attribute::NoFPClass:
+ V0 = FPClassTest::fcNan | FPClassTest::fcInf;
+ V1 = FPClassTest::fcNan;
+ break;
+ case Attribute::Range:
+ break;
+ default:
+ ASSERT_FALSE(true);
+ }
+ } else {
+ V0 = (i & 2) + 1;
+ V1 = (2 - (i & 2)) + 1;
+ }
+
+ ConstantRange CR0(APInt(32, 0), APInt(32, 10));
----------------
goldsteinn wrote:
Sorry about that and thank you for the prompt fix.
https://github.com/llvm/llvm-project/pull/109719
More information about the llvm-commits
mailing list