summaryrefslogtreecommitdiffstats
path: root/llvm/tools/bugpoint
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2016-06-29 00:43:18 +0000
committerPhilip Reames <listmail@philipreames.com>2016-06-29 00:43:18 +0000
commit1c232f9b6667248a5dea1df6ef69f84b1bd488cd (patch)
tree8eecc13152ff173590e0d71354259e30ce4f99da /llvm/tools/bugpoint
parent8d74cb27e82440dbf1bea123613fc373e203680a (diff)
downloadbcm5719-llvm-1c232f9b6667248a5dea1df6ef69f84b1bd488cd.tar.gz
bcm5719-llvm-1c232f9b6667248a5dea1df6ef69f84b1bd488cd.zip
[bugpoint] Extract helper functions for readability [NFCI]
And remove the use of a label(!) in the process. llvm-svn: 274087
Diffstat (limited to 'llvm/tools/bugpoint')
-rw-r--r--llvm/tools/bugpoint/CrashDebugger.cpp115
1 files changed, 64 insertions, 51 deletions
diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index fe015f81349..052874dbf44 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -649,16 +649,10 @@ bool ReduceCrashingNamedMDOps::TestNamedMDOps(
return false;
}
-/// DebugACrash - Given a predicate that determines whether a component crashes
-/// 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) {
- // See if we can get away with nuking some of the global variable initializers
- // in the program...
- if (!NoGlobalRM &&
- BD.getProgram()->global_begin() != BD.getProgram()->global_end()) {
+static void ReduceGlobalInitializers(BugDriver &BD,
+ bool (*TestFn)(const BugDriver &, Module *),
+ std::string &Error) {
+ 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.
Module *M = CloneModule(BD.getProgram()).release();
@@ -699,8 +693,7 @@ static bool DebugACrash(BugDriver &BD,
unsigned OldSize = GVs.size();
ReduceCrashingGlobalVariables(BD, TestFn).reduceList(GVs, Error);
- if (!Error.empty())
- return true;
+ assert(!Error.empty());
if (GVs.size() < OldSize)
BD.EmitProgressBitcode(BD.getProgram(), "reduced-global-variables");
@@ -708,40 +701,11 @@ static bool DebugACrash(BugDriver &BD,
}
}
}
+}
- // Now try to reduce the number of functions in the module to something small.
- std::vector<Function*> Functions;
- for (Function &F : *BD.getProgram())
- if (!F.isDeclaration())
- Functions.push_back(&F);
-
- if (Functions.size() > 1 && !BugpointIsInterrupted) {
- outs() << "\n*** Attempting to reduce the number of functions "
- "in the testcase\n";
-
- unsigned OldSize = Functions.size();
- ReduceCrashingFunctions(BD, TestFn).reduceList(Functions, Error);
-
- if (Functions.size() < OldSize)
- BD.EmitProgressBitcode(BD.getProgram(), "reduced-function");
- }
-
- // Attempt to delete entire basic blocks at a time to speed up
- // convergence... this actually works by setting the terminator of the blocks
- // to a return instruction then running simplifycfg, which can potentially
- // shrinks the code dramatically quickly
- //
- if (!DisableSimplifyCFG && !BugpointIsInterrupted) {
- std::vector<const BasicBlock*> Blocks;
- for (Function &F : *BD.getProgram())
- for (BasicBlock &BB : F)
- Blocks.push_back(&BB);
- unsigned OldSize = Blocks.size();
- ReduceCrashingBlocks(BD, TestFn).reduceList(Blocks, Error);
- if (Blocks.size() < OldSize)
- BD.EmitProgressBitcode(BD.getProgram(), "reduced-blocks");
- }
-
+static void ReduceInsts(BugDriver &BD,
+ bool (*TestFn)(const BugDriver &, Module *),
+ std::string &Error) {
// 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) {
@@ -755,11 +719,10 @@ static bool DebugACrash(BugDriver &BD,
ReduceCrashingInstructions(BD, TestFn).reduceList(Insts, Error);
}
- // FIXME: This should use the list reducer to converge faster by deleting
- // larger chunks of instructions at a time!
unsigned Simplification = 2;
do {
- if (BugpointIsInterrupted) break;
+ if (BugpointIsInterrupted)
+ return;
--Simplification;
outs() << "\n*** Attempting to reduce testcase by deleting instruc"
<< "tions: Simplification Level #" << Simplification << '\n';
@@ -788,7 +751,8 @@ static bool DebugACrash(BugDriver &BD,
if (InstructionsToSkipBeforeDeleting) {
--InstructionsToSkipBeforeDeleting;
} else {
- if (BugpointIsInterrupted) goto ExitLoops;
+ if (BugpointIsInterrupted)
+ return;
if (I->isEHPad() || I->getType()->isTokenTy())
continue;
@@ -815,6 +779,57 @@ static bool DebugACrash(BugDriver &BD,
} while (Simplification);
BD.EmitProgressBitcode(BD.getProgram(), "reduced-instructions");
+}
+
+
+/// DebugACrash - Given a predicate that determines whether a component crashes
+/// 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) {
+ // See if we can get away with nuking some of the global variable initializers
+ // in the program...
+ if (!NoGlobalRM)
+ ReduceGlobalInitializers(BD, TestFn, Error);
+
+ // Now try to reduce the number of functions in the module to something small.
+ std::vector<Function*> Functions;
+ for (Function &F : *BD.getProgram())
+ if (!F.isDeclaration())
+ Functions.push_back(&F);
+
+ if (Functions.size() > 1 && !BugpointIsInterrupted) {
+ outs() << "\n*** Attempting to reduce the number of functions "
+ "in the testcase\n";
+
+ unsigned OldSize = Functions.size();
+ ReduceCrashingFunctions(BD, TestFn).reduceList(Functions, Error);
+
+ if (Functions.size() < OldSize)
+ BD.EmitProgressBitcode(BD.getProgram(), "reduced-function");
+ }
+
+ // Attempt to delete entire basic blocks at a time to speed up
+ // convergence... this actually works by setting the terminator of the blocks
+ // to a return instruction then running simplifycfg, which can potentially
+ // shrinks the code dramatically quickly
+ //
+ if (!DisableSimplifyCFG && !BugpointIsInterrupted) {
+ std::vector<const BasicBlock*> Blocks;
+ for (Function &F : *BD.getProgram())
+ for (BasicBlock &BB : F)
+ Blocks.push_back(&BB);
+ unsigned OldSize = Blocks.size();
+ ReduceCrashingBlocks(BD, TestFn).reduceList(Blocks, Error);
+ if (Blocks.size() < OldSize)
+ BD.EmitProgressBitcode(BD.getProgram(), "reduced-blocks");
+ }
+
+ // 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);
if (!NoNamedMDRM) {
if (!BugpointIsInterrupted) {
@@ -839,8 +854,6 @@ static bool DebugACrash(BugDriver &BD,
BD.EmitProgressBitcode(BD.getProgram(), "reduced-named-md");
}
-ExitLoops:
-
// Try to clean up the testcase by running funcresolve and globaldce...
if (!BugpointIsInterrupted) {
outs() << "\n*** Attempting to perform final cleanups: ";
OpenPOWER on IntegriCloud