[llvm] ec75be1 - [VPlan] Assert that addMetadata does not add duplicates (NFC).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 10 08:44:41 PST 2025


Author: Florian Hahn
Date: 2025-11-10T16:43:47Z
New Revision: ec75be1aa15b7e78758582883c4296a636f415df

URL: https://github.com/llvm/llvm-project/commit/ec75be1aa15b7e78758582883c4296a636f415df
DIFF: https://github.com/llvm/llvm-project/commit/ec75be1aa15b7e78758582883c4296a636f415df.diff

LOG: [VPlan] Assert that addMetadata does not add duplicates (NFC).

Duplicates are not supported, and would require kind-specific merging of
metadata.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlan.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 5851b3ab7978c..72858e1265d86 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -959,6 +959,11 @@ class VPIRMetadata {
 
   /// Add metadata with kind \p Kind and \p Node.
   void addMetadata(unsigned Kind, MDNode *Node) {
+    assert(none_of(Metadata,
+                   [Kind](const std::pair<unsigned, MDNode *> &P) {
+                     return P.first == Kind;
+                   }) &&
+           "Kind must appear at most once in Metadata");
     Metadata.emplace_back(Kind, Node);
   }
 


        


More information about the llvm-commits mailing list