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

Chris Lattner clattner at apple.com
Wed Apr 25 13:31:18 PDT 2007


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_cast<GlobalAlias>(G)) {
> +    // If this is a global alias we also need it's aliasee
> +    GlobalIsNeeded(const_cast<GlobalValue*>(GA->getAliasee()));

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

-Chris






More information about the llvm-commits mailing list