mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-14 17:34:41 +00:00
* Reduce the number of useless bytecode files produced by bugpoint.
- This also speeds it up as the bytecode writer isn't terribly fast. * Add a new cleanup pass after everything else to run -funcresolve -globaldce git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5668 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
74cd04ea01
commit
ba386d943f
@ -125,6 +125,12 @@ private:
|
|||||||
///
|
///
|
||||||
Module *deleteInstructionFromProgram(Instruction *I, unsigned Simp) const;
|
Module *deleteInstructionFromProgram(Instruction *I, unsigned Simp) const;
|
||||||
|
|
||||||
|
/// performFinalCleanups - This method clones the current Program and performs
|
||||||
|
/// a series of cleanups intended to get rid of extra cruft on the module
|
||||||
|
/// before handing it to the user...
|
||||||
|
///
|
||||||
|
Module *performFinalCleanups() const;
|
||||||
|
|
||||||
/// initializeExecutionEnvironment - This method is used to set up the
|
/// initializeExecutionEnvironment - This method is used to set up the
|
||||||
/// environment for executing LLVM programs.
|
/// environment for executing LLVM programs.
|
||||||
///
|
///
|
||||||
|
@ -84,6 +84,7 @@ static unsigned CountFunctions(Module *M) {
|
|||||||
///
|
///
|
||||||
bool BugDriver::debugPassCrash(const PassInfo *Pass) {
|
bool BugDriver::debugPassCrash(const PassInfo *Pass) {
|
||||||
EmitProgressBytecode(Pass, "passinput");
|
EmitProgressBytecode(Pass, "passinput");
|
||||||
|
bool Reduced = false, AnyReduction = false;
|
||||||
|
|
||||||
if (CountFunctions(Program) > 1) {
|
if (CountFunctions(Program) > 1) {
|
||||||
// Attempt to reduce the input program down to a single function that still
|
// Attempt to reduce the input program down to a single function that still
|
||||||
@ -106,7 +107,7 @@ bool BugDriver::debugPassCrash(const PassInfo *Pass) {
|
|||||||
// reduce the testcase...
|
// reduce the testcase...
|
||||||
delete M;
|
delete M;
|
||||||
|
|
||||||
EmitProgressBytecode(Pass, "reduced-"+I->getName());
|
Reduced = AnyReduction = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +123,11 @@ bool BugDriver::debugPassCrash(const PassInfo *Pass) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Reduced) {
|
||||||
|
EmitProgressBytecode(Pass, "reduced-function");
|
||||||
|
Reduced = false;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: This should attempt to delete entire basic blocks at a time to speed
|
// FIXME: This should attempt to delete entire basic blocks at a time to speed
|
||||||
// up convergence...
|
// up convergence...
|
||||||
|
|
||||||
@ -159,8 +165,8 @@ bool BugDriver::debugPassCrash(const PassInfo *Pass) {
|
|||||||
if (runPass(Pass)) {
|
if (runPass(Pass)) {
|
||||||
// Yup, it does, we delete the old module, and continue trying to
|
// Yup, it does, we delete the old module, and continue trying to
|
||||||
// reduce the testcase...
|
// reduce the testcase...
|
||||||
EmitProgressBytecode(Pass, "reduced-" + I->getName());
|
|
||||||
delete M;
|
delete M;
|
||||||
|
Reduced = AnyReduction = true;
|
||||||
goto TryAgain; // I wish I had a multi-level break here!
|
goto TryAgain; // I wish I had a multi-level break here!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,6 +177,28 @@ bool BugDriver::debugPassCrash(const PassInfo *Pass) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (Simplification);
|
} while (Simplification);
|
||||||
|
|
||||||
|
// Try to clean up the testcase by running funcresolve and globaldce...
|
||||||
|
if (AnyReduction) {
|
||||||
|
std::cout << "\n*** Attempting to perform final cleanups: ";
|
||||||
|
Module *M = performFinalCleanups();
|
||||||
|
std::swap(Program, M);
|
||||||
|
|
||||||
|
// Find out if the pass still crashes on the cleaned up program...
|
||||||
|
if (runPass(Pass)) {
|
||||||
|
// Yup, it does, keep the reduced version...
|
||||||
|
delete M;
|
||||||
|
Reduced = AnyReduction = true;
|
||||||
|
} else {
|
||||||
|
delete Program; // Otherwise, restore the original module...
|
||||||
|
Program = M;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Reduced) {
|
||||||
|
EmitProgressBytecode(Pass, "reduced-simplified");
|
||||||
|
Reduced = false;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -81,3 +81,16 @@ Module *BugDriver::deleteInstructionFromProgram(Instruction *I,
|
|||||||
Passes.run(*Result);
|
Passes.run(*Result);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// performFinalCleanups - This method clones the current Program and performs
|
||||||
|
/// a series of cleanups intended to get rid of extra cruft on the module
|
||||||
|
/// before handing it to the user...
|
||||||
|
///
|
||||||
|
Module *BugDriver::performFinalCleanups() const {
|
||||||
|
PassManager CleanupPasses;
|
||||||
|
CleanupPasses.add(createFunctionResolvingPass());
|
||||||
|
CleanupPasses.add(createGlobalDCEPass());
|
||||||
|
Module *M = CloneModule(Program);
|
||||||
|
CleanupPasses.run(*M);
|
||||||
|
return M;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user