cgscc-invalidate.ll
2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
; This test tries to ensure that the inliner successfully invalidates function
; analyses after inlining into the function body.
;
; The strategy for these tests is to compute domtree over all the functions,
; then run the inliner, and then verify the domtree. Then we can arrange the
; inline to disturb the domtree (easy) and detect any stale cached entries in
; the verifier. We do the initial computation both *inside* the CGSCC walk and
; in a pre-step to make sure both work.
;
; RUN: opt < %s -passes='function(require<domtree>),cgscc(inline,function(verify<domtree>))' -S | FileCheck %s
; RUN: opt < %s -passes='cgscc(function(require<domtree>),inline,function(verify<domtree>))' -S | FileCheck %s
; An external function used to control branches.
declare i1 @flag()
; CHECK-LABEL: declare i1 @flag()
; The utility function with interesting control flow that gets inlined below to
; perturb the dominator tree.
define internal void @callee() {
; CHECK-LABEL: @callee
entry:
%ptr = alloca i8
%flag = call i1 @flag()
br i1 %flag, label %then, label %else
then:
store volatile i8 42, i8* %ptr
br label %return
else:
store volatile i8 -42, i8* %ptr
br label %return
return:
ret void
}
; The 'test1_' prefixed functions test the basic scenario of inlining
; destroying dominator tree.
define void @test1_caller() {
; CHECK-LABEL: define void @test1_caller()
entry:
call void @callee()
; CHECK-NOT: @callee
ret void
; CHECK: ret void
}
; The 'test2_' prefixed functions test the scenario of not inlining preserving
; dominators.
define void @test2_caller() {
; CHECK-LABEL: define void @test2_caller()
entry:
call void @callee() noinline
; CHECK: call void @callee
ret void
; CHECK: ret void
}
; The 'test3_' prefixed functions test the scenario of not inlining preserving
; dominators after splitting an SCC into two smaller SCCs.
; This function ends up split into a separate SCC, which can cause its analyses
; to become stale if the splitting doesn't properly invalidate things. Also, as
; a consequence of being split out, test3_f is too large to inline by the time
; we get here.
define void @test3_g() {
; CHECK-LABEL: define void @test3_g()
entry:
; Create the second edge in the SCC cycle.
call void @test3_f()
; CHECK: call void @test3_f()
; Pull interesting CFG into this function.
call void @callee()
; CHECK-NOT: call void @callee()
ret void
; CHECK: ret void
}
; The second function gets visited first and we end up inlining everything we
; can into this routine. That splits test3_g into a separate SCC that is enqued
; for later processing.
define void @test3_f() {
; CHECK-LABEL: define void @test3_f()
entry:
; Create the first edge in the SCC cycle.
call void @test3_g()
; CHECK-NOT: @test3_g()
; CHECK: call void @test3_f()
; Pull interesting CFG into this function.
call void @callee()
; CHECK-NOT: call void @callee()
ret void
; CHECK: ret void
}