Get rid of the Pass+Context magic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76702 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson
2009-07-22 00:24:57 +00:00
parent 7cf12c7efd
commit e922c02019
120 changed files with 835 additions and 786 deletions
+5 -5
View File
@@ -56,8 +56,6 @@ bool IPCP::runOnModule(Module &M) {
bool Changed = false;
bool LocalChange = true;
Context = &M.getContext();
// FIXME: instead of using smart algorithms, we just iterate until we stop
// making changes.
while (LocalChange) {
@@ -136,7 +134,7 @@ bool IPCP::PropagateConstantsIntoArguments(Function &F) {
continue;
Value *V = ArgumentConstants[i].first;
if (V == 0) V = Context->getUndef(AI->getType());
if (V == 0) V = F.getContext().getUndef(AI->getType());
AI->replaceAllUsesWith(V);
++NumArgumentsProped;
MadeChange = true;
@@ -161,15 +159,17 @@ bool IPCP::PropagateConstantReturn(Function &F) {
// propagate information about its results into callers.
if (F.mayBeOverridden())
return false;
LLVMContext &Context = F.getContext();
// Check to see if this function returns a constant.
SmallVector<Value *,4> RetVals;
const StructType *STy = dyn_cast<StructType>(F.getReturnType());
if (STy)
for (unsigned i = 0, e = STy->getNumElements(); i < e; ++i)
RetVals.push_back(Context->getUndef(STy->getElementType(i)));
RetVals.push_back(Context.getUndef(STy->getElementType(i)));
else
RetVals.push_back(Context->getUndef(F.getReturnType()));
RetVals.push_back(Context.getUndef(F.getReturnType()));
unsigned NumNonConstant = 0;
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)