mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 22:28:18 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212079 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2865,7 +2865,12 @@ bool GlobalOpt::OptimizeGlobalAliases(Module &M) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
Constant *Aliasee = J->getAliasee();
|
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();
|
Target->removeDeadConstantUsers();
|
||||||
|
|
||||||
// Make all users of the alias use the aliasee instead.
|
// Make all users of the alias use the aliasee instead.
|
||||||
|
@@ -12,6 +12,10 @@
|
|||||||
@weak1 = alias weak void ()* @bar2
|
@weak1 = alias weak void ()* @bar2
|
||||||
; CHECK: @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() {
|
define void @bar2() {
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user