• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mtriple=thumb-apple-darwin -arm-global-merge -global-merge-group-by-use=false -global-merge-on-const=true | FileCheck %s
2; Test the ARMGlobalMerge pass.  Use -march=thumb because it has a small
3; value for the maximum offset (127).
4
5; A local array that exceeds the maximum offset should not be merged.
6; CHECK: g0:
7@g0 = internal global [32 x i32] [ i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1, i32 2 ]
8
9; Global variables marked with "used" attribute must be kept
10; CHECK: g8
11@g8 = internal global i32 0
12@llvm.used = appending global [1 x i8*] [i8* bitcast (i32* @g8 to i8*)], section "llvm.metadata"
13
14; Global used in landing pad instruction must be kept
15; CHECK: ZTIi
16@_ZTIi = internal global i8* null
17
18define i32 @_Z9exceptioni(i32 %arg) personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*) {
19bb:
20  %tmp = invoke i32 @_Z14throwSomethingi(i32 %arg)
21          to label %bb9 unwind label %bb1
22
23bb1:                                              ; preds = %bb
24  %tmp2 = landingpad { i8*, i32 }
25          catch i8* bitcast (i8** @_ZTIi to i8*)
26  %tmp3 = extractvalue { i8*, i32 } %tmp2, 1
27  %tmp4 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
28  %tmp5 = icmp eq i32 %tmp3, %tmp4
29  br i1 %tmp5, label %bb6, label %bb10
30
31bb6:                                              ; preds = %bb1
32  %tmp7 = extractvalue { i8*, i32 } %tmp2, 0
33  %tmp8 = tail call i8* @__cxa_begin_catch(i8* %tmp7)
34  tail call void @__cxa_end_catch()
35  br label %bb9
36
37bb9:                                              ; preds = %bb6, %bb
38  %res.0 = phi i32 [ 0, %bb6 ], [ %tmp, %bb ]
39  ret i32 %res.0
40
41bb10:                                             ; preds = %bb1
42  resume { i8*, i32 } %tmp2
43}
44
45declare i32 @_Z14throwSomethingi(i32)
46
47declare i32 @__gxx_personality_sj0(...)
48
49declare i32 @llvm.eh.typeid.for(i8*)
50
51declare i8* @__cxa_begin_catch(i8*)
52
53declare void @__cxa_end_catch()
54
55; CHECK: _MergedGlobals:
56@g1 = internal global i32 1
57@g2 = internal global i32 2
58
59; Make sure that the complete variable fits within the range of the maximum
60; offset.  Having the starting offset in range is not sufficient.
61; When this works properly, @g3 is placed in a separate chunk of merged globals.
62; CHECK: _MergedGlobals.1:
63@g3 = internal global [30 x i32] [ i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10 ], align 4
64
65; Global variables that can be placed in BSS should be kept together in a
66; separate pool of merged globals.
67; CHECK: _MergedGlobals.2
68@g4 = internal global i32 0
69@g5 = internal global i32 0
70
71; Global variables that are constant can be merged together
72; CHECK: _MergedGlobals.3
73@g6 = internal constant [12 x i32] zeroinitializer, align 4
74@g7 = internal constant [12 x i32] zeroinitializer, align 4
75