mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
Implement support for bugpoint to identify which FUNCTION an optimization
is miscompiling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5893 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -11,6 +11,23 @@
|
||||
#include "llvm/Pass.h"
|
||||
#include <fstream>
|
||||
|
||||
#if 0
|
||||
class DebugCrashes : public ListReducer<const PassInfo*> {
|
||||
BugDriver &BD;
|
||||
public:
|
||||
DebugCrashes(BugDriver &bd) : BD(bd) {}
|
||||
|
||||
// doTest - Return true iff running the "removed" passes succeeds, and running
|
||||
// the "Kept" passes fail when run on the output of the "removed" passes. If
|
||||
// we return true, we update the current module of bugpoint.
|
||||
//
|
||||
virtual bool doTest(const std::vector<ElTy> &Removed,
|
||||
const std::vector<ElTy> &Kept) {
|
||||
return BD.runPasses(Kept);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/// debugCrash - This method is called when some pass crashes on input. It
|
||||
/// attempts to prune down the testcase to something reasonable, and figure
|
||||
/// out exactly which pass is crashing.
|
||||
@ -18,7 +35,11 @@
|
||||
bool BugDriver::debugCrash() {
|
||||
std::cout << "\n*** Debugging optimizer crash!\n";
|
||||
|
||||
// Determine which pass causes the optimizer to crash... using binary search
|
||||
#if 0
|
||||
// Reduce the list of passes which causes the optimizer to crash...
|
||||
DebugCrashes(*this).reduceList(PassesToRun);
|
||||
#endif
|
||||
|
||||
unsigned LastToPass = 0, LastToCrash = PassesToRun.size();
|
||||
while (LastToPass != LastToCrash) {
|
||||
unsigned Mid = (LastToCrash+LastToPass+1) / 2;
|
||||
@ -65,6 +86,9 @@ bool BugDriver::debugCrash() {
|
||||
removeFile(Filename);
|
||||
}
|
||||
|
||||
PassesToRun.clear();
|
||||
PassesToRun.push_back(CrashingPass);
|
||||
|
||||
return debugPassCrash(CrashingPass);
|
||||
}
|
||||
|
||||
@ -83,7 +107,7 @@ static unsigned CountFunctions(Module *M) {
|
||||
/// crashes, but it smaller.
|
||||
///
|
||||
bool BugDriver::debugPassCrash(const PassInfo *Pass) {
|
||||
EmitProgressBytecode(Pass, "passinput");
|
||||
EmitProgressBytecode("passinput");
|
||||
bool Reduced = false, AnyReduction = false;
|
||||
|
||||
if (CountFunctions(Program) > 1) {
|
||||
@ -124,7 +148,7 @@ bool BugDriver::debugPassCrash(const PassInfo *Pass) {
|
||||
}
|
||||
|
||||
if (Reduced) {
|
||||
EmitProgressBytecode(Pass, "reduced-function");
|
||||
EmitProgressBytecode("reduced-function");
|
||||
Reduced = false;
|
||||
}
|
||||
|
||||
@ -196,7 +220,7 @@ bool BugDriver::debugPassCrash(const PassInfo *Pass) {
|
||||
}
|
||||
|
||||
if (Reduced) {
|
||||
EmitProgressBytecode(Pass, "reduced-simplified");
|
||||
EmitProgressBytecode("reduced-simplified");
|
||||
Reduced = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user