1 ; RUN: opt < %s -globalopt -S | FileCheck %s
5 @i = internal global i8 42
6 ; CHECK: @ia = internal global i8 42
7 @ia = internal alias i8, i8* @i
9 @llvm.used = appending global [3 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*), i8* @ca], section "llvm.metadata"
10 ; CHECK-DAG: @llvm.used = appending global [3 x i8*] [i8* @ca, i8* bitcast (void ()* @f to i8*), i8* bitcast (void ()* @fa to i8*)], section "llvm.metadata"
12 @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"
13 ; CHECK-DAG: @llvm.compiler.used = appending global [2 x i8*] [i8* bitcast (void ()* @fa3 to i8*), i8* @ia], section "llvm.metadata"
15 @sameAsUsed = global [3 x i8*] [i8* bitcast (void ()* @fa to i8*), i8* bitcast (void ()* @f to i8*), i8* @ca]
16 ; CHECK-DAG: @sameAsUsed = local_unnamed_addr global [3 x i8*] [i8* bitcast (void ()* @f to i8*), i8* bitcast (void ()* @f to i8*), i8* @c]
18 @other = global i32* bitcast (void ()* @fa to i32*)
19 ; CHECK-DAG: @other = local_unnamed_addr global i32* bitcast (void ()* @f to i32*)
21 @fa = internal alias void (), void ()* @f
22 ; CHECK: @fa = internal alias void (), void ()* @f
24 @fa2 = internal alias void (), void ()* @f
27 @fa3 = internal alias void (), void ()* @f
30 @ca = internal alias i8, i8* @c
31 ; CHECK: @ca = internal alias i8, i8* @c
38 ret i8* bitcast (void ()* @fa to i8*);
42 ret i8* bitcast (void ()* @fa2 to i8*);
49 ; Check that GlobalOpt doesn't try to resolve aliases with GEP operands.
51 %struct.S = type { i32, i32, i32 }
52 @s = global %struct.S { i32 1, i32 2, i32 3 }, align 4
54 @alias1 = alias i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i64 0, i32 1)
55 @alias2 = alias i32, i32* getelementptr inbounds (%struct.S, %struct.S* @s, i64 0, i32 2)
57 ; CHECK: load i32, i32* @alias1, align 4
58 ; CHECK: load i32, i32* @alias2, align 4
62 %0 = load i32, i32* @alias1, align 4
63 %1 = load i32, i32* @alias2, align 4
64 %add = add nsw i32 %1, %0