[llvm] [LLVM-Reduce] - Distinct Metadata Reduction (PR #104624)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 16 23:52:30 PDT 2024


================
@@ -44,24 +51,32 @@ static constexpr StringLiteral ListNamedMetadata[] = {
 static void reduceNamedMetadataOperands(Oracle &O, ReducerWorkItem &WorkItem) {
   Module &M = WorkItem.getModule();
 
-  for (StringRef MDName : ListNamedMetadata) {
-    NamedMDNode *NamedNode = M.getNamedMetadata(MDName);
-    if (!NamedNode)
-      continue;
+  for (NamedMDNode &I : M.named_metadata()) {
+    // If we don't want to reduce mindlessly, check if our node is part of
+    // ListNamedMetadata before reducing it
+    if (!AggressiveMetadataReduction) {
+      bool Found = false;
+      for (StringRef MDName : ListNamedMetadata) {
+        if (I.getName() == MDName)
+          Found = true;
+      }
+      if (!Found)
+        continue;
----------------
arsenm wrote:

Use is_contained? 

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


More information about the llvm-commits mailing list