diff options
author | Justin Bogner <mail@justinbogner.com> | 2016-09-06 04:04:13 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2016-09-06 04:04:13 +0000 |
commit | 46b1a9a70c171c44eb2fe0948f9b6f1be2387aa3 (patch) | |
tree | b05f5a80e5937bf80d7ebf319fb9256620e12ba1 /llvm/tools/bugpoint/ListReducer.h | |
parent | bfa25bd1aca993e36222aec4b400bdeff37355ec (diff) | |
download | bcm5719-llvm-46b1a9a70c171c44eb2fe0948f9b6f1be2387aa3.tar.gz bcm5719-llvm-46b1a9a70c171c44eb2fe0948f9b6f1be2387aa3.zip |
bugpoint: Stop threading errors through APIs that never fail
This simplifies ListReducer and most of its subclasses by removing the
std::string &Error that was threaded through all of them but almost
never used. If we end up needing error handling in more places here we
can reinstate it using llvm::Error instead of these unwieldy strings.
The 2 cases (out of 12) that actually can hit the error cases are a
little bit awkward now, but those will clean up as I refactor this API
further.
llvm-svn: 280690
Diffstat (limited to 'llvm/tools/bugpoint/ListReducer.h')
-rw-r--r-- | llvm/tools/bugpoint/ListReducer.h | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/llvm/tools/bugpoint/ListReducer.h b/llvm/tools/bugpoint/ListReducer.h index 78af1aeb6a2..94e63e34200 100644 --- a/llvm/tools/bugpoint/ListReducer.h +++ b/llvm/tools/bugpoint/ListReducer.h @@ -15,7 +15,6 @@ #ifndef LLVM_TOOLS_BUGPOINT_LISTREDUCER_H #define LLVM_TOOLS_BUGPOINT_LISTREDUCER_H -#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> #include <cstdlib> @@ -39,16 +38,16 @@ template <typename ElTy> struct ListReducer { /// test desired. The testcase is only required to test to see if the Kept /// list still satisfies the property, but if it is going to check the prefix /// anyway, it can. - virtual TestResult doTest(std::vector<ElTy> &Prefix, std::vector<ElTy> &Kept, - std::string &Error) = 0; + virtual TestResult doTest(std::vector<ElTy> &Prefix, + std::vector<ElTy> &Kept) = 0; /// This function attempts to reduce the length of the specified list while /// still maintaining the "test" property. This is the core of the "work" /// that bugpoint does. - bool reduceList(std::vector<ElTy> &TheList, std::string &Error) { + bool reduceList(std::vector<ElTy> &TheList) { std::vector<ElTy> empty; std::srand(0x6e5ea738); // Seed the random number generator - switch (doTest(TheList, empty, Error)) { + switch (doTest(TheList, empty)) { case KeepPrefix: if (TheList.size() == 1) // we are done, it's the base case and it fails return true; @@ -64,7 +63,6 @@ template <typename ElTy> struct ListReducer { return false; // there is no failure with the full set of passes/funcs! case InternalError: - assert(!Error.empty()); return true; } @@ -97,7 +95,7 @@ template <typename ElTy> struct ListReducer { std::random_shuffle(ShuffledList.begin(), ShuffledList.end()); errs() << "\n\n*** Testing shuffled set...\n\n"; // Check that random shuffle doesn't loose the bug - if (doTest(ShuffledList, empty, Error) == KeepPrefix) { + if (doTest(ShuffledList, empty) == KeepPrefix) { // If the bug is still here, use the shuffled list. TheList.swap(ShuffledList); MidTop = TheList.size(); @@ -116,7 +114,7 @@ template <typename ElTy> struct ListReducer { std::vector<ElTy> Prefix(TheList.begin(), TheList.begin() + Mid); std::vector<ElTy> Suffix(TheList.begin() + Mid, TheList.end()); - switch (doTest(Prefix, Suffix, Error)) { + switch (doTest(Prefix, Suffix)) { case KeepSuffix: // The property still holds. We can just drop the prefix elements, and // shorten the list to the "kept" elements. @@ -141,9 +139,8 @@ template <typename ElTy> struct ListReducer { NumOfIterationsWithoutProgress++; break; case InternalError: - return true; // Error was set by doTest. + return true; } - assert(Error.empty() && "doTest did not return InternalError for error"); } // Probability of backjumping from the trimming loop back to the binary @@ -179,14 +176,18 @@ template <typename ElTy> struct ListReducer { std::vector<ElTy> TestList(TheList); TestList.erase(TestList.begin() + i); - if (doTest(EmptyList, TestList, Error) == KeepSuffix) { + switch (doTest(EmptyList, TestList)) { + case KeepSuffix: // We can trim down the list! TheList.swap(TestList); --i; // Don't skip an element of the list Changed = true; - } - if (!Error.empty()) + break; + case InternalError: return true; + default: + break; + } } if (TrimIterations >= MaxTrimIterationsWithoutBackJump) break; |