forked from OSchip/llvm-project
several multiple-retval fixes for bugpoint.
llvm-svn: 50331
This commit is contained in:
parent
d04b818a91
commit
7855a5cb70
|
@ -14,7 +14,7 @@
|
||||||
#include "BugDriver.h"
|
#include "BugDriver.h"
|
||||||
#include "ToolRunner.h"
|
#include "ToolRunner.h"
|
||||||
#include "ListReducer.h"
|
#include "ListReducer.h"
|
||||||
#include "llvm/Constant.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
|
@ -300,17 +300,16 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
|
||||||
for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI)
|
for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI)
|
||||||
(*SI)->removePredecessor(BB);
|
(*SI)->removePredecessor(BB);
|
||||||
|
|
||||||
if (BB->getTerminator()->getType() != Type::VoidTy)
|
TerminatorInst *BBTerm = BB->getTerminator();
|
||||||
BB->getTerminator()->replaceAllUsesWith(
|
|
||||||
Constant::getNullValue(BB->getTerminator()->getType()));
|
|
||||||
|
|
||||||
// Delete the old terminator instruction...
|
if (isa<StructType>(BBTerm->getType()))
|
||||||
|
BBTerm->replaceAllUsesWith(UndefValue::get(BBTerm->getType()));
|
||||||
|
else if (BB->getTerminator()->getType() != Type::VoidTy)
|
||||||
|
BBTerm->replaceAllUsesWith(Constant::getNullValue(BBTerm->getType()));
|
||||||
|
|
||||||
|
// Replace the old terminator instruction.
|
||||||
BB->getInstList().pop_back();
|
BB->getInstList().pop_back();
|
||||||
|
new UnreachableInst(BB);
|
||||||
// Add a new return instruction of the appropriate type...
|
|
||||||
const Type *RetTy = BB->getParent()->getReturnType();
|
|
||||||
ReturnInst::Create(RetTy == Type::VoidTy ? 0 :
|
|
||||||
Constant::getNullValue(RetTy), BB);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The CFG Simplifier pass may delete one of the basic blocks we are
|
// The CFG Simplifier pass may delete one of the basic blocks we are
|
||||||
|
|
|
@ -71,7 +71,9 @@ Module *BugDriver::deleteInstructionFromProgram(const Instruction *I,
|
||||||
Instruction *TheInst = 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 (TheInst->getType() != Type::VoidTy)
|
if (isa<StructType>(TheInst->getType()))
|
||||||
|
TheInst->replaceAllUsesWith(UndefValue::get(TheInst->getType()));
|
||||||
|
else if (TheInst->getType() != Type::VoidTy)
|
||||||
TheInst->replaceAllUsesWith(Constant::getNullValue(TheInst->getType()));
|
TheInst->replaceAllUsesWith(Constant::getNullValue(TheInst->getType()));
|
||||||
|
|
||||||
// Remove the instruction from the program.
|
// Remove the instruction from the program.
|
||||||
|
|
Loading…
Reference in New Issue