stored to, but are stored at variable indexes. This occurs at least in
176.gcc, but probably others, and we should handle it for completeness.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16876
91177308-0d34-0410-b5e6-
96231b3b80d8
} else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(U)) {
if (Constant *SubInit = TraverseGEPInitializer(GEP, Init))
Changed |= CleanupConstantGlobalUsers(GEP, SubInit);
+ else {
+ // If this GEP has variable indexes, we should still be able to delete
+ // any stores through it.
+ for (Value::use_iterator GUI = GEP->use_begin(), E = GEP->use_end();
+ GUI != E;)
+ if (StoreInst *SI = dyn_cast<StoreInst>(*GUI++)) {
+ SI->getParent()->getInstList().erase(SI);
+ Changed = true;
+ }
+ }
+
if (GEP->use_empty()) {
GEP->getParent()->getInstList().erase(GEP);
Changed = true;