summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-10-10 16:47:33 +0000
committerChris Lattner <sabre@nondot.org>2004-10-10 16:47:33 +0000
commita0e769cc815f64eeb9cf2569cb067da592525e61 (patch)
tree7c859e53a0f33761a555a7d30b5c73e5ea562c13 /llvm/lib/Transforms/IPO/GlobalOpt.cpp
parent924ce79136bd932c43b394eba9a9b6d20a381f21 (diff)
downloadbcm5719-llvm-a0e769cc815f64eeb9cf2569cb067da592525e61.tar.gz
bcm5719-llvm-a0e769cc815f64eeb9cf2569cb067da592525e61.zip
Implement GlobalOpt/deadglobal-2.llx, deletion of globals that are only
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. llvm-svn: 16876
Diffstat (limited to 'llvm/lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 7c0c3225129..3a58afdc260 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -259,6 +259,17 @@ static bool CleanupConstantGlobalUsers(Value *V, Constant *Init) {
} 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;
OpenPOWER on IntegriCloud