[llvm-commits] [llvm] r66233 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/2009-03-05-dbg.ll

Devang Patel dpatel at apple.com
Thu Mar 5 17:39:36 PST 2009


Author: dpatel
Date: Thu Mar  5 19:39:36 2009
New Revision: 66233

URL: http://llvm.org/viewvc/llvm-project?rev=66233&view=rev
Log:
Revert 66224.

Modified:
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
    llvm/trunk/test/Transforms/GlobalOpt/2009-03-05-dbg.ll

Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=66233&r1=66232&r2=66233&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Mar  5 19:39:36 2009
@@ -23,7 +23,6 @@
 #include "llvm/Module.h"
 #include "llvm/Pass.h"
 #include "llvm/Analysis/ConstantFolding.h"
-#include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/Compiler.h"
@@ -1541,7 +1540,7 @@
   // Walk the use list of the global seeing if all the uses are load or store.
   // If there is anything else, bail out.
   for (Value::use_iterator I = GV->use_begin(), E = GV->use_end(); I != E; ++I)
-    if (!isa<LoadInst>(I) && !isa<StoreInst>(I) && !UserIsDebugInfo(*I))
+    if (!isa<LoadInst>(I) && !isa<StoreInst>(I))
       return false;
   
   DOUT << "   *** SHRINKING TO BOOL: " << *GV;
@@ -1564,8 +1563,8 @@
     IsOneZero = InitVal->isNullValue() && CI->isOne();
 
   while (!GV->use_empty()) {
-    User *GVU = GV->use_back();
-    if (StoreInst *SI = dyn_cast<StoreInst>(GVU)) {
+    Instruction *UI = cast<Instruction>(GV->use_back());
+    if (StoreInst *SI = dyn_cast<StoreInst>(UI)) {
       // Change the store into a boolean store.
       bool StoringOther = SI->getOperand(0) == OtherVal;
       // Only do this if we weren't storing a loaded value.
@@ -1593,9 +1592,9 @@
         }
       }
       new StoreInst(StoreVal, NewGV, SI);
-      SI->eraseFromParent();
-    } else if (LoadInst *LI = dyn_cast<LoadInst>(GVU)) {
+    } else {
       // Change the load into a load of bool then a select.
+      LoadInst *LI = cast<LoadInst>(UI);
       LoadInst *NLI = new LoadInst(NewGV, LI->getName()+".b", LI);
       Value *NSI;
       if (IsOneZero)
@@ -1604,9 +1603,8 @@
         NSI = SelectInst::Create(NLI, OtherVal, InitVal, "", LI);
       NSI->takeName(LI);
       LI->replaceAllUsesWith(NSI);
-      LI->eraseFromParent();
-    } else 
-      RemoveDbgInfoUser(GVU);
+    }
+    UI->eraseFromParent();
   }
 
   GV->eraseFromParent();

Modified: llvm/trunk/test/Transforms/GlobalOpt/2009-03-05-dbg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/2009-03-05-dbg.ll?rev=66233&r1=66232&r2=66233&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/GlobalOpt/2009-03-05-dbg.ll (original)
+++ llvm/trunk/test/Transforms/GlobalOpt/2009-03-05-dbg.ll Thu Mar  5 19:39:36 2009
@@ -1,4 +1,6 @@
 ; RUN: llvm-as < %s | opt -globalopt -stats -disable-output |& grep "1 globalopt - Number of global vars shrunk to booleans"
+; XFAIL: *
+
 	type { }		; type %0
 	%llvm.dbg.anchor.type = type { i32, i32 }
 	%llvm.dbg.basictype.type = type { i32, %0*, i8*, %0*, i32, i64, i64, i64, i32, i32 }





More information about the llvm-commits mailing list