[llvm] 0b5051c - [llvm-reduce] Don't reuse SmallVector across calls to getAllMetadata()
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 15 14:55:03 PST 2021
Author: Arthur Eubanks
Date: 2021-11-15T14:53:48-08:00
New Revision: 0b5051cedec487f2e611ec2b582df6c23f90a046
URL: https://github.com/llvm/llvm-project/commit/0b5051cedec487f2e611ec2b582df6c23f90a046
DIFF: https://github.com/llvm/llvm-project/commit/0b5051cedec487f2e611ec2b582df6c23f90a046.diff
LOG: [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
Added:
Modified:
llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
index 2fa616c47c3f9..9ef03d4c85366 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())
More information about the llvm-commits
mailing list