[llvm-reduce] Unify pass logging
authorArthur Eubanks <aeubanks@google.com>
Tue, 18 Oct 2022 04:43:08 +0000 (21:43 -0700)
committerArthur Eubanks <aeubanks@google.com>
Tue, 18 Oct 2022 15:42:37 +0000 (08:42 -0700)
We randomly use outs() or errs(), which makes test logs confusing.
We also randomly add/don't add a line afterward.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D136130

33 files changed:
llvm/tools/llvm-reduce/deltas/Delta.cpp
llvm/tools/llvm-reduce/deltas/Delta.h
llvm/tools/llvm-reduce/deltas/ReduceAliases.cpp
llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp
llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp
llvm/tools/llvm-reduce/deltas/ReduceFunctionBodies.cpp
llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp
llvm/tools/llvm-reduce/deltas/ReduceGlobalValues.cpp
llvm/tools/llvm-reduce/deltas/ReduceGlobalVarInitializers.cpp
llvm/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp
llvm/tools/llvm-reduce/deltas/ReduceIRReferences.cpp
llvm/tools/llvm-reduce/deltas/ReduceInstructionFlagsMIR.cpp
llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp
llvm/tools/llvm-reduce/deltas/ReduceInstructionsMIR.cpp
llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
llvm/tools/llvm-reduce/deltas/ReduceModuleData.cpp
llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp
llvm/tools/llvm-reduce/deltas/ReduceOperandBundles.cpp
llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
llvm/tools/llvm-reduce/deltas/ReduceOperandsSkip.cpp
llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
llvm/tools/llvm-reduce/deltas/ReduceRegisterDefs.cpp
llvm/tools/llvm-reduce/deltas/ReduceRegisterMasks.cpp
llvm/tools/llvm-reduce/deltas/ReduceRegisterUses.cpp
llvm/tools/llvm-reduce/deltas/ReduceSpecialGlobals.cpp
llvm/tools/llvm-reduce/deltas/ReduceUsingSimplifyCFG.cpp
llvm/tools/llvm-reduce/deltas/ReduceVirtualRegisters.cpp
llvm/tools/llvm-reduce/deltas/RunIRPasses.cpp
llvm/tools/llvm-reduce/deltas/SimplifyInstructions.cpp
llvm/tools/llvm-reduce/llvm-reduce.cpp

index e8224ca..73a00e6 100644 (file)
@@ -235,10 +235,11 @@ SmallString<0> ProcessChunkFromSerializedBitcode(
 /// reduces the amount of chunks that are considered interesting by the
 /// given test. The number of chunks is determined by a preliminary run of the
 /// reduction pass where no change must be made to the module.
-void llvm::runDeltaPass(TestRunner &Test,
-                        ReductionFunc ExtractChunksFromModule) {
+void llvm::runDeltaPass(TestRunner &Test, ReductionFunc ExtractChunksFromModule,
+                        StringRef Message) {
   assert(!verifyReducerWorkItem(Test.getProgram(), &errs()) &&
          "input module is broken before making changes");
+  errs() << "*** " << Message << "...\n";
 
   SmallString<128> CurrentFilepath;
   if (!isReduced(Test.getProgram(), Test, CurrentFilepath)) {
@@ -275,6 +276,7 @@ void llvm::runDeltaPass(TestRunner &Test,
   if (!Targets) {
     if (Verbose)
       errs() << "\nNothing to reduce\n";
+    errs() << "----------------------------\n";
     return;
   }
 
@@ -412,4 +414,5 @@ void llvm::runDeltaPass(TestRunner &Test,
     Test.setProgram(std::move(ReducedProgram));
   if (Verbose)
     errs() << "Couldn't increase anymore.\n";
+  errs() << "----------------------------\n";
 }
index f8c8ede..e89cb72 100644 (file)
@@ -105,7 +105,8 @@ using ReductionFunc = function_ref<void(Oracle &, ReducerWorkItem &)>;
 ///
 /// Other implementations of the Delta Debugging algorithm can also be found in
 /// the CReduce, Delta, and Lithium projects.
-void runDeltaPass(TestRunner &Test, ReductionFunc ExtractChunksFromModule);
+void runDeltaPass(TestRunner &Test, ReductionFunc ExtractChunksFromModule,
+                  StringRef Message);
 } // namespace llvm
 
 #endif
index cdcd426..8ceae20 100644 (file)
@@ -30,7 +30,5 @@ static void extractAliasesFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceAliasesDeltaPass(TestRunner &Test) {
-  errs() << "*** Reducing Aliases ...\n";
-  runDeltaPass(Test, extractAliasesFromModule);
-  errs() << "----------------------------\n";
+  runDeltaPass(Test, extractAliasesFromModule, "Reducing Aliases");
 }
index 45b5525..e251256 100644 (file)
@@ -119,6 +119,5 @@ static void extractArgumentsFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceArgumentsDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing Arguments...\n";
-  runDeltaPass(Test, extractArgumentsFromModule);
+  runDeltaPass(Test, extractArgumentsFromModule, "Reducing Arguments");
 }
index 7b87088..35d8b84 100644 (file)
@@ -178,6 +178,5 @@ static void extractAttributesFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceAttributesDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing Attributes...\n";
-  runDeltaPass(Test, extractAttributesFromModule);
+  runDeltaPass(Test, extractAttributesFromModule, "Reducing Attributes");
 }
index 1cef2a1..5f70640 100644 (file)
@@ -173,6 +173,5 @@ static void extractBasicBlocksFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceBasicBlocksDeltaPass(TestRunner &Test) {
-  errs() << "*** Reducing Basic Blocks...\n";
-  runDeltaPass(Test, extractBasicBlocksFromModule);
+  runDeltaPass(Test, extractBasicBlocksFromModule, "Reducing Basic Blocks");
 }
index 474139e..6ae535f 100644 (file)
@@ -96,7 +96,5 @@ static void extractDIMetadataFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceDIMetadataDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing DIMetadata...\n";
-  runDeltaPass(Test, extractDIMetadataFromModule);
-  outs() << "----------------------------\n";
+  runDeltaPass(Test, extractDIMetadataFromModule, "Reducing DIMetadata");
 }
index ed583e9..19cda6d 100644 (file)
@@ -31,7 +31,6 @@ static void extractFunctionBodiesFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceFunctionBodiesDeltaPass(TestRunner &Test) {
-  errs() << "*** Reducing Function Bodies...\n";
-  runDeltaPass(Test, extractFunctionBodiesFromModule);
-  errs() << "----------------------------\n";
+  runDeltaPass(Test, extractFunctionBodiesFromModule,
+               "Reducing Function Bodies");
 }
index faade8a..61f7af9 100644 (file)
@@ -50,7 +50,5 @@ static void extractFunctionsFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceFunctionsDeltaPass(TestRunner &Test) {
-  errs() << "*** Reducing Functions...\n";
-  runDeltaPass(Test, extractFunctionsFromModule);
-  errs() << "----------------------------\n";
+  runDeltaPass(Test, extractFunctionsFromModule, "Reducing Functions");
 }
index 1a95260..8677a72 100644 (file)
@@ -31,6 +31,5 @@ static void reduceGOs(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceGlobalObjectsDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing GlobalObjects...\n";
-  runDeltaPass(Test, reduceGOs);
+  runDeltaPass(Test, reduceGOs, "Reducing GlobalObjects");
 }
index 26a3cbd..eb0ea4e 100644 (file)
@@ -58,6 +58,5 @@ static void reduceGVs(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceGlobalValuesDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing GlobalValues...\n";
-  runDeltaPass(Test, reduceGVs);
+  runDeltaPass(Test, reduceGVs, "Reducing GlobalValues");
 }
index c9e4d9f..9765b38 100644 (file)
@@ -29,6 +29,5 @@ static void extractGVsFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceGlobalsInitializersDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing GVs initializers...\n";
-  runDeltaPass(Test, extractGVsFromModule);
+  runDeltaPass(Test, extractGVsFromModule, "Reducing GV Initializers");
 }
