[llvm] 309d453 - [llvm-reduce] Move most debugging output behind --verbose
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 19 13:27:46 PDT 2022
Author: Arthur Eubanks
Date: 2022-08-19T13:25:42-07:00
New Revision: 309d4538662fac082b9b0bee5720de5c240cd400
URL: https://github.com/llvm/llvm-project/commit/309d4538662fac082b9b0bee5720de5c240cd400
DIFF: https://github.com/llvm/llvm-project/commit/309d4538662fac082b9b0bee5720de5c240cd400.diff
LOG: [llvm-reduce] Move most debugging output behind --verbose
This should cut down on the visual noise when reducing. Still keep output when we run a pass or when we successfully reduce.
Notably, this also suppresses redirecting the test output to stdout/stderr.
Reviewed By: regehr
Differential Revision: https://reviews.llvm.org/D131922
Added:
Modified:
llvm/tools/llvm-reduce/TestRunner.cpp
llvm/tools/llvm-reduce/deltas/Delta.cpp
llvm/tools/llvm-reduce/deltas/Utils.cpp
llvm/tools/llvm-reduce/deltas/Utils.h
Removed:
################################################################################
diff --git a/llvm/tools/llvm-reduce/TestRunner.cpp b/llvm/tools/llvm-reduce/TestRunner.cpp
index 691790dd9e8d2..63de850de5b23 100644
--- a/llvm/tools/llvm-reduce/TestRunner.cpp
+++ b/llvm/tools/llvm-reduce/TestRunner.cpp
@@ -8,7 +8,7 @@
#include "TestRunner.h"
#include "ReducerWorkItem.h"
-#include "llvm/CodeGen/MachineFunction.h"
+#include "deltas/Utils.h"
using namespace llvm;
@@ -33,9 +33,15 @@ int TestRunner::run(StringRef Filename) {
ProgramArgs.push_back(Filename);
std::string ErrMsg;
- int Result = sys::ExecuteAndWait(
- TestName, ProgramArgs, /*Env=*/None, /*Redirects=*/None,
- /*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg);
+ SmallVector<Optional<StringRef>, 3> Redirects;
+ Optional<StringRef> Empty = StringRef();
+ if (!Verbose) {
+ for (int i = 0; i < 3; ++i)
+ Redirects.push_back(Empty);
+ }
+ int Result =
+ sys::ExecuteAndWait(TestName, ProgramArgs, /*Env=*/None, Redirects,
+ /*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg);
if (Result < 0) {
Error E = make_error<StringError>("Error running interesting-ness test: " +
diff --git a/llvm/tools/llvm-reduce/deltas/Delta.cpp b/llvm/tools/llvm-reduce/deltas/Delta.cpp
index a9f20368d47e7..8d0a4c6aa2d33 100644
--- a/llvm/tools/llvm-reduce/deltas/Delta.cpp
+++ b/llvm/tools/llvm-reduce/deltas/Delta.cpp
@@ -14,9 +14,10 @@
#include "Delta.h"
#include "ReducerWorkItem.h"
+#include "Utils.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
+#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/CodeGen/MachineFunction.h"
@@ -118,7 +119,8 @@ static int getLines(StringRef Filepath) {
/// Splits Chunks in half and prints them.
/// If unable to split (when chunk size is 1) returns false.
static bool increaseGranularity(std::vector<Chunk> &Chunks) {
- errs() << "Increasing granularity...";
+ if (Verbose)
+ errs() << "Increasing granularity...";
std::vector<Chunk> NewChunks;
bool SplitOne = false;
@@ -134,11 +136,13 @@ static bool increaseGranularity(std::vector<Chunk> &Chunks) {
}
if (SplitOne) {
Chunks = NewChunks;
- errs() << "Success! New Chunks:\n";
- for (auto C : Chunks) {
- errs() << '\t';
- C.print();
- errs() << '\n';
+ if (Verbose) {
+ errs() << "Success! New Chunks:\n";
+ for (auto C : Chunks) {
+ errs() << '\t';
+ C.print();
+ errs() << '\n';
+ }
}
}
return SplitOne;
@@ -177,20 +181,26 @@ CheckChunk(Chunk &ChunkToCheckForUninterestingness,
Clone->print(errs());
exit(1);
}
- errs() << " **** WARNING | reduction resulted in invalid module, "
- "skipping\n";
+ if (Verbose) {
+ errs() << " **** WARNING | reduction resulted in invalid module, "
+ "skipping\n";
+ }
return nullptr;
}
- errs() << "Ignoring: ";
- ChunkToCheckForUninterestingness.print();
- for (const Chunk &C : UninterestingChunks)
- C.print();
+ if (Verbose) {
+ errs() << "Ignoring: ";
+ ChunkToCheckForUninterestingness.print();
+ for (const Chunk &C : UninterestingChunks)
+ C.print();
+ errs() << "\n";
+ }
SmallString<128> CurrentFilepath;
if (!isReduced(*Clone, Test, CurrentFilepath)) {
// Program became non-reduced, so this chunk appears to be interesting.
- errs() << "\n";
+ if (Verbose)
+ errs() << "\n";
return nullptr;
}
return Clone;
@@ -263,7 +273,8 @@ void llvm::runDeltaPass(TestRunner &Test,
#endif
}
if (!Targets) {
- errs() << "\nNothing to reduce\n";
+ if (Verbose)
+ errs() << "\nNothing to reduce\n";
return;
}
@@ -382,7 +393,9 @@ void llvm::runDeltaPass(TestRunner &Test,
FoundAtLeastOneNewUninterestingChunkWithCurrentGranularity = true;
UninterestingChunks.insert(ChunkToCheckForUninterestingness);
ReducedProgram = std::move(Result);
- errs() << " **** SUCCESS | lines: " << getLines(CurrentFilepath) << "\n";
+ if (Verbose)
+ errs() << " **** SUCCESS | lines: " << getLines(CurrentFilepath)
+ << "\n";
writeOutput(*ReducedProgram, "Saved new best reduction to ");
}
// Delete uninteresting chunks
@@ -397,5 +410,6 @@ void llvm::runDeltaPass(TestRunner &Test,
// If we reduced the testcase replace it
if (ReducedProgram)
Test.setProgram(std::move(ReducedProgram));
- errs() << "Couldn't increase anymore.\n";
+ if (Verbose)
+ errs() << "Couldn't increase anymore.\n";
}
diff --git a/llvm/tools/llvm-reduce/deltas/Utils.cpp b/llvm/tools/llvm-reduce/deltas/Utils.cpp
index 46ebffda40dbd..40ef1dcd670cb 100644
--- a/llvm/tools/llvm-reduce/deltas/Utils.cpp
+++ b/llvm/tools/llvm-reduce/deltas/Utils.cpp
@@ -16,6 +16,12 @@
using namespace llvm;
+extern cl::OptionCategory LLVMReduceOptions;
+
+cl::opt<bool> llvm::Verbose("verbose",
+ cl::desc("Print extra debugging information"),
+ cl::init(false), cl::cat(LLVMReduceOptions));
+
Value *llvm::getDefaultValue(Type *T) {
return T->isVoidTy() ? PoisonValue::get(T) : Constant::getNullValue(T);
}
diff --git a/llvm/tools/llvm-reduce/deltas/Utils.h b/llvm/tools/llvm-reduce/deltas/Utils.h
index 748b6de39b618..43c38f831b179 100644
--- a/llvm/tools/llvm-reduce/deltas/Utils.h
+++ b/llvm/tools/llvm-reduce/deltas/Utils.h
@@ -15,9 +15,12 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/Value.h"
+#include "llvm/Support/CommandLine.h"
namespace llvm {
+extern cl::opt<bool> Verbose;
+
Value *getDefaultValue(Type *T);
bool hasAliasUse(Function &F);
More information about the llvm-commits
mailing list