From: Chris Lattner Date: Mon, 15 Dec 2008 21:20:32 +0000 (+0000) Subject: Use stripPointerCasts. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=344b41cfbd30980a2194c56db382b0537d087ea9;p=oota-llvm.git Use stripPointerCasts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61047 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 62e671fb611..41ff3f37d56 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1358,13 +1358,8 @@ static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV, static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal, Module::global_iterator &GVI, TargetData &TD) { - if (BitCastInst *CI = dyn_cast(StoredOnceVal)) - StoredOnceVal = CI->getOperand(0); - else if (GetElementPtrInst *GEPI =dyn_cast(StoredOnceVal)){ - // "getelementptr Ptr, 0, 0, 0" is really just a cast. - if (GEPI->hasAllZeroIndices()) - StoredOnceVal = GEPI->getOperand(0); - } + // Ignore no-op GEPs and bitcasts. + StoredOnceVal = StoredOnceVal->stripPointerCasts(); // If we are dealing with a pointer global that is initialized to null and // only has one (non-null) value stored into it, then we can optimize any