From d7cc5215f131a4df933c750595d7c642df3ee5b8 Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Fri, 9 Jul 2010 15:53:42 +0000 Subject: [PATCH] cache result of operator* git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107978 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/IPA/GlobalsModRef.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index fa5edfcc133..7ff8a58de15 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(*UI)) { + for (Value::use_iterator UI = V->use_begin(), E=V->use_end(); UI != E; ++UI) { + User *U = *UI; + if (LoadInst *LI = dyn_cast(U)) { Readers.push_back(LI->getParent()->getParent()); - } else if (StoreInst *SI = dyn_cast(*UI)) { + } else if (StoreInst *SI = dyn_cast(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(*UI)) { + } else if (GetElementPtrInst *GEP = dyn_cast(U)) { if (AnalyzeUsesOfPointer(GEP, Readers, Writers)) return true; - } else if (BitCastInst *BCI = dyn_cast(*UI)) { + } else if (BitCastInst *BCI = dyn_cast(U)) { if (AnalyzeUsesOfPointer(BCI, Readers, Writers, OkayStoreDest)) return true; - } else if (isFreeCall(*UI)) { - Writers.push_back(cast(*UI)->getParent()->getParent()); - } else if (CallInst *CI = dyn_cast(*UI)) { + } else if (isFreeCall(U)) { + Writers.push_back(cast(U)->getParent()->getParent()); + } else if (CallInst *CI = dyn_cast(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(*UI)) { + } else if (InvokeInst *II = dyn_cast(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(*UI)) { + } else if (ConstantExpr *CE = dyn_cast(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(*UI)) { + } else if (ICmpInst *ICI = dyn_cast(U)) { if (!isa(ICI->getOperand(1))) return true; // Allow comparison against null. } else { return true; } + } + return false; } -- 2.34.1