[llvm-commits] [llvm] r66082 - in /llvm/branches/Apple/Dib: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/2009-03-03-dbg.ll

Bill Wendling isanbard at gmail.com
Wed Mar 4 14:01:07 PST 2009


Author: void
Date: Wed Mar  4 16:01:06 2009
New Revision: 66082

URL: http://llvm.org/viewvc/llvm-project?rev=66082&view=rev
Log:
Temporarily revert r65994. It was causing rdar://6646455.

Modified:
    llvm/branches/Apple/Dib/lib/Transforms/IPO/GlobalOpt.cpp
    llvm/branches/Apple/Dib/test/Transforms/GlobalOpt/2009-03-03-dbg.ll

Modified: llvm/branches/Apple/Dib/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Transforms/IPO/GlobalOpt.cpp?rev=66082&r1=66081&r2=66082&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/branches/Apple/Dib/lib/Transforms/IPO/GlobalOpt.cpp Wed Mar  4 16:01:06 2009
@@ -135,23 +135,15 @@
 }
 
 /// 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;
@@ -344,13 +336,7 @@
     } 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);

Modified: llvm/branches/Apple/Dib/test/Transforms/GlobalOpt/2009-03-03-dbg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/test/Transforms/GlobalOpt/2009-03-03-dbg.ll?rev=66082&r1=66081&r2=66082&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/test/Transforms/GlobalOpt/2009-03-03-dbg.ll (original)
+++ llvm/branches/Apple/Dib/test/Transforms/GlobalOpt/2009-03-03-dbg.ll Wed Mar  4 16:01:06 2009
@@ -1,4 +1,6 @@
 ; RUN: llvm-as < %s | opt -globalopt | llvm-dis | not grep global_variable42
+; XFAIL: *
+
 	%llvm.dbg.anchor.type = type { i32, i32 }
 	%llvm.dbg.basictype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, i32 }
 	%llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8*, i32 }





More information about the llvm-commits mailing list