index 908c984..bc45f69 100644 (file)
@@ -59,6 +59,5 @@ static void extractGVsFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceGlobalsDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing GVs...\n";
-  runDeltaPass(Test, extractGVsFromModule);
+  runDeltaPass(Test, extractGVsFromModule, "Reducing GlobalVariables");
 }
index 975bdc2..1e78176 100644 (file)
@@ -67,16 +67,15 @@ static void stripIRFromFunctions(Oracle &O, ReducerWorkItem &WorkItem) {
 }
 
 void llvm::reduceIRInstructionReferencesDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing IR references from instructions...\n";
-  runDeltaPass(Test, stripIRFromInstructions);
+  runDeltaPass(Test, stripIRFromInstructions,
+               "Reducing IR references from instructions");
 }
 
 void llvm::reduceIRBlockReferencesDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing IR references from blocks...\n";
-  runDeltaPass(Test, stripIRFromBlocks);
+  runDeltaPass(Test, stripIRFromBlocks, "Reducing IR references from blocks");
 }
 
 void llvm::reduceIRFunctionReferencesDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing IR references from functions...\n";
-  runDeltaPass(Test, stripIRFromFunctions);
+  runDeltaPass(Test, stripIRFromFunctions,
+               "Reducing IR references from functions");
 }
index 4c3b4d3..72882a8 100644 (file)
@@ -30,6 +30,5 @@ static void removeFlagsFromModule(Oracle &O, ReducerWorkItem &WorkItem) {
 }
 
 void llvm::reduceInstructionFlagsMIRDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing Instruction flags...\n";
-  runDeltaPass(Test, removeFlagsFromModule);
+  runDeltaPass(Test, removeFlagsFromModule, "Reducing Instruction Flags");
 }
index 078da9e..bdd227b 100644 (file)
@@ -52,6 +52,5 @@ static void extractInstrFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceInstructionsDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing Instructions...\n";
-  runDeltaPass(Test, extractInstrFromModule);
+  runDeltaPass(Test, extractInstrFromModule, "Reducing Instructions");
 }
index f21bcdc..6324092 100644 (file)
@@ -158,6 +158,5 @@ static void extractInstrFromModule(Oracle &O, ReducerWorkItem &WorkItem) {
 }
 
 void llvm::reduceInstructionsMIRDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing Instructions...\n";
-  runDeltaPass(Test, extractInstrFromModule);
+  runDeltaPass(Test, extractInstrFromModule, "Reducing Instructions");
 }
index 0681e35..c2a20db 100644 (file)
@@ -76,7 +76,5 @@ static void extractMetadataFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceMetadataDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing Metadata...\n";
-  runDeltaPass(Test, extractMetadataFromModule);
-  outs() << "----------------------------\n";
+  runDeltaPass(Test, extractMetadataFromModule, "Reducing Metadata");
 }
index cbde789..7c31437 100644 (file)
@@ -25,6 +25,5 @@ static void clearModuleData(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceModuleDataDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing Module Data...\n";
-  runDeltaPass(Test, clearModuleData);
+  runDeltaPass(Test, clearModuleData, "Reducing Module Data");
 }
index 327125b..99beb31 100644 (file)
@@ -107,6 +107,5 @@ static void replaceOpcodesInModule(Oracle &O, Module &Mod) {
 }
 
 void llvm::reduceOpcodesDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing Opcodes...\n";
-  runDeltaPass(Test, replaceOpcodesInModule);
+  runDeltaPass(Test, replaceOpcodesInModule, "Reducing Opcodes");
 }
index c28bbb2..0998d6b 100644 (file)
@@ -104,6 +104,6 @@ static void extractOperandBundesFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceOperandBundesDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing OperandBundes...\n";
-  runDeltaPass(Test, extractOperandBundesFromModule);
+  runDeltaPass(Test, extractOperandBundesFromModule,
+               "Reducing Operand Bundles");
 }
