forked from OSchip/llvm-project
[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
This commit is contained in:
parent
945a306501
commit
309d453866
|
@ -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: " +
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue