[llvm] [Verifier] Reject incorrect types in assume operand bundles (PR #196446)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun May 10 03:00:50 PDT 2026
================
@@ -5994,16 +5994,28 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
Call);
continue;
}
- Check(Elem.Tag->getKey() == "ignore" ||
- Attribute::isExistingAttribute(Elem.Tag->getKey()),
+ if (Elem.Tag->getKey() == "ignore")
+ break;
+ Check(Attribute::isExistingAttribute(Elem.Tag->getKey()),
"tags must be valid attribute names", Call);
Attribute::AttrKind Kind =
Attribute::getAttrKindFromName(Elem.Tag->getKey());
+
+ // Reject assume bundles with incorrect types
+ if (Elem.Begin != Elem.End) {
+ AttributeMask IncompatibleAttrs = AttributeFuncs::typeIncompatible(
+ Call.getOperand(Elem.Begin)->getType(),
+ AttributeSet().addAttribute(Context, Kind));
----------------
nikic wrote:
Hm, is this going to assert if Kind if a non-enum/integer attribute (e.g. type attribute or range attribute)?
I'm kind of wondering whether we shouldn't be going into the opposite direction, and explicitly listing all the allowed operand bundles with explicit validation. The current scheme where we just accept all attributes is kind of nice conceptually, but breaks down the more you think about it. Like, for many integer attributes the "integer" is just some encoding of a complex value (like `memory`) which is supposed to be an implementation detail. And for a lot of attributes I have no idea what the assume would even mean, esp. anything defomed in terms of function-local effects or provenance. Like, what is `llvm.assume(true) ["memory"(i32 0)]` supposed to mean? The current situation also makes it unclear which attributes actually have some kind of meaningful support (which is basically just the ones being explicitly verified below, plus nonnull).
https://github.com/llvm/llvm-project/pull/196446
More information about the llvm-commits
mailing list