[PATCH] D113808: [llvm-reduce] Don't reuse SmallVector across calls to getAllMetadata()

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 15 14:55:04 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG0b5051cedec4: [llvm-reduce] Don't reuse SmallVector across calls to getAllMetadata() (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113808/new/

https://reviews.llvm.org/D113808

Files:
  llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp


Index: llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
===================================================================
--- llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
+++ llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
@@ -36,8 +36,8 @@
   }
 
   // Delete out-of-chunk metadata attached to globals.
-  SmallVector<std::pair<unsigned, MDNode *>> MDs;
   for (GlobalVariable &GV : Program.globals()) {
+    SmallVector<std::pair<unsigned, MDNode *>> MDs;
     GV.getAllMetadata(MDs);
     for (std::pair<unsigned, MDNode *> &MD : MDs)
       if (!O.shouldKeep())
@@ -45,14 +45,18 @@
   }
 
   for (Function &F : Program) {
-    // Delete out-of-chunk metadata attached to functions.
-    F.getAllMetadata(MDs);
-    for (std::pair<unsigned, MDNode *> &MD : MDs)
-      if (!O.shouldKeep())
-        F.setMetadata(MD.first, NULL);
+    {
+      SmallVector<std::pair<unsigned, MDNode *>> MDs;
+      // Delete out-of-chunk metadata attached to functions.
+      F.getAllMetadata(MDs);
+      for (std::pair<unsigned, MDNode *> &MD : MDs)
+        if (!O.shouldKeep())
+          F.setMetadata(MD.first, NULL);
+    }
 
     // Delete out-of-chunk metadata attached to instructions.
     for (Instruction &I : instructions(F)) {
+      SmallVector<std::pair<unsigned, MDNode *>> MDs;
       I.getAllMetadata(MDs);
       for (std::pair<unsigned, MDNode *> &MD : MDs)
         if (!O.shouldKeep())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113808.387412.patch
Type: text/x-patch
Size: 1405 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211115/f3bd22ee/attachment.bin>


More information about the llvm-commits mailing list