From 0b5051cedec487f2e611ec2b582df6c23f90a046 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Fri, 12 Nov 2021 15:10:59 -0800 Subject: [PATCH] [llvm-reduce] Don't reuse SmallVector across calls to getAllMetadata() The SmallVector is not cleared in calls to getAllMetadata(). Reviewed By: Meinersbur Differential Revision: https://reviews.llvm.org/D113808 --- llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp index 2fa616c47c3f..9ef03d4c8536 100644 --- a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp +++ b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp @@ -36,8 +36,8 @@ static void extractMetadataFromModule(Oracle &O, Module &Program) { } // 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 @@ static void extractMetadataFromModule(Oracle &O, Module &Program) { } 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())