[llvm] [Verifier] Add checks for loop metadata nodes (PR #182252)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 06:35:33 PDT 2026


================
@@ -1145,6 +1146,60 @@ void Verifier::visitMDNode(const MDNode &MD, AreDebugLocsAllowed AllowLocs) {
   Check(MD.isResolved(), "All nodes should be resolved!", &MD);
 }
 
+// Loop attributes that require exactly two operands (name + i1).
+static const StringRef LoopBooleanAttributeNames[] = {
+    "llvm.loop.distribute.enable",
+    "llvm.loop.vectorize.enable",
+};
+
+// Loop attributes that allow only a single operand (just the name).
+// TODO: This is not an exhaustive list and can also include attributes
+//       like llvm.loop.licm_versioning.disable.
+static const StringRef LoopSingleOperandAttributeNames[] = {
+    "llvm.loop.unroll.disable",
+    "llvm.loop.unroll.enable",
+    "llvm.loop.unroll.full",
+    "llvm.loop.unroll_and_jam.enable",
+    "llvm.loop.unroll_and_jam.disable",
+};
----------------
Meinersbur wrote:

Are you going to update the LangRef as well? The Clang loop hint CodeGen? Will the AutoUpdater normalize the attributes?

For the one-operand versions, what is the difference between `false` and "absent attribute"? Does absent attribute mean "it's up to the pass", `false` means "don't to anything". `llvm::hasVectorizeTransformation` matches that interpretation of `llvm.loop.vectorize.enable`, calls it `TM_SuppressedByUser`.

One step further could be to normalize `llvm.loop.vectorize.enable` into `llvm.loop.vectorize.enable` and `llvm.loop.vectorize.disable`, etc, otherwise we still have two formats of boolean attributes. Or a TODO marker if we want future boolean attributes have a single format.

https://github.com/llvm/llvm-project/pull/182252


More information about the llvm-commits mailing list