summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2021-11-12 15:10:59 -0800
committerArthur Eubanks <aeubanks@google.com>2021-11-15 14:53:48 -0800
commit0b5051cedec487f2e611ec2b582df6c23f90a046 (patch)
tree0f592c2c558d93124988190307505232040258a9
parentcdb0623ad82751c87d9c7d4b2c6eaf0c5ccf3719 (diff)
[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
-rw-r--r--llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp16
1 files 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<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 @@ 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<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())