summaryrefslogtreecommitdiffstats
path: root/llvm/tools/bugpoint/CrashDebugger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/bugpoint/CrashDebugger.cpp')
-rw-r--r--llvm/tools/bugpoint/CrashDebugger.cpp72
1 files changed, 28 insertions, 44 deletions
diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index 649cac7c681..7a565c0140b 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -71,14 +71,13 @@ public:
// passes. If we return true, we update the current module of bugpoint.
//
TestResult doTest(std::vector<std::string> &Removed,
- std::vector<std::string> &Kept,
- std::string &Error) override;
+ std::vector<std::string> &Kept) override;
};
}
ReducePassList::TestResult
ReducePassList::doTest(std::vector<std::string> &Prefix,
- std::vector<std::string> &Suffix, std::string &Error) {
+ std::vector<std::string> &Suffix) {
std::string PrefixOutput;
Module *OrigProgram = nullptr;
if (!Prefix.empty()) {
@@ -129,8 +128,7 @@ public:
: BD(bd), TestFn(testFn) {}
TestResult doTest(std::vector<GlobalVariable *> &Prefix,
- std::vector<GlobalVariable *> &Kept,
- std::string &Error) override {
+ std::vector<GlobalVariable *> &Kept) override {
if (!Kept.empty() && TestGlobalVariables(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestGlobalVariables(Prefix))
@@ -199,8 +197,7 @@ public:
: BD(bd), TestFn(testFn) {}
TestResult doTest(std::vector<Function *> &Prefix,
- std::vector<Function *> &Kept,
- std::string &Error) override {
+ std::vector<Function *> &Kept) override {
if (!Kept.empty() && TestFuncs(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestFuncs(Prefix))
@@ -373,8 +370,7 @@ public:
: BD(BD), TestFn(testFn) {}
TestResult doTest(std::vector<const BasicBlock *> &Prefix,
- std::vector<const BasicBlock *> &Kept,
- std::string &Error) override {
+ std::vector<const BasicBlock *> &Kept) override {
if (!Kept.empty() && TestBlocks(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestBlocks(Prefix))
@@ -495,8 +491,7 @@ public:
: BD(bd), TestFn(testFn), Direction(Direction) {}
TestResult doTest(std::vector<const BasicBlock *> &Prefix,
- std::vector<const BasicBlock *> &Kept,
- std::string &Error) override {
+ std::vector<const BasicBlock *> &Kept) override {
if (!Kept.empty() && TestBlocks(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestBlocks(Prefix))
@@ -603,8 +598,7 @@ public:
: BD(bd), TestFn(testFn), TTI(bd.getProgram()->getDataLayout()) {}
TestResult doTest(std::vector<const BasicBlock *> &Prefix,
- std::vector<const BasicBlock *> &Kept,
- std::string &Error) override {
+ std::vector<const BasicBlock *> &Kept) override {
if (!Kept.empty() && TestBlocks(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestBlocks(Prefix))
@@ -698,8 +692,7 @@ public:
: BD(bd), TestFn(testFn) {}
TestResult doTest(std::vector<const Instruction *> &Prefix,
- std::vector<const Instruction *> &Kept,
- std::string &Error) override {
+ std::vector<const Instruction *> &Kept) override {
if (!Kept.empty() && TestInsts(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestInsts(Prefix))
@@ -775,8 +768,7 @@ public:
: BD(bd), TestFn(testFn) {}
TestResult doTest(std::vector<std::string> &Prefix,
- std::vector<std::string> &Kept,
- std::string &Error) override {
+ std::vector<std::string> &Kept) override {
if (!Kept.empty() && TestNamedMDs(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestNamedMDs(Prefix))
@@ -845,8 +837,7 @@ public:
: BD(bd), TestFn(testFn) {}
TestResult doTest(std::vector<const MDNode *> &Prefix,
- std::vector<const MDNode *> &Kept,
- std::string &Error) override {
+ std::vector<const MDNode *> &Kept) override {
if (!Kept.empty() && TestNamedMDOps(Kept))
return KeepSuffix;
if (!Prefix.empty() && TestNamedMDOps(Prefix))
@@ -909,8 +900,7 @@ bool ReduceCrashingNamedMDOps::TestNamedMDOps(
static void ReduceGlobalInitializers(BugDriver &BD,
bool (*TestFn)(const BugDriver &,
- Module *),
- std::string &Error) {
+ Module *)) {
if (BD.getProgram()->global_begin() != BD.getProgram()->global_end()) {
// Now try to reduce the number of global variable initializers in the
// module to something small.
@@ -952,8 +942,7 @@ static void ReduceGlobalInitializers(BugDriver &BD,
<< "variables in the testcase\n";
unsigned OldSize = GVs.size();
- ReduceCrashingGlobalVariables(BD, TestFn).reduceList(GVs, Error);
- assert(!Error.empty());
+ ReduceCrashingGlobalVariables(BD, TestFn).reduceList(GVs);
if (GVs.size() < OldSize)
BD.EmitProgressBitcode(BD.getProgram(), "reduced-global-variables");
@@ -964,8 +953,7 @@ static void ReduceGlobalInitializers(BugDriver &BD,
}
static void ReduceInsts(BugDriver &BD,
- bool (*TestFn)(const BugDriver &, Module *),
- std::string &Error) {
+ bool (*TestFn)(const BugDriver &, Module *)) {
// Attempt to delete instructions using bisection. This should help out nasty
// cases with large basic blocks where the problem is at one end.
if (!BugpointIsInterrupted) {
@@ -976,7 +964,7 @@ static void ReduceInsts(BugDriver &BD,
if (!isa<TerminatorInst>(&I))
Insts.push_back(&I);
- ReduceCrashingInstructions(BD, TestFn).reduceList(Insts, Error);
+ ReduceCrashingInstructions(BD, TestFn).reduceList(Insts);
}
unsigned Simplification = 2;
@@ -1046,12 +1034,11 @@ static void ReduceInsts(BugDriver &BD,
/// on a program, try to destructively reduce the program while still keeping
/// the predicate true.
static bool DebugACrash(BugDriver &BD,
- bool (*TestFn)(const BugDriver &, Module *),
- std::string &Error) {
+ bool (*TestFn)(const BugDriver &, Module *)) {
// See if we can get away with nuking some of the global variable initializers
// in the program...
if (!NoGlobalRM)
- ReduceGlobalInitializers(BD, TestFn, Error);
+ ReduceGlobalInitializers(BD, TestFn);
// Now try to reduce the number of functions in the module to something small.
std::vector<Function *> Functions;
@@ -1064,7 +1051,7 @@ static bool DebugACrash(BugDriver &BD,
"in the testcase\n";
unsigned OldSize = Functions.size();
- ReduceCrashingFunctions(BD, TestFn).reduceList(Functions, Error);
+ ReduceCrashingFunctions(BD, TestFn).reduceList(Functions);
if (Functions.size() < OldSize)
BD.EmitProgressBitcode(BD.getProgram(), "reduced-function");
@@ -1078,8 +1065,8 @@ static bool DebugACrash(BugDriver &BD,
for (BasicBlock &BB : F)
Blocks.push_back(&BB);
unsigned OldSize = Blocks.size();
- ReduceCrashingConditionals(BD, TestFn, true).reduceList(Blocks, Error);
- ReduceCrashingConditionals(BD, TestFn, false).reduceList(Blocks, Error);
+ ReduceCrashingConditionals(BD, TestFn, true).reduceList(Blocks);
+ ReduceCrashingConditionals(BD, TestFn, false).reduceList(Blocks);
if (Blocks.size() < OldSize)
BD.EmitProgressBitcode(BD.getProgram(), "reduced-conditionals");
}
@@ -1095,7 +1082,7 @@ static bool DebugACrash(BugDriver &BD,
for (BasicBlock &BB : F)
Blocks.push_back(&BB);
unsigned OldSize = Blocks.size();
- ReduceCrashingBlocks(BD, TestFn).reduceList(Blocks, Error);
+ ReduceCrashingBlocks(BD, TestFn).reduceList(Blocks);
if (Blocks.size() < OldSize)
BD.EmitProgressBitcode(BD.getProgram(), "reduced-blocks");
}
@@ -1106,7 +1093,7 @@ static bool DebugACrash(BugDriver &BD,
for (BasicBlock &BB : F)
Blocks.push_back(&BB);
unsigned OldSize = Blocks.size();
- ReduceSimplifyCFG(BD, TestFn).reduceList(Blocks, Error);
+ ReduceSimplifyCFG(BD, TestFn).reduceList(Blocks);
if (Blocks.size() < OldSize)
BD.EmitProgressBitcode(BD.getProgram(), "reduced-simplifycfg");
}
@@ -1114,7 +1101,7 @@ static bool DebugACrash(BugDriver &BD,
// Attempt to delete instructions using bisection. This should help out nasty
// cases with large basic blocks where the problem is at one end.
if (!BugpointIsInterrupted)
- ReduceInsts(BD, TestFn, Error);
+ ReduceInsts(BD, TestFn);
if (!NoNamedMDRM) {
if (!BugpointIsInterrupted) {
@@ -1124,7 +1111,7 @@ static bool DebugACrash(BugDriver &BD,
std::vector<std::string> NamedMDNames;
for (auto &NamedMD : BD.getProgram()->named_metadata())
NamedMDNames.push_back(NamedMD.getName().str());
- ReduceCrashingNamedMD(BD, TestFn).reduceList(NamedMDNames, Error);
+ ReduceCrashingNamedMD(BD, TestFn).reduceList(NamedMDNames);
}
if (!BugpointIsInterrupted) {
@@ -1134,7 +1121,7 @@ static bool DebugACrash(BugDriver &BD,
for (auto &NamedMD : BD.getProgram()->named_metadata())
for (auto op : NamedMD.operands())
NamedMDOps.push_back(op);
- ReduceCrashingNamedMDOps(BD, TestFn).reduceList(NamedMDOps, Error);
+ ReduceCrashingNamedMDOps(BD, TestFn).reduceList(NamedMDOps);
}
BD.EmitProgressBitcode(BD.getProgram(), "reduced-named-md");
}
@@ -1169,11 +1156,9 @@ static bool TestForOptimizerCrash(const BugDriver &BD, Module *M) {
bool BugDriver::debugOptimizerCrash(const std::string &ID) {
outs() << "\n*** Debugging optimizer crash!\n";
- std::string Error;
// Reduce the list of passes which causes the optimizer to crash...
if (!BugpointIsInterrupted && !DontReducePassList)
- ReducePassList(*this).reduceList(PassesToRun, Error);
- assert(Error.empty());
+ ReducePassList(*this).reduceList(PassesToRun);
outs() << "\n*** Found crashing pass"
<< (PassesToRun.size() == 1 ? ": " : "es: ")
@@ -1181,8 +1166,7 @@ bool BugDriver::debugOptimizerCrash(const std::string &ID) {
EmitProgressBitcode(Program, ID);
- bool Success = DebugACrash(*this, TestForOptimizerCrash, Error);
- assert(Error.empty());
+ bool Success = DebugACrash(*this, TestForOptimizerCrash);
return Success;
}
@@ -1203,8 +1187,8 @@ static bool TestForCodeGenCrash(const BugDriver &BD, Module *M) {
/// debugCodeGeneratorCrash - This method is called when the code generator
/// crashes on an input. It attempts to reduce the input as much as possible
/// while still causing the code generator to crash.
-bool BugDriver::debugCodeGeneratorCrash(std::string &Error) {
+bool BugDriver::debugCodeGeneratorCrash() {
errs() << "*** Debugging code generator crash!\n";
- return DebugACrash(*this, TestForCodeGenCrash, Error);
+ return DebugACrash(*this, TestForCodeGenCrash);
}
OpenPOWER on IntegriCloud