2013-05-09 19:22:59 +02:00
|
|
|
; RUN: opt < %s -globalopt -S | FileCheck %s
|
|
|
|
|
|
|
|
@c = global i8 42
|
|
|
|
|
2013-06-11 19:48:06 +02:00
|
|
|
@i = internal global i8 42
|
|
|
|
; CHECK: @ia = internal global i8 42
|
2015-09-11 05:22:04 +02:00
|
|
|
@ia = internal alias i8, i8* @i
|
2013-06-11 19:48:06 +02:00
|
|
|
|
2013-05-09 19:22:59 +02:00
|
|
|
@llvm.used = appending global [3 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*), i8* @ca], section "llvm.metadata"
|
2015-09-28 21:02:11 +02:00
|
|
|
; CHECK-DAG: @llvm.used = appending global [3 x i8*] [i8* @ca, i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*)], section "llvm.metadata"
|
2013-05-09 19:22:59 +02:00
|
|
|
|
2013-07-19 20:44:51 +02:00
|
|
|
@llvm.compiler.used = appending global [4 x i8*] [i8* bitcast (void ()* @fa3 to i8*), i8* bitcast (void ()* @fa to i8*), i8* @ia, i8* @i], section "llvm.metadata"
|
|
|
|
; CHECK-DAG: @llvm.compiler.used = appending global [2 x i8*] [i8* bitcast (void ()* @fa3 to i8*), i8* @ia], section "llvm.metadata"
|
2013-05-09 19:22:59 +02:00
|
|
|
|
|
|
|
@sameAsUsed = global [3 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*), i8* @ca]
|
2013-06-11 19:48:06 +02:00
|
|
|
; CHECK-DAG: @sameAsUsed = global [3 x i8*] [i8* bitcast (void ()* @f to i8*), i8* bitcast (void ()* @f to i8*), i8* @c]
|
2013-05-09 19:22:59 +02:00
|
|
|
|
|
|
|
@other = global i32* bitcast (void ()* @fa to i32*)
|
2013-06-11 19:48:06 +02:00
|
|
|
; CHECK-DAG: @other = global i32* bitcast (void ()* @f to i32*)
|
2013-05-09 19:22:59 +02:00
|
|
|
|
2015-09-11 05:22:04 +02:00
|
|
|
@fa = internal alias void (), void ()* @f
|
|
|
|
; CHECK: @fa = internal alias void (), void ()* @f
|
2013-05-09 19:22:59 +02:00
|
|
|
|
2015-09-11 05:22:04 +02:00
|
|
|
@fa2 = internal alias void (), void ()* @f
|
2013-05-09 19:22:59 +02:00
|
|
|
; CHECK-NOT: @fa2
|
|
|
|
|
2015-09-11 05:22:04 +02:00
|
|
|
@fa3 = internal alias void (), void ()* @f
|
2013-05-09 19:22:59 +02:00
|
|
|
; CHECK: @fa3
|
|
|
|
|
2015-09-11 05:22:04 +02:00
|
|
|
@ca = internal alias i8, i8* @c
|
|
|
|
; CHECK: @ca = internal alias i8, i8* @c
|
2013-05-09 19:22:59 +02:00
|
|
|
|
|
|
|
define void @f() {
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define i8* @g() {
|
|
|
|
ret i8* bitcast (void ()* @fa to i8*);
|
|
|
|
}
|
|
|
|
|
|
|
|
define i8* @g2() {
|
|
|
|
ret i8* bitcast (void ()* @fa2 to i8*);
|
|
|
|
}
|
|
|
|
|
|
|
|
define i8* @h() {
|
|
|
|
ret i8* @ca
|
|
|
|
}
|
2016-03-02 21:02:25 +01:00
|
|
|
|
|
|
|
; Check that GlobalOpt doesn't try to resolve aliases with GEP operands.
|
|
|
|
|
|
|
|
%struct.S = type { i32, i32, i32 }
|
|
|
|
@s = global %struct.S { i32 1, i32 2, i32 3 }, align 4
|
|
|
|
|
|
|
|
@alias1 = alias i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i64 0, i32 1)
|
|
|
|
@alias2 = alias i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i64 0, i32 2)
|
|
|
|
|
|
|
|
; CHECK: load i32, i32* @alias1, align 4
|
|
|
|
; CHECK: load i32, i32* @alias2, align 4
|
|
|
|
|
|
|
|
define i32 @foo1() {
|
|
|
|
entry:
|
|
|
|
%0 = load i32, i32* @alias1, align 4
|
|
|
|
%1 = load i32, i32* @alias2, align 4
|
|
|
|
%add = add nsw i32 %1, %0
|
|
|
|
ret i32 %add
|
|
|
|
}
|