[llvm] ea48d25 - llvm-reduce: Minor code cleanups
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 11 14:40:29 PST 2022
Author: Matt Arsenault
Date: 2022-11-11T14:38:19-08:00
New Revision: ea48d251c5d3ebaa28426170aa9ac809d2ffaabf
URL: https://github.com/llvm/llvm-project/commit/ea48d251c5d3ebaa28426170aa9ac809d2ffaabf
DIFF: https://github.com/llvm/llvm-project/commit/ea48d251c5d3ebaa28426170aa9ac809d2ffaabf.diff
LOG: llvm-reduce: Minor code cleanups
Added:
Modified:
llvm/tools/llvm-reduce/deltas/Delta.cpp
llvm/tools/llvm-reduce/deltas/Delta.h
Removed:
################################################################################
diff --git a/llvm/tools/llvm-reduce/deltas/Delta.cpp b/llvm/tools/llvm-reduce/deltas/Delta.cpp
index 932d7198e979..feefea15bf9e 100644
--- a/llvm/tools/llvm-reduce/deltas/Delta.cpp
+++ b/llvm/tools/llvm-reduce/deltas/Delta.cpp
@@ -104,19 +104,19 @@ static bool increaseGranularity(std::vector<Chunk> &Chunks) {
if (Verbose)
errs() << "Increasing granularity...";
std::vector<Chunk> NewChunks;
- bool SplitOne = false;
+ bool SplitAny = false;
- for (auto &C : Chunks) {
+ for (Chunk C : Chunks) {
if (C.End - C.Begin == 0)
NewChunks.push_back(C);
else {
int Half = (C.Begin + C.End) / 2;
NewChunks.push_back({C.Begin, Half});
NewChunks.push_back({Half + 1, C.End});
- SplitOne = true;
+ SplitAny = true;
}
}
- if (SplitOne) {
+ if (SplitAny) {
Chunks = NewChunks;
if (Verbose) {
errs() << "Success! " << NewChunks.size() << " New Chunks:\n";
@@ -127,7 +127,7 @@ static bool increaseGranularity(std::vector<Chunk> &Chunks) {
}
}
}
- return SplitOne;
+ return SplitAny;
}
// Check if \p ChunkToCheckForUninterestingness is interesting. Returns the
@@ -147,8 +147,8 @@ CheckChunk(Chunk &ChunkToCheckForUninterestingness,
UninterestingChunks.size() - 1);
copy_if(ChunksStillConsideredInteresting, std::back_inserter(CurrentChunks),
[&](const Chunk &C) {
- return !UninterestingChunks.count(C) &&
- C != ChunkToCheckForUninterestingness;
+ return C != ChunkToCheckForUninterestingness &&
+ !UninterestingChunks.count(C);
});
// Generate Module with only Targets inside Current Chunks
@@ -193,8 +193,7 @@ static SmallString<0> ProcessChunkFromSerializedBitcode(
SmallString<0> &OriginalBC, std::atomic<bool> &AnyReduced) {
LLVMContext Ctx;
auto CloneMMM = std::make_unique<ReducerWorkItem>();
- auto Data = MemoryBufferRef(StringRef(OriginalBC.data(), OriginalBC.size()),
- "<bc file>");
+ MemoryBufferRef Data(StringRef(OriginalBC), "<bc file>");
readBitcode(*CloneMMM, Data, Ctx, Test.getToolName());
SmallString<0> Result;
@@ -345,8 +344,7 @@ void llvm::runDeltaPass(TestRunner &Test, ReductionFunc ExtractChunksFromModule,
}
Result = std::make_unique<ReducerWorkItem>();
- auto Data = MemoryBufferRef(StringRef(Res.data(), Res.size()),
- "<bc file>");
+ MemoryBufferRef Data(StringRef(Res), "<bc file>");
readBitcode(*Result, Data, Test.getProgram().M->getContext(),
Test.getToolName());
break;
diff --git a/llvm/tools/llvm-reduce/deltas/Delta.h b/llvm/tools/llvm-reduce/deltas/Delta.h
index 6b595e796ef1..fde1b8820afe 100644
--- a/llvm/tools/llvm-reduce/deltas/Delta.h
+++ b/llvm/tools/llvm-reduce/deltas/Delta.h
@@ -31,10 +31,10 @@ struct Chunk {
bool contains(int Index) const { return Index >= Begin && Index <= End; }
void print() const {
- errs() << "[" << Begin;
+ errs() << '[' << Begin;
if (End - Begin != 0)
- errs() << "," << End;
- errs() << "]";
+ errs() << ',' << End;
+ errs() << ']';
}
/// Operator when populating CurrentChunks in Generic Delta Pass
More information about the llvm-commits
mailing list