index 773d19c..348421b 100644 (file)
@@ -82,7 +82,6 @@ static bool switchCaseExists(Use &Op, ConstantInt *CI) {
 }
 
 void llvm::reduceOperandsOneDeltaPass(TestRunner &Test) {
-  errs() << "*** Reducing Operands to one...\n";
   auto ReduceValue = [](Use &Op) -> Value * {
     if (!shouldReduceOperand(Op))
       return nullptr;
@@ -117,13 +116,15 @@ void llvm::reduceOperandsOneDeltaPass(TestRunner &Test) {
 
     return nullptr;
   };
-  runDeltaPass(Test, [ReduceValue](Oracle &O, Module &Program) {
-    extractOperandsFromModule(O, Program, ReduceValue);
-  });
+  runDeltaPass(
+      Test,
+      [ReduceValue](Oracle &O, Module &Program) {
+        extractOperandsFromModule(O, Program, ReduceValue);
+      },
+      "Reducing Operands to one");
 }
 
 void llvm::reduceOperandsZeroDeltaPass(TestRunner &Test) {
-  errs() << "*** Reducing Operands to zero...\n";
   auto ReduceValue = [](Use &Op) -> Value * {
     if (!shouldReduceOperand(Op))
       return nullptr;
@@ -134,13 +135,15 @@ void llvm::reduceOperandsZeroDeltaPass(TestRunner &Test) {
     // Don't replace existing zeroes.
     return isZero(Op) ? nullptr : Constant::getNullValue(Op->getType());
   };
-  runDeltaPass(Test, [ReduceValue](Oracle &O, Module &Program) {
-    extractOperandsFromModule(O, Program, ReduceValue);
-  });
+  runDeltaPass(
+      Test,
+      [ReduceValue](Oracle &O, Module &Program) {
+        extractOperandsFromModule(O, Program, ReduceValue);
+      },
+      "Reducing Operands to zero");
 }
 
 void llvm::reduceOperandsNaNDeltaPass(TestRunner &Test) {
-  errs() << "*** Reducing Operands to NaN...\n";
   auto ReduceValue = [](Use &Op) -> Value * {
     Type *Ty = Op->getType();
     if (!Ty->isFPOrFPVectorTy())
@@ -160,7 +163,10 @@ void llvm::reduceOperandsNaNDeltaPass(TestRunner &Test) {
 
     return ConstantFP::getQNaN(Ty);
   };
-  runDeltaPass(Test, [ReduceValue](Oracle &O, Module &Program) {
-    extractOperandsFromModule(O, Program, ReduceValue);
-  });
+  runDeltaPass(
+      Test,
+      [ReduceValue](Oracle &O, Module &Program) {
+        extractOperandsFromModule(O, Program, ReduceValue);
+      },
+      "Reducing Operands to NaN");
 }
index bb15a72..8120bfa 100644 (file)
@@ -222,6 +222,6 @@ static void extractOperandsFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceOperandsSkipDeltaPass(TestRunner &Test) {
-  errs() << "*** Reducing operands by skipping over instructions ...\n";
-  runDeltaPass(Test, extractOperandsFromModule);
+  runDeltaPass(Test, extractOperandsFromModule,
+               "Reducing operands by skipping over instructions");
 }
index f738a51..c77cccb 100644 (file)
@@ -195,6 +195,6 @@ static void reduceOperandsToArgs(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceOperandsToArgsDeltaPass(TestRunner &Test) {
-  outs() << "*** Converting operands to function arguments ...\n";
-  return runDeltaPass(Test, reduceOperandsToArgs);
+  runDeltaPass(Test, reduceOperandsToArgs,
+               "Converting operands to function arguments");
 }
index ab4d28a..2c17aea 100644 (file)
@@ -117,6 +117,5 @@ static void removeDefsFromModule(Oracle &O, ReducerWorkItem &WorkItem) {
 }
 
 void llvm::reduceRegisterDefsMIRDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing register defs...\n";
-  runDeltaPass(Test, removeDefsFromModule);
+  runDeltaPass(Test, removeDefsFromModule, "Reducing register defs");
 }
index 93d833c..acb378b 100644 (file)
@@ -68,6 +68,5 @@ static void reduceMasksInModule(Oracle &O, ReducerWorkItem &WorkItem) {
 }
 
 void llvm::reduceRegisterMasksMIRDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing register masks...\n";
-  runDeltaPass(Test, reduceMasksInModule);
+  runDeltaPass(Test, reduceMasksInModule, "Reducing register masks");
 }
index a461cb8..6ada985 100644 (file)
@@ -62,6 +62,5 @@ static void removeUsesFromModule(Oracle &O, ReducerWorkItem &WorkItem) {
 }
 
 void llvm::reduceRegisterUsesMIRDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing register uses...\n";
-  runDeltaPass(Test, removeUsesFromModule);
+  runDeltaPass(Test, removeUsesFromModule, "Reducing register uses");
 }
index a86db31..0e35695 100644 (file)
@@ -37,7 +37,6 @@ static void extractSpecialGlobalsFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceSpecialGlobalsDeltaPass(TestRunner &Test) {
-  errs() << "*** Reducing Special Globals ...\n";
-  runDeltaPass(Test, extractSpecialGlobalsFromModule);
-  errs() << "----------------------------\n";
+  runDeltaPass(Test, extractSpecialGlobalsFromModule,
+               "Reducing Special Globals");
 }
index 504f4c2..a45d571 100644 (file)
@@ -29,6 +29,5 @@ static void reduceUsingSimplifyCFG(Oracle &O, Module &Program) {
 }
 
 void llvm::reduceUsingSimplifyCFGDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing using SimplifyCFG...\n";
-  runDeltaPass(Test, reduceUsingSimplifyCFG);
+  runDeltaPass(Test, reduceUsingSimplifyCFG, "Reducing using SimplifyCFG");
 }
index 1c5bda8..4c9ea85 100644 (file)
@@ -41,6 +41,6 @@ static void dropRegisterHintsFromFunctions(Oracle &O,
 }
 
 void llvm::reduceVirtualRegisterHintsDeltaPass(TestRunner &Test) {
-  outs() << "*** Reducing virtual register hints from functions...\n";
-  runDeltaPass(Test, dropRegisterHintsFromFunctions);
+  runDeltaPass(Test, dropRegisterHintsFromFunctions,
+               "Reducing virtual register hints from functions");
 }
index ba93ba7..0071047 100644 (file)
@@ -47,7 +47,5 @@ static void runPasses(Oracle &O, Module &Program) {
 }
 
 void llvm::runIRPassesDeltaPass(TestRunner &Test) {
-  errs() << "*** Running passes ...\n";
-  runDeltaPass(Test, runPasses);
-  errs() << "----------------------------\n";
+  runDeltaPass(Test, runPasses, "Running passes");
 }
index 6e2e52a..7bf3eb1 100644 (file)
@@ -45,6 +45,5 @@ static void extractInstrFromModule(Oracle &O, Module &Program) {
 }
 
 void llvm::simplifyInstructionsDeltaPass(TestRunner &Test) {
-  outs() << "*** Simplifying Instructions...\n";
-  runDeltaPass(Test, extractInstrFromModule);
+  runDeltaPass(Test, extractInstrFromModule, "Simplifying Instructions");
 }
index c7606b5..13c6edc 100644 (file)
@@ -189,7 +189,7 @@ int main(int Argc, char **Argv) {
   if (OutputFilename == "-")
     Tester.getProgram().print(outs(), nullptr);
   else
-    writeOutput(Tester.getProgram(), "\nDone reducing! Reduced testcase: ");
+    writeOutput(Tester.getProgram(), "Done reducing! Reduced testcase: ");
 
   return 0;
 }