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

Madhur Amilkanthwar via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 2 03:06:58 PST 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",
+};
----------------
madhur13490 wrote:

I agree with both of you. It should be consistent and I prefer no-argument format for enable/disable case. I also agree that accepting both is just deviation of that descipline. 

I took a quick scan over LangRef and here is the table. #6-9 needs changes in LangRef and the code. 
<img width="978" height="521" alt="Screenshot 2026-03-02 at 16 32 52" src="https://github.com/user-attachments/assets/94d0c98d-7b77-42a0-95c5-c0ca174ae1fc" />


Also, I think we need a RFC for this? What do we think?

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


More information about the llvm-commits mailing list