forked from OSchip/llvm-project
parent
4b0d24c00a
commit
5349d87a69
|
@ -2993,10 +2993,17 @@ bool GlobalOpt::OptimizeGlobalAliases(Module &M) {
|
|||
|
||||
for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end();
|
||||
I != E;) {
|
||||
Module::alias_iterator J = I++;
|
||||
GlobalAlias *J = &*I++;
|
||||
|
||||
// Aliases without names cannot be referenced outside this module.
|
||||
if (!J->hasName() && !J->isDeclaration() && !J->hasLocalLinkage())
|
||||
J->setLinkage(GlobalValue::InternalLinkage);
|
||||
|
||||
if (deleteIfDead(*J)) {
|
||||
Changed = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the aliasee may change at link time, nothing can be done - bail out.
|
||||
if (J->mayBeOverridden())
|
||||
continue;
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
; CHECK: @weak1 = weak alias void (), void ()* @bar2
|
||||
|
||||
@bar4 = private unnamed_addr constant [2 x i8*] zeroinitializer
|
||||
@foo4 = linkonce_odr unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @bar4, i32 0, i32 1)
|
||||
; CHECK: @foo4 = linkonce_odr unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @bar4, i32 0, i32 1)
|
||||
@foo4 = weak_odr unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @bar4, i32 0, i32 1)
|
||||
; CHECK: @foo4 = weak_odr unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @bar4, i32 0, i32 1)
|
||||
|
||||
define void @bar2() {
|
||||
ret void
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
; RUN: opt < %s -globalopt -S | FileCheck %s
|
||||
|
||||
@G1 = internal global i32 123 ; <i32*> [#uses=1]
|
||||
@A1 = internal alias i32, i32* @G1
|
||||
|
||||
; CHECK-NOT: @G1
|
||||
; CHECK: @G2
|
||||
; CHECK-NOT: @G3
|
||||
|
||||
; CHECK-NOT: @A1
|
||||
|
||||
define void @foo1() {
|
||||
; CHECK: define void @foo
|
||||
; CHECK-NEXT: ret
|
||||
|
|
|
@ -13,7 +13,7 @@ define i8 @f() norecurse {
|
|||
}
|
||||
|
||||
@H = internal global i32 42
|
||||
@Halias = internal alias i32, i32* @H
|
||||
@Halias = alias i32, i32* @H
|
||||
|
||||
; @H can't be localized because @Halias uses it, and @Halias can't be converted to an instruction.
|
||||
define i8 @g() norecurse {
|
||||
|
|
Loading…
Reference in New Issue