summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2009-03-04 22:02:09 +0000
committerBill Wendling <isanbard@gmail.com>2009-03-04 22:02:09 +0000
commit803da0db79b9b1f2761f25c944d3003eb90ea255 (patch)
tree54d329f7f5123a21e44f613d0601cb15f41cd870 /llvm/lib
parentebd4998c1fbdd1838605d00300ec451974432605 (diff)
downloadbcm5719-llvm-803da0db79b9b1f2761f25c944d3003eb90ea255.tar.gz
bcm5719-llvm-803da0db79b9b1f2761f25c944d3003eb90ea255.zip
Temporarily revert r65994. It was causing rdar://6646455.
llvm-svn: 66083
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp26
1 files changed, 6 insertions, 20 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 28cd902472d..0a35fa93e43 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -137,23 +137,15 @@ struct VISIBILITY_HIDDEN GlobalStatus {
}
/// ConstantIsDead - Return true if the specified constant is (transitively)
-/// dead. The constant may be used by other constants (e.g. constant arrays,
-/// constant exprs, constant global variables) as long as they are dead,
-/// but it cannot be used by anything else. If DeadGVs is not null then
-/// record dead constant GV users.
-static bool ConstantIsDead(Constant *C,
- SmallPtrSet<GlobalVariable *, 4> *DeadGVs = false) {
- if (GlobalVariable *GV = dyn_cast<GlobalVariable>(C))
- if (GV->hasLocalLinkage() && GV->use_empty()) {
- if (DeadGVs)
- DeadGVs->insert(GV);
- return true;
- }
+/// dead. The constant may be used by other constants (e.g. constant arrays and
+/// constant exprs) as long as they are dead, but it cannot be used by anything
+/// else.
+static bool ConstantIsDead(Constant *C) {
if (isa<GlobalValue>(C)) return false;
for (Value::use_iterator UI = C->use_begin(), E = C->use_end(); UI != E; ++UI)
if (Constant *CU = dyn_cast<Constant>(*UI)) {
- if (!ConstantIsDead(CU, DeadGVs)) return false;
+ if (!ConstantIsDead(CU)) return false;
} else
return false;
return true;
@@ -346,13 +338,7 @@ static bool CleanupConstantGlobalUsers(Value *V, Constant *Init) {
} else if (Constant *C = dyn_cast<Constant>(U)) {
// If we have a chain of dead constantexprs or other things dangling from
// us, and if they are all dead, nuke them without remorse.
- SmallPtrSet<GlobalVariable *, 4> DeadGVs;
- if (ConstantIsDead(C, &DeadGVs)) {
- for (SmallPtrSet<GlobalVariable *, 4>::iterator TI = DeadGVs.begin(),
- TE = DeadGVs.end(); TI != TE; ) {
- GlobalVariable *TGV = *TI; ++TI;
- TGV->eraseFromParent();
- }
+ if (ConstantIsDead(C)) {
C->destroyConstant();
// This could have invalidated UI, start over from scratch.
CleanupConstantGlobalUsers(V, Init);
OpenPOWER on IntegriCloud