mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Make more stuff public. Make the instruction argument to
deleteInstructionFromProgram be const llvm-svn: 11606
This commit is contained in:
parent
975c9272ef
commit
6e7c1e5c5c
@ -152,6 +152,26 @@ public:
|
|||||||
bool diffProgram(const std::string &BytecodeFile = "",
|
bool diffProgram(const std::string &BytecodeFile = "",
|
||||||
const std::string &SharedObj = "",
|
const std::string &SharedObj = "",
|
||||||
bool RemoveBytecode = false);
|
bool RemoveBytecode = false);
|
||||||
|
/// EmitProgressBytecode - This function is used to output the current Program
|
||||||
|
/// to a file named "bugpoint-ID.bc".
|
||||||
|
///
|
||||||
|
void EmitProgressBytecode(const std::string &ID, bool NoFlyer = false);
|
||||||
|
|
||||||
|
/// deleteInstructionFromProgram - This method clones the current Program and
|
||||||
|
/// deletes the specified instruction from the cloned module. It then runs a
|
||||||
|
/// series of cleanup passes (ADCE and SimplifyCFG) to eliminate any code
|
||||||
|
/// which depends on the value. The modified module is then returned.
|
||||||
|
///
|
||||||
|
Module *deleteInstructionFromProgram(const 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. If
|
||||||
|
/// the MayModifySemantics argument is true, then the cleanups is allowed to
|
||||||
|
/// modify how the code behaves.
|
||||||
|
///
|
||||||
|
Module *performFinalCleanups(Module *M, bool MayModifySemantics = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// ParseInputFile - Given a bytecode or assembly input filename, parse and
|
/// ParseInputFile - Given a bytecode or assembly input filename, parse and
|
||||||
/// return it, or return null if not possible.
|
/// return it, or return null if not possible.
|
||||||
@ -163,12 +183,6 @@ private:
|
|||||||
///
|
///
|
||||||
bool writeProgramToFile(const std::string &Filename, Module *M = 0) const;
|
bool writeProgramToFile(const std::string &Filename, Module *M = 0) const;
|
||||||
|
|
||||||
|
|
||||||
/// EmitProgressBytecode - This function is used to output the current Program
|
|
||||||
/// to a file named "bugpoint-ID.bc".
|
|
||||||
///
|
|
||||||
void EmitProgressBytecode(const std::string &ID, bool NoFlyer = false);
|
|
||||||
|
|
||||||
/// runPasses - Run the specified passes on Program, outputting a bytecode
|
/// runPasses - Run the specified passes on Program, outputting a bytecode
|
||||||
/// file and writting the filename into OutputFile if successful. If the
|
/// file and writting the filename into OutputFile if successful. If the
|
||||||
/// optimizations fail for some reason (optimizer crashes), return true,
|
/// optimizations fail for some reason (optimizer crashes), return true,
|
||||||
@ -195,20 +209,6 @@ private:
|
|||||||
///
|
///
|
||||||
static void PrintFunctionList(const std::vector<Function*> &Funcs);
|
static void PrintFunctionList(const std::vector<Function*> &Funcs);
|
||||||
|
|
||||||
/// deleteInstructionFromProgram - This method clones the current Program and
|
|
||||||
/// deletes the specified instruction from the cloned module. It then runs a
|
|
||||||
/// series of cleanup passes (ADCE and SimplifyCFG) to eliminate any code
|
|
||||||
/// which depends on the value. The modified module is then returned.
|
|
||||||
///
|
|
||||||
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. If
|
|
||||||
/// the MayModifySemantics argument is true, then the cleanups is allowed to
|
|
||||||
/// modify how the code behaves.
|
|
||||||
///
|
|
||||||
Module *performFinalCleanups(Module *M, bool MayModifySemantics = false);
|
|
||||||
|
|
||||||
/// 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.
|
||||||
///
|
///
|
||||||
|
@ -48,29 +48,30 @@ namespace {
|
|||||||
/// series of cleanup passes (ADCE and SimplifyCFG) to eliminate any code which
|
/// series of cleanup passes (ADCE and SimplifyCFG) to eliminate any code which
|
||||||
/// depends on the value. The modified module is then returned.
|
/// depends on the value. The modified module is then returned.
|
||||||
///
|
///
|
||||||
Module *BugDriver::deleteInstructionFromProgram(Instruction *I,
|
Module *BugDriver::deleteInstructionFromProgram(const Instruction *I,
|
||||||
unsigned Simplification) const {
|
unsigned Simplification) const {
|
||||||
Module *Result = CloneModule(Program);
|
Module *Result = CloneModule(Program);
|
||||||
|
|
||||||
BasicBlock *PBB = I->getParent();
|
const BasicBlock *PBB = I->getParent();
|
||||||
Function *PF = PBB->getParent();
|
const Function *PF = PBB->getParent();
|
||||||
|
|
||||||
Module::iterator RFI = Result->begin(); // Get iterator to corresponding fn
|
Module::iterator RFI = Result->begin(); // Get iterator to corresponding fn
|
||||||
std::advance(RFI, std::distance(Program->begin(), Module::iterator(PF)));
|
std::advance(RFI, std::distance(PF->getParent()->begin(),
|
||||||
|
Module::const_iterator(PF)));
|
||||||
|
|
||||||
Function::iterator RBI = RFI->begin(); // Get iterator to corresponding BB
|
Function::iterator RBI = RFI->begin(); // Get iterator to corresponding BB
|
||||||
std::advance(RBI, std::distance(PF->begin(), Function::iterator(PBB)));
|
std::advance(RBI, std::distance(PF->begin(), Function::const_iterator(PBB)));
|
||||||
|
|
||||||
BasicBlock::iterator RI = RBI->begin(); // Get iterator to corresponding inst
|
BasicBlock::iterator RI = RBI->begin(); // Get iterator to corresponding inst
|
||||||
std::advance(RI, std::distance(PBB->begin(), BasicBlock::iterator(I)));
|
std::advance(RI, std::distance(PBB->begin(), BasicBlock::const_iterator(I)));
|
||||||
I = RI; // Got the corresponding instruction!
|
Instruction *TheInst = RI; // Got the corresponding instruction!
|
||||||
|
|
||||||
// If this instruction produces a value, replace any users with null values
|
// If this instruction produces a value, replace any users with null values
|
||||||
if (I->getType() != Type::VoidTy)
|
if (TheInst->getType() != Type::VoidTy)
|
||||||
I->replaceAllUsesWith(Constant::getNullValue(I->getType()));
|
TheInst->replaceAllUsesWith(Constant::getNullValue(TheInst->getType()));
|
||||||
|
|
||||||
// Remove the instruction from the program.
|
// Remove the instruction from the program.
|
||||||
I->getParent()->getInstList().erase(I);
|
TheInst->getParent()->getInstList().erase(TheInst);
|
||||||
|
|
||||||
// Spiff up the output a little bit.
|
// Spiff up the output a little bit.
|
||||||
PassManager Passes;
|
PassManager Passes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user