forked from OSchip/llvm-project
remove some extraneous llvmcontext stuff.
llvm-svn: 85774
This commit is contained in:
parent
efdd2bbce6
commit
6df5cec72f
|
@ -23,7 +23,6 @@
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/LLVMContext.h"
|
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Analysis/ConstantFolding.h"
|
#include "llvm/Analysis/ConstantFolding.h"
|
||||||
#include "llvm/Analysis/MemoryBuiltins.h"
|
#include "llvm/Analysis/MemoryBuiltins.h"
|
||||||
|
@ -144,7 +143,6 @@ public:
|
||||||
/// Constant Propagation.
|
/// Constant Propagation.
|
||||||
///
|
///
|
||||||
class SCCPSolver : public InstVisitor<SCCPSolver> {
|
class SCCPSolver : public InstVisitor<SCCPSolver> {
|
||||||
LLVMContext *Context;
|
|
||||||
DenseSet<BasicBlock*> BBExecutable;// The basic blocks that are executable
|
DenseSet<BasicBlock*> BBExecutable;// The basic blocks that are executable
|
||||||
std::map<Value*, LatticeVal> ValueState; // The state each value is in.
|
std::map<Value*, LatticeVal> ValueState; // The state each value is in.
|
||||||
|
|
||||||
|
@ -184,7 +182,6 @@ class SCCPSolver : public InstVisitor<SCCPSolver> {
|
||||||
typedef std::pair<BasicBlock*, BasicBlock*> Edge;
|
typedef std::pair<BasicBlock*, BasicBlock*> Edge;
|
||||||
DenseSet<Edge> KnownFeasibleEdges;
|
DenseSet<Edge> KnownFeasibleEdges;
|
||||||
public:
|
public:
|
||||||
void setContext(LLVMContext *C) { Context = C; }
|
|
||||||
|
|
||||||
/// MarkBlockExecutable - This method can be used by clients to mark all of
|
/// MarkBlockExecutable - This method can be used by clients to mark all of
|
||||||
/// the blocks that are known to be intrinsically live in the processed unit.
|
/// the blocks that are known to be intrinsically live in the processed unit.
|
||||||
|
@ -439,18 +436,20 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI,
|
||||||
if (BranchInst *BI = dyn_cast<BranchInst>(&TI)) {
|
if (BranchInst *BI = dyn_cast<BranchInst>(&TI)) {
|
||||||
if (BI->isUnconditional()) {
|
if (BI->isUnconditional()) {
|
||||||
Succs[0] = true;
|
Succs[0] = true;
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LatticeVal &BCValue = getValueState(BI->getCondition());
|
LatticeVal &BCValue = getValueState(BI->getCondition());
|
||||||
if (BCValue.isOverdefined() ||
|
if (BCValue.isOverdefined() ||
|
||||||
(BCValue.isConstant() && !isa<ConstantInt>(BCValue.getConstant()))) {
|
(BCValue.isConstant() && !isa<ConstantInt>(BCValue.getConstant()))) {
|
||||||
// Overdefined condition variables, and branches on unfoldable constant
|
// Overdefined condition variables, and branches on unfoldable constant
|
||||||
// conditions, mean the branch could go either way.
|
// conditions, mean the branch could go either way.
|
||||||
Succs[0] = Succs[1] = true;
|
Succs[0] = Succs[1] = true;
|
||||||
} else if (BCValue.isConstant()) {
|
return;
|
||||||
// Constant condition variables mean the branch can only go a single way
|
|
||||||
Succs[BCValue.getConstant() == ConstantInt::getFalse(*Context)] = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Constant condition variables mean the branch can only go a single way.
|
||||||
|
Succs[cast<ConstantInt>(BCValue.getConstant())->isZero()] = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,18 +500,18 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
LatticeVal &BCValue = getValueState(BI->getCondition());
|
LatticeVal &BCValue = getValueState(BI->getCondition());
|
||||||
if (BCValue.isOverdefined()) {
|
|
||||||
// Overdefined condition variables mean the branch could go either way.
|
// Overdefined condition variables mean the branch could go either way,
|
||||||
return true;
|
// undef conditions mean that neither edge is feasible yet.
|
||||||
} else if (BCValue.isConstant()) {
|
if (!BCValue.isConstant())
|
||||||
|
return BCValue.isOverdefined();
|
||||||
|
|
||||||
// Not branching on an evaluatable constant?
|
// Not branching on an evaluatable constant?
|
||||||
if (!isa<ConstantInt>(BCValue.getConstant())) return true;
|
if (!isa<ConstantInt>(BCValue.getConstant())) return true;
|
||||||
|
|
||||||
// Constant condition variables mean the branch can only go a single way
|
// Constant condition variables mean the branch can only go a single way.
|
||||||
return BI->getSuccessor(BCValue.getConstant() ==
|
bool CondIsFalse = cast<ConstantInt>(BCValue.getConstant())->isZero();
|
||||||
ConstantInt::getFalse(*Context)) == To;
|
return BI->getSuccessor(CondIsFalse) == To;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke instructions successors are always executable.
|
// Invoke instructions successors are always executable.
|
||||||
|
@ -1522,7 +1521,7 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) {
|
||||||
// as undef, then further analysis could think the undef went another way
|
// as undef, then further analysis could think the undef went another way
|
||||||
// leading to an inconsistent set of conclusions.
|
// leading to an inconsistent set of conclusions.
|
||||||
if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
|
if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
|
||||||
BI->setCondition(ConstantInt::getFalse(*Context));
|
BI->setCondition(ConstantInt::getFalse(BI->getContext()));
|
||||||
} else {
|
} else {
|
||||||
SwitchInst *SI = cast<SwitchInst>(TI);
|
SwitchInst *SI = cast<SwitchInst>(TI);
|
||||||
SI->setCondition(SI->getCaseValue(1));
|
SI->setCondition(SI->getCaseValue(1));
|
||||||
|
@ -1572,7 +1571,6 @@ FunctionPass *llvm::createSCCPPass() {
|
||||||
bool SCCP::runOnFunction(Function &F) {
|
bool SCCP::runOnFunction(Function &F) {
|
||||||
DEBUG(errs() << "SCCP on function '" << F.getName() << "'\n");
|
DEBUG(errs() << "SCCP on function '" << F.getName() << "'\n");
|
||||||
SCCPSolver Solver;
|
SCCPSolver Solver;
|
||||||
Solver.setContext(&F.getContext());
|
|
||||||
|
|
||||||
// Mark the first block of the function as being executable.
|
// Mark the first block of the function as being executable.
|
||||||
Solver.MarkBlockExecutable(F.begin());
|
Solver.MarkBlockExecutable(F.begin());
|
||||||
|
@ -1698,10 +1696,7 @@ static bool AddressIsTaken(GlobalValue *GV) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IPSCCP::runOnModule(Module &M) {
|
bool IPSCCP::runOnModule(Module &M) {
|
||||||
LLVMContext *Context = &M.getContext();
|
|
||||||
|
|
||||||
SCCPSolver Solver;
|
SCCPSolver Solver;
|
||||||
Solver.setContext(Context);
|
|
||||||
|
|
||||||
// Loop over all functions, marking arguments to those with their addresses
|
// Loop over all functions, marking arguments to those with their addresses
|
||||||
// taken or that are external as overdefined.
|
// taken or that are external as overdefined.
|
||||||
|
|
Loading…
Reference in New Issue