forked from OSchip/llvm-project
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
This commit is contained in:
parent
5bfe75cf61
commit
0e2cc2a519
|
@ -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.
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
@weak1 = alias weak void ()* @bar2
|
||||
; CHECK: @weak1 = alias weak void ()* @bar2
|
||||
|
||||
@bar4 = private unnamed_addr constant [2 x i8*] zeroinitializer
|
||||
@foo4 = unnamed_addr alias linkonce_odr getelementptr inbounds ([2 x i8*]* @bar4, i32 0, i32 1)
|
||||
; CHECK: @foo4 = unnamed_addr alias linkonce_odr getelementptr inbounds ([2 x i8*]* @bar4, i32 0, i32 1)
|
||||
|
||||
define void @bar2() {
|
||||
ret void
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue