blob: 1dd638da3265b3bf30ae98ad52cc8837047a7d06 [file] [log] [blame]
Peter Collingbournef72a8d42016-11-16 23:40:26 +00001; RUN: opt -S -globalsplit %s | FileCheck %s
2
3target datalayout = "e-p:64:64"
4target triple = "x86_64-unknown-linux-gnu"
5
6; 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*)]
7@vtt = constant [3 x i8*] [
8 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*),
9 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*),
10 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*)
11]
12
13; CHECK-NOT: @global =
14; CHECK: @global.0 = private constant [2 x i8* ()*] [i8* ()* @f1, i8* ()* @f2], !type [[T1:![0-9]+$]]
15; CHECK: @global.1 = private constant [1 x i8* ()*] [i8* ()* @f3], !type [[T2:![0-9]+$]]
16; CHECK-NOT: @global =
17@global = internal constant { [2 x i8* ()*], [1 x i8* ()*] } {
18 [2 x i8* ()*] [i8* ()* @f1, i8* ()* @f2],
19 [1 x i8* ()*] [i8* ()* @f3]
20}, !type !0, !type !1
21
22; CHECK: define i8* @f1()
23define i8* @f1() {
24 ; CHECK-NEXT: ret i8* bitcast ([2 x i8* ()*]* @global.0 to i8*)
25 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*)
26}
27
28; CHECK: define i8* @f2()
29define i8* @f2() {
30 ; CHECK-NEXT: ret i8* bitcast (i8* ()** getelementptr inbounds ([2 x i8* ()*], [2 x i8* ()*]* @global.0, i32 0, i32 1) to i8*)
31 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*)
32}
33
34; CHECK: define i8* @f3()
35define i8* @f3() {
36 ; CHECK-NEXT: ret i8* bitcast (i8* ()** getelementptr inbounds ([2 x i8* ()*], [2 x i8* ()*]* @global.0, i64 1, i32 0) to i8*)
37 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*)
38}
39
40; CHECK: define i8* @f4()
41define i8* @f4() {
42 ; CHECK-NEXT: ret i8* bitcast ([1 x i8* ()*]* @global.1 to i8*)
43 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*)
44}
45
46define void @foo() {
47 %p = call i1 @llvm.type.test(i8* null, metadata !"")
48 ret void
49}
50
51declare i1 @llvm.type.test(i8*, metadata) nounwind readnone
52
53; CHECK: [[T1]] = !{i32 8, !"foo"}
54; CHECK: [[T2]] = !{i32 0, !"bar"}
55!0 = !{i32 8, !"foo"}
56!1 = !{i32 16, !"bar"}