[llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalOpt.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Oct 10 09:47:44 PDT 2004



Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.19 -> 1.20
---
Log message:

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.


---
Diffs of the changes:  (+11 -0)

Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.19 llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.20
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.19	Sun Oct 10 11:43:46 2004
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp	Sun Oct 10 11:47:33 2004
@@ -259,6 +259,17 @@
     } 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;






More information about the llvm-commits mailing list