summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-03-06 01:39:36 +0000
committerDevang Patel <dpatel@apple.com>2009-03-06 01:39:36 +0000
commit771281f1806ba3299fb515f59bd2f726a6a7a77e (patch)
treefe091c1e7c744148b55b20b6e87c77077f577600
parent743cdf8edf21d96b3d155eb322578936aebc4876 (diff)
downloadllvm-771281f1806ba3299fb515f59bd2f726a6a7a77e.tar.gz
llvm-771281f1806ba3299fb515f59bd2f726a6a7a77e.tar.bz2
llvm-771281f1806ba3299fb515f59bd2f726a6a7a77e.tar.xz
Revert 66224.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66233 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp16
-rw-r--r--test/Transforms/GlobalOpt/2009-03-05-dbg.ll2
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 8362e8c893..0a35fa93e4 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -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 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
// 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 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
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 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
}
}
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 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
NSI = SelectInst::Create(NLI, OtherVal, InitVal, "", LI);
NSI->takeName(LI);
LI->replaceAllUsesWith(NSI);
- LI->eraseFromParent();
- } else
- RemoveDbgInfoUser(GVU);
+ }
+ UI->eraseFromParent();
}
GV->eraseFromParent();
diff --git a/test/Transforms/GlobalOpt/2009-03-05-dbg.ll b/test/Transforms/GlobalOpt/2009-03-05-dbg.ll
index 1ff6bdf023..30e9a63f3b 100644
--- a/test/Transforms/GlobalOpt/2009-03-05-dbg.ll
+++ b/test/Transforms/GlobalOpt/2009-03-05-dbg.ll
@@ -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 }