X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FLoadValueNumbering.cpp;h=2414d33863dd1d303c5cf28fb6bed3f2d64b2bff;hb=51cd9d6e073932fcb37f1857c66249d6c7d368ee;hp=f1ade951f34b79e5f9e93dd276a340ef9a12a357;hpb=6ea7ac6a1e36f4ea44c77e5d008b0f4d2379c529;p=oota-llvm.git diff --git a/lib/Analysis/LoadValueNumbering.cpp b/lib/Analysis/LoadValueNumbering.cpp index f1ade951f34..2414d33863d 100644 --- a/lib/Analysis/LoadValueNumbering.cpp +++ b/lib/Analysis/LoadValueNumbering.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -82,14 +82,15 @@ namespace { void getCallEqualNumberNodes(CallInst *CI, std::vector &RetVals) const; }; +} - char LoadVN::ID = 0; - // Register this pass... - RegisterPass X("load-vn", "Load Value Numbering"); +char LoadVN::ID = 0; +// Register this pass... +static RegisterPass +X("load-vn", "Load Value Numbering", false, true); - // Declare that we implement the ValueNumbering interface - RegisterAnalysisGroup Y(X); -} +// Declare that we implement the ValueNumbering interface +static RegisterAnalysisGroup Y(X); FunctionPass *llvm::createLoadValueNumberingPass() { return new LoadVN(); } @@ -148,7 +149,7 @@ void LoadVN::getCallEqualNumberNodes(CallInst *CI, Function *CF = CI->getCalledFunction(); if (CF == 0) return; // Indirect call. AliasAnalysis &AA = getAnalysis(); - AliasAnalysis::ModRefBehavior MRB = AA.getModRefBehavior(CF, CI); + AliasAnalysis::ModRefBehavior MRB = AA.getModRefBehavior(CI); if (MRB != AliasAnalysis::DoesNotAccessMemory && MRB != AliasAnalysis::OnlyReadsMemory) return; // Nothing we can do for now. @@ -157,10 +158,10 @@ void LoadVN::getCallEqualNumberNodes(CallInst *CI, // global. In particular, we would prefer to have an argument or instruction // operand to chase the def-use chains of. Value *Op = CF; - for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i) - if (isa(CI->getOperand(i)) || - isa(CI->getOperand(i))) { - Op = CI->getOperand(i); + for (User::op_iterator i = CI->op_begin() + 1, e = CI->op_end(); i != e; ++i) + if (isa(*i) || + isa(*i)) { + Op = *i; break; } @@ -175,8 +176,9 @@ void LoadVN::getCallEqualNumberNodes(CallInst *CI, C->getOperand(0) == CI->getOperand(0) && C->getParent()->getParent() == CIFunc && C != CI) { bool AllOperandsEqual = true; - for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i) - if (C->getOperand(i) != CI->getOperand(i)) { + for (User::op_iterator i = CI->op_begin() + 1, j = C->op_begin() + 1, + e = CI->op_end(); i != e; ++i, ++j) + if (*j != *i) { AllOperandsEqual = false; break; } @@ -227,8 +229,7 @@ void LoadVN::getCallEqualNumberNodes(CallInst *CI, CantEqual = true; break; } else if (CallInst *CI = dyn_cast(I)) { - if (CI->getCalledFunction() == 0 || - !AA.onlyReadsMemory(CI->getCalledFunction())) { + if (!AA.onlyReadsMemory(CI)) { CantEqual = true; break; } @@ -293,7 +294,7 @@ void LoadVN::getEqualNumberNodes(Value *V, Function *F = LoadBB->getParent(); // Find out how many bytes of memory are loaded by the load instruction... - unsigned LoadSize = getAnalysis().getTypeSize(LI->getType()); + unsigned LoadSize = getAnalysis().getTypeStoreSize(LI->getType()); AliasAnalysis &AA = getAnalysis(); // Figure out if the load is invalidated from the entry of the block it is in