diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-07-01 00:30:56 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-07-01 00:30:56 +0000 |
commit | 0e2cc2a519a35796b48dd564db80d578df56e9f8 (patch) | |
tree | 4609e00297176c5cb348b2d862c7b88b3b473028 /llvm/lib/Transforms/IPO/GlobalOpt.cpp | |
parent | 5bfe75cf61dc2bb4176ef602586d44f4499fe11f (diff) | |
download | bcm5719-llvm-0e2cc2a519a35796b48dd564db80d578df56e9f8.tar.gz bcm5719-llvm-0e2cc2a519a35796b48dd564db80d578df56e9f8.zip |
GlobalOpt: Handle non-zero offsets for aliases
An alias with an aliasee of a non-zero GEP is not trivially replacable
with it's aliasee.
llvm-svn: 212079
Diffstat (limited to 'llvm/lib/Transforms/IPO/GlobalOpt.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/GlobalOpt.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index dc9b2a8105e..63a6058b969 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -2865,7 +2865,12 @@ bool GlobalOpt::OptimizeGlobalAliases(Module &M) { continue; Constant *Aliasee = J->getAliasee(); - GlobalValue *Target = cast<GlobalValue>(Aliasee->stripPointerCasts()); + GlobalValue *Target = dyn_cast<GlobalValue>(Aliasee->stripPointerCasts()); + // We can't trivially replace the alias with the aliasee if the aliasee is + // non-trivial in some way. + // TODO: Try to handle non-zero GEPs of local aliasees. + if (!Target) + continue; Target->removeDeadConstantUsers(); // Make all users of the alias use the aliasee instead. |