From 1c731fa86f493d08958a06a90e5853b3580f40a4 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 15 Dec 2008 21:20:32 +0000 Subject: [PATCH] Use stripPointerCasts. llvm-svn: 61047 --- llvm/lib/Transforms/IPO/GlobalOpt.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index 62e671fb6112..41ff3f37d567 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/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