[PATCH] D113856: [llvm-reduce] Move code to check chunk to lambda, to enable reuse (NFC).
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 14 11:16:24 PST 2021
fhahn created this revision.
fhahn added reviewers: aeubanks, dblaikie, lebedev.ri, Meinersbur.
fhahn requested review of this revision.
Herald added a project: LLVM.
This patch moves the logic to clone and check a new chunk into a lambda
function, to allow re-use in a follow-up patch that implements parallel
reductions.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113856
Files:
llvm/tools/llvm-reduce/deltas/Delta.cpp
Index: llvm/tools/llvm-reduce/deltas/Delta.cpp
===================================================================
--- llvm/tools/llvm-reduce/deltas/Delta.cpp
+++ llvm/tools/llvm-reduce/deltas/Delta.cpp
@@ -140,8 +140,13 @@
FoundAtLeastOneNewUninterestingChunkWithCurrentGranularity = false;
std::set<Chunk> UninterestingChunks;
- for (Chunk &ChunkToCheckForUninterestingness :
- reverse(ChunksStillConsideredInteresting)) {
+
+ // Check if \p ChunkToCheckForUninterestingness is interesting. Returns the
+ // modified module if the chunk resulted in a reduction.
+ auto CheckChunk = [&UninterestingChunks, &Test, &ExtractChunksFromModule,
+ &ChunksStillConsideredInteresting](
+ Chunk &ChunkToCheckForUninterestingness)
+ -> std::unique_ptr<ReducerWorkItem> {
// Take all of ChunksStillConsideredInteresting chunks, except those we've
// already deemed uninteresting (UninterestingChunks) but didn't remove
// from ChunksStillConsideredInteresting yet, and additionally ignore
@@ -170,7 +175,7 @@
}
errs() << " **** WARNING | reduction resulted in invalid module, "
"skipping\n";
- continue;
+ return nullptr;
}
errs() << "Ignoring: ";
@@ -182,12 +187,21 @@
if (!isReduced(*Clone, Test, CurrentFilepath)) {
// Program became non-reduced, so this chunk appears to be interesting.
errs() << "\n";
- continue;
+ return nullptr;
}
+ return Clone;
+ };
+
+ for (Chunk &ChunkToCheckForUninterestingness :
+ reverse(ChunksStillConsideredInteresting)) {
+ std::unique_ptr<ReducerWorkItem> Result =
+ CheckChunk(ChunkToCheckForUninterestingness);
+ if (!Result)
+ continue;
FoundAtLeastOneNewUninterestingChunkWithCurrentGranularity = true;
UninterestingChunks.insert(ChunkToCheckForUninterestingness);
- ReducedProgram = std::move(Clone);
+ ReducedProgram = std::move(Result);
errs() << " **** SUCCESS | lines: " << getLines(CurrentFilepath) << "\n";
writeOutput(*ReducedProgram, "Saved new best reduction to ");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113856.387117.patch
Type: text/x-patch
Size: 2218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211114/f51584ab/attachment.bin>
More information about the llvm-commits
mailing list