llvm-reduce: Minor code cleanups
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 24 Oct 2022 17:56:18 +0000 (10:56 -0700)
committerMatt Arsenault <arsenm2@gmail.com>
Fri, 11 Nov 2022 22:38:19 +0000 (14:38 -0800)
llvm/tools/llvm-reduce/deltas/Delta.cpp
llvm/tools/llvm-reduce/deltas/Delta.h

index 932d719..feefea1 100644 (file)
@@ -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;
index 6b595e7..fde1b88 100644 (file)
@@ -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