diff options
author | Gabor Greif <ggreif@gmail.com> | 2010-07-09 15:53:42 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2010-07-09 15:53:42 +0000 |
commit | d7cc5215f131a4df933c750595d7c642df3ee5b8 (patch) | |
tree | b7e6d199dcc2f4d7c8b7078f8359f4fcf93086fe /lib/Analysis/IPA/GlobalsModRef.cpp | |
parent | 1f2c0c9eaddc745fa18e3878151e3cded6fcf82f (diff) | |
download | external_llvm-d7cc5215f131a4df933c750595d7c642df3ee5b8.zip external_llvm-d7cc5215f131a4df933c750595d7c642df3ee5b8.tar.gz external_llvm-d7cc5215f131a4df933c750595d7c642df3ee5b8.tar.bz2 |
cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107978 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/IPA/GlobalsModRef.cpp')
-rw-r--r-- | lib/Analysis/IPA/GlobalsModRef.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index fa5edfc..7ff8a58 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -233,33 +233,34 @@ bool GlobalsModRef::AnalyzeUsesOfPointer(Value *V, GlobalValue *OkayStoreDest) { if (!V->getType()->isPointerTy()) return true; - for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI) - if (LoadInst *LI = dyn_cast<LoadInst>(*UI)) { + for (Value::use_iterator UI = V->use_begin(), E=V->use_end(); UI != E; ++UI) { + User *U = *UI; + if (LoadInst *LI = dyn_cast<LoadInst>(U)) { Readers.push_back(LI->getParent()->getParent()); - } else if (StoreInst *SI = dyn_cast<StoreInst>(*UI)) { + } else if (StoreInst *SI = dyn_cast<StoreInst>(U)) { if (V == SI->getOperand(1)) { Writers.push_back(SI->getParent()->getParent()); } else if (SI->getOperand(1) != OkayStoreDest) { return true; // Storing the pointer } - } else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(*UI)) { + } else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(U)) { if (AnalyzeUsesOfPointer(GEP, Readers, Writers)) return true; - } else if (BitCastInst *BCI = dyn_cast<BitCastInst>(*UI)) { + } else if (BitCastInst *BCI = dyn_cast<BitCastInst>(U)) { if (AnalyzeUsesOfPointer(BCI, Readers, Writers, OkayStoreDest)) return true; - } else if (isFreeCall(*UI)) { - Writers.push_back(cast<Instruction>(*UI)->getParent()->getParent()); - } else if (CallInst *CI = dyn_cast<CallInst>(*UI)) { + } else if (isFreeCall(U)) { + Writers.push_back(cast<Instruction>(U)->getParent()->getParent()); + } else if (CallInst *CI = dyn_cast<CallInst>(U)) { // Make sure that this is just the function being called, not that it is // passing into the function. for (unsigned i = 0, e = CI->getNumArgOperands(); i != e; ++i) if (CI->getArgOperand(i) == V) return true; - } else if (InvokeInst *II = dyn_cast<InvokeInst>(*UI)) { + } else if (InvokeInst *II = dyn_cast<InvokeInst>(U)) { // Make sure that this is just the function being called, not that it is // passing into the function. for (unsigned i = 0, e = II->getNumArgOperands(); i != e; ++i) if (II->getArgOperand(i) == V) return true; - } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(*UI)) { + } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(U)) { if (CE->getOpcode() == Instruction::GetElementPtr || CE->getOpcode() == Instruction::BitCast) { if (AnalyzeUsesOfPointer(CE, Readers, Writers)) @@ -267,12 +268,14 @@ bool GlobalsModRef::AnalyzeUsesOfPointer(Value *V, } else { return true; } - } else if (ICmpInst *ICI = dyn_cast<ICmpInst>(*UI)) { + } else if (ICmpInst *ICI = dyn_cast<ICmpInst>(U)) { if (!isa<ConstantPointerNull>(ICI->getOperand(1))) return true; // Allow comparison against null. } else { return true; } + } + return false; } |