diff options
| author | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-25 14:27:10 +0000 |
|---|---|---|
| committer | Anton Korobeynikov <asl@math.spbu.ru> | 2007-04-25 14:27:10 +0000 |
| commit | a97b694c823eb346d255ca04724f4003f9056800 (patch) | |
| tree | 3545f70936dcd0d230e479913f19dc1c78c37cfb /llvm/lib/Transforms | |
| parent | 7818c03c6b6dd1481c467e8292516a388d567e27 (diff) | |
| download | bcm5719-llvm-a97b694c823eb346d255ca04724f4003f9056800.tar.gz bcm5719-llvm-a97b694c823eb346d255ca04724f4003f9056800.zip | |
Implement aliases. This fixes PR1017 and it's dependent bugs. CFE part
will follow.
llvm-svn: 36435
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/GlobalDCE.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp index 7fd110208f7..560bcb56b0f 100644 --- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp +++ b/llvm/lib/Transforms/IPO/GlobalDCE.cpp @@ -62,7 +62,8 @@ bool GlobalDCE::runOnModule(Module &M) { 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 @@ bool GlobalDCE::runOnModule(Module &M) { } + 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 @@ void GlobalDCE::GlobalIsNeeded(GlobalValue *G) { // 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())); } 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 |

