From: Chris Lattner Date: Mon, 2 Nov 2009 02:30:06 +0000 (+0000) Subject: remove some extraneous llvmcontext stuff. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ea0db070a1862ede85719110b59f0bbb00dcf7f9;p=oota-llvm.git remove some extraneous llvmcontext stuff. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85774 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 0451cb32cae..ed4f7d0da87 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -23,7 +23,6 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" -#include "llvm/LLVMContext.h" #include "llvm/Pass.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/MemoryBuiltins.h" @@ -144,7 +143,6 @@ public: /// Constant Propagation. /// class SCCPSolver : public InstVisitor { - LLVMContext *Context; DenseSet BBExecutable;// The basic blocks that are executable std::map ValueState; // The state each value is in. @@ -184,7 +182,6 @@ class SCCPSolver : public InstVisitor { typedef std::pair Edge; DenseSet KnownFeasibleEdges; public: - void setContext(LLVMContext *C) { Context = C; } /// 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. @@ -439,18 +436,20 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI, if (BranchInst *BI = dyn_cast(&TI)) { if (BI->isUnconditional()) { Succs[0] = true; - } else { - LatticeVal &BCValue = getValueState(BI->getCondition()); - if (BCValue.isOverdefined() || - (BCValue.isConstant() && !isa(BCValue.getConstant()))) { - // Overdefined condition variables, and branches on unfoldable constant - // conditions, mean the branch could go either way. - Succs[0] = Succs[1] = true; - } else if (BCValue.isConstant()) { - // Constant condition variables mean the branch can only go a single way - Succs[BCValue.getConstant() == ConstantInt::getFalse(*Context)] = true; - } + return; + } + + LatticeVal &BCValue = getValueState(BI->getCondition()); + if (BCValue.isOverdefined() || + (BCValue.isConstant() && !isa(BCValue.getConstant()))) { + // Overdefined condition variables, and branches on unfoldable constant + // conditions, mean the branch could go either way. + Succs[0] = Succs[1] = true; + return; } + + // Constant condition variables mean the branch can only go a single way. + Succs[cast(BCValue.getConstant())->isZero()] = true; return; } @@ -501,18 +500,18 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) { return true; LatticeVal &BCValue = getValueState(BI->getCondition()); - if (BCValue.isOverdefined()) { - // Overdefined condition variables mean the branch could go either way. - return true; - } else if (BCValue.isConstant()) { - // Not branching on an evaluatable constant? - if (!isa(BCValue.getConstant())) return true; - // Constant condition variables mean the branch can only go a single way - return BI->getSuccessor(BCValue.getConstant() == - ConstantInt::getFalse(*Context)) == To; - } - return false; + // Overdefined condition variables mean the branch could go either way, + // undef conditions mean that neither edge is feasible yet. + if (!BCValue.isConstant()) + return BCValue.isOverdefined(); + + // Not branching on an evaluatable constant? + if (!isa(BCValue.getConstant())) return true; + + // Constant condition variables mean the branch can only go a single way. + bool CondIsFalse = cast(BCValue.getConstant())->isZero(); + return BI->getSuccessor(CondIsFalse) == To; } // Invoke instructions successors are always executable. @@ -1496,7 +1495,7 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) { if (!getValueState(BI->getCondition()).isUndefined()) continue; } else if (SwitchInst *SI = dyn_cast(TI)) { - if (SI->getNumSuccessors()<2) // no cases + if (SI->getNumSuccessors() < 2) // no cases continue; if (!getValueState(SI->getCondition()).isUndefined()) continue; @@ -1522,7 +1521,7 @@ bool SCCPSolver::ResolvedUndefsIn(Function &F) { // as undef, then further analysis could think the undef went another way // leading to an inconsistent set of conclusions. if (BranchInst *BI = dyn_cast(TI)) { - BI->setCondition(ConstantInt::getFalse(*Context)); + BI->setCondition(ConstantInt::getFalse(BI->getContext())); } else { SwitchInst *SI = cast(TI); SI->setCondition(SI->getCaseValue(1)); @@ -1572,7 +1571,6 @@ FunctionPass *llvm::createSCCPPass() { bool SCCP::runOnFunction(Function &F) { DEBUG(errs() << "SCCP on function '" << F.getName() << "'\n"); SCCPSolver Solver; - Solver.setContext(&F.getContext()); // Mark the first block of the function as being executable. Solver.MarkBlockExecutable(F.begin()); @@ -1698,10 +1696,7 @@ static bool AddressIsTaken(GlobalValue *GV) { } bool IPSCCP::runOnModule(Module &M) { - LLVMContext *Context = &M.getContext(); - SCCPSolver Solver; - Solver.setContext(Context); // Loop over all functions, marking arguments to those with their addresses // taken or that are external as overdefined.