1 ; RUN: opt -S -globalsplit %s | FileCheck %s
2 ; RUN: opt -S -passes=globalsplit %s | FileCheck %s
4 target datalayout = "e-p:64:64"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; CHECK: @vtt = constant [3 x i8*] [i8* bitcast ([2 x i8* ()*]* @global.0 to i8*), i8* bitcast (i8* ()** getelementptr inbounds ([2 x i8* ()*], [2 x i8* ()*]* @global.0, i32 0, i32 1) to i8*), i8* bitcast ([1 x i8* ()*]* @global.1 to i8*)]
8 @vtt = constant [3 x i8*] [
9 i8* bitcast (i8* ()** getelementptr ({ [2 x i8* ()*], [1 x i8* ()*] }, { [2 x i8* ()*], [1 x i8* ()*] }* @global, i32 0, inrange i32 0, i32 0) to i8*),
10 i8* bitcast (i8* ()** getelementptr ({ [2 x i8* ()*], [1 x i8* ()*] }, { [2 x i8* ()*], [1 x i8* ()*] }* @global, i32 0, inrange i32 0, i32 1) to i8*),
11 i8* bitcast (i8* ()** getelementptr ({ [2 x i8* ()*], [1 x i8* ()*] }, { [2 x i8* ()*], [1 x i8* ()*] }* @global, i32 0, inrange i32 1, i32 0) to i8*)
14 ; CHECK-NOT: @global =
15 ; CHECK: @global.0 = private constant [2 x i8* ()*] [i8* ()* @f1, i8* ()* @f2], !type [[T1:![0-9]+]], !type [[T2:![0-9]+]], !type [[T3:![0-9]+$]]
16 ; CHECK: @global.1 = private constant [1 x i8* ()*] [i8* ()* @f3], !type [[T4:![0-9]+]], !type [[T5:![0-9]+$]]
17 ; CHECK-NOT: @global =
18 @global = internal constant { [2 x i8* ()*], [1 x i8* ()*] } {
19 [2 x i8* ()*] [i8* ()* @f1, i8* ()* @f2],
20 [1 x i8* ()*] [i8* ()* @f3]
21 }, !type !0, !type !1, !type !2, !type !3, !type !4
23 ; CHECK: define i8* @f1()
25 ; CHECK-NEXT: ret i8* bitcast ([2 x i8* ()*]* @global.0 to i8*)
26 ret i8* bitcast (i8* ()** getelementptr ({ [2 x i8* ()*], [1 x i8* ()*] }, { [2 x i8* ()*], [1 x i8* ()*] }* @global, i32 0, inrange i32 0, i32 0) to i8*)
29 ; CHECK: define i8* @f2()
31 ; CHECK-NEXT: ret i8* bitcast (i8* ()** getelementptr inbounds ([2 x i8* ()*], [2 x i8* ()*]* @global.0, i32 0, i32 1) to i8*)
32 ret i8* bitcast (i8* ()** getelementptr ({ [2 x i8* ()*], [1 x i8* ()*] }, { [2 x i8* ()*], [1 x i8* ()*] }* @global, i32 0, inrange i32 0, i32 1) to i8*)
35 ; CHECK: define i8* @f3()
37 ; CHECK-NEXT: ret i8* bitcast (i8* ()** getelementptr inbounds ([2 x i8* ()*], [2 x i8* ()*]* @global.0, i64 1, i32 0) to i8*)
38 ret i8* bitcast (i8* ()** getelementptr ({ [2 x i8* ()*], [1 x i8* ()*] }, { [2 x i8* ()*], [1 x i8* ()*] }* @global, i32 0, inrange i32 0, i32 2) to i8*)
41 ; CHECK: define i8* @f4()
43 ; CHECK-NEXT: ret i8* bitcast ([1 x i8* ()*]* @global.1 to i8*)
44 ret i8* bitcast (i8* ()** getelementptr ({ [2 x i8* ()*], [1 x i8* ()*] }, { [2 x i8* ()*], [1 x i8* ()*] }* @global, i32 0, inrange i32 1, i32 0) to i8*)
48 %p = call i1 @llvm.type.test(i8* null, metadata !"")
52 declare i1 @llvm.type.test(i8*, metadata) nounwind readnone
54 ; CHECK: [[T1]] = !{i32 0, !"foo"}
55 ; CHECK: [[T2]] = !{i32 15, !"bar"}
56 ; CHECK: [[T3]] = !{i32 16, !"a"}
57 ; CHECK: [[T4]] = !{i32 1, !"b"}
58 ; CHECK: [[T5]] = !{i32 8, !"c"}
60 !1 = !{i32 15, !"bar"}