diff --git a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp --- a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp +++ b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp @@ -36,8 +36,8 @@ } // Delete out-of-chunk metadata attached to globals. - SmallVector> MDs; for (GlobalVariable &GV : Program.globals()) { + SmallVector> MDs; GV.getAllMetadata(MDs); for (std::pair &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 &MD : MDs) - if (!O.shouldKeep()) - F.setMetadata(MD.first, NULL); + { + SmallVector> MDs; + // Delete out-of-chunk metadata attached to functions. + F.getAllMetadata(MDs); + for (std::pair &MD : MDs) + if (!O.shouldKeep()) + F.setMetadata(MD.first, NULL); + } // Delete out-of-chunk metadata attached to instructions. for (Instruction &I : instructions(F)) { + SmallVector> MDs; I.getAllMetadata(MDs); for (std::pair &MD : MDs) if (!O.shouldKeep())