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

2007-04-28 Thread Anton Korobeynikov


Changes in directory llvm/lib/Transforms/IPO:

GlobalDCE.cpp updated: 1.43 - 1.44
---
Log message:

Implement review feedback. Aliasees can be either GlobalValue's or 
bitcasts of them.


---
Diffs of the changes:  (+2 -6)

 GlobalDCE.cpp |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)


Index: llvm/lib/Transforms/IPO/GlobalDCE.cpp
diff -u llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.43 
llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.44
--- llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.43  Wed Apr 25 09:27:10 2007
+++ llvm/lib/Transforms/IPO/GlobalDCE.cpp   Sat Apr 28 08:44:59 2007
@@ -75,9 +75,8 @@
 
   for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end();
I != E; ++I) {
-Changed |= RemoveUnusedGlobalValue(*I);
 // Aliases are always needed even if they are not used.
-GlobalIsNeeded(I);
+MarkUsedGlobalsAsNeeded(castConstant(I-getAliasee()));
   }
 
   // Now that all globals which are needed are in the AliveGlobals set, we loop
@@ -143,10 +142,7 @@
 // referenced by the initializer to the alive set.
 if (GV-hasInitializer())
   MarkUsedGlobalsAsNeeded(GV-getInitializer());
-  } else if (GlobalAlias *GA = dyn_castGlobalAlias(G)) {
-// If this is a global alias we also need it's aliasee
-GlobalIsNeeded(const_castGlobalValue*(GA-getAliasee()));
-  } else {
+  } else if (!isaGlobalAlias(G)) {
 // Otherwise this must be a function object.  We have to scan the body of
 // the function looking for constants and global values which are used as
 // operands.  Any operands of these types must be processed to ensure that



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-04-28 Thread Chris Lattner
 Index: llvm/lib/Transforms/IPO/GlobalDCE.cpp
 diff -u llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.43 llvm/lib/ 
 Transforms/IPO/GlobalDCE.cpp:1.44
 --- llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.43Wed Apr 25 09:27:10  
 2007
 +++ llvm/lib/Transforms/IPO/GlobalDCE.cpp Sat Apr 28 08:44:59 2007
 @@ -75,9 +75,8 @@

for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end();
 I != E; ++I) {
 -Changed |= RemoveUnusedGlobalValue(*I);
  // Aliases are always needed even if they are not used.
 -GlobalIsNeeded(I);
 +MarkUsedGlobalsAsNeeded(castConstant(I-getAliasee()));

You can drop the cast, the method already returns a Constant.

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-04-25 Thread Anton Korobeynikov


Changes in directory llvm/lib/Transforms/IPO:

GlobalDCE.cpp updated: 1.42 - 1.43
---
Log message:

Implement aliases. This fixes PR1017: http://llvm.org/PR1017  and it's 
dependent bugs. CFE part 
will follow.


---
Diffs of the changes:  (+12 -1)

 GlobalDCE.cpp |   13 -
 1 files changed, 12 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/IPO/GlobalDCE.cpp
diff -u llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.42 
llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.43
--- llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.42  Mon Feb  5 17:32:05 2007
+++ llvm/lib/Transforms/IPO/GlobalDCE.cpp   Wed Apr 25 09:27:10 2007
@@ -62,7 +62,8 @@
   GlobalIsNeeded(I);
   }
 
-  for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != 
E; ++I) {
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end();
+   I != E; ++I) {
 Changed |= RemoveUnusedGlobalValue(*I);
 // Externally visible  appending globals are needed, if they have an
 // initializer.
@@ -72,6 +73,13 @@
   }
 
 
+  for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end();
+   I != E; ++I) {
+Changed |= RemoveUnusedGlobalValue(*I);
+// Aliases are always needed even if they are not used.
+GlobalIsNeeded(I);
+  }
+
   // Now that all globals which are needed are in the AliveGlobals set, we loop
   // through the program, deleting those which are not alive.
   //
@@ -135,6 +143,9 @@
 // referenced by the initializer to the alive set.
 if (GV-hasInitializer())
   MarkUsedGlobalsAsNeeded(GV-getInitializer());
+  } else if (GlobalAlias *GA = dyn_castGlobalAlias(G)) {
+// If this is a global alias we also need it's aliasee
+GlobalIsNeeded(const_castGlobalValue*(GA-getAliasee()));
   } else {
 // Otherwise this must be a function object.  We have to scan the body of
 // the function looking for constants and global values which are used as



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-04-25 Thread Chris Lattner

On Apr 25, 2007, at 7:28 AM, Anton Korobeynikov wrote:



 +  for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end();
 +   I != E; ++I) {
 +Changed |= RemoveUnusedGlobalValue(*I);

RemoveUnusedGlobalValue shouldn't be called here.

 +// Aliases are always needed even if they are not used.
 +GlobalIsNeeded(I);

This should mark I-getAliasee() as needed, not the alias.

 +  }
 +
// Now that all globals which are needed are in the AliveGlobals  
 set, we loop
// through the program, deleting those which are not alive.
//
 @@ -135,6 +143,9 @@
  // referenced by the initializer to the alive set.
  if (GV-hasInitializer())
MarkUsedGlobalsAsNeeded(GV-getInitializer());
 +  } else if (GlobalAlias *GA = dyn_castGlobalAlias(G)) {
 +// If this is a global alias we also need it's aliasee
 +GlobalIsNeeded(const_castGlobalValue*(GA-getAliasee()));

If you do the above change, you can delete this hunk.  Why do you  
need the const_cast?

-Chris



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits