1 ; This test tries to ensure that the inliner successfully invalidates function
2 ; analyses after inlining into the function body.
4 ; The strategy for these tests is to compute domtree over all the functions,
5 ; then run the inliner, and then verify the domtree. Then we can arrange the
6 ; inline to disturb the domtree (easy) and detect any stale cached entries in
7 ; the verifier. We do the initial computation both *inside* the CGSCC walk and
8 ; in a pre-step to make sure both work.
10 ; RUN: opt < %s -passes='function(require<domtree>),cgscc(inline,function(verify<domtree>))' -S | FileCheck %s
11 ; RUN: opt < %s -passes='cgscc(function(require<domtree>),inline,function(verify<domtree>))' -S | FileCheck %s
13 ; An external function used to control branches.
15 ; CHECK-LABEL: declare i1 @flag()
17 ; The utility function with interesting control flow that gets inlined below to
18 ; perturb the dominator tree.
19 define internal void @callee() {
20 ; CHECK-LABEL: @callee
23 %flag = call i1 @flag()
24 br i1 %flag, label %then, label %else
27 store volatile i8 42, i8* %ptr
31 store volatile i8 -42, i8* %ptr
39 ; The 'test1_' prefixed functions test the basic scenario of inlining
40 ; destroying dominator tree.
42 define void @test1_caller() {
43 ; CHECK-LABEL: define void @test1_caller()
52 ; The 'test2_' prefixed functions test the scenario of not inlining preserving
55 define void @test2_caller() {
56 ; CHECK-LABEL: define void @test2_caller()
58 call void @callee() noinline
59 ; CHECK: call void @callee
65 ; The 'test3_' prefixed functions test the scenario of not inlining preserving
66 ; dominators after splitting an SCC into two smaller SCCs.
68 ; This function ends up split into a separate SCC, which can cause its analyses
69 ; to become stale if the splitting doesn't properly invalidate things. Also, as
70 ; a consequence of being split out, test3_f is too large to inline by the time
72 define void @test3_g() {
73 ; CHECK-LABEL: define void @test3_g()
75 ; Create the second edge in the SCC cycle.
77 ; CHECK: call void @test3_f()
79 ; Pull interesting CFG into this function.
81 ; CHECK-NOT: call void @callee()
87 ; The second function gets visited first and we end up inlining everything we
88 ; can into this routine. That splits test3_g into a separate SCC that is enqued
89 ; for later processing.
90 define void @test3_f() {
91 ; CHECK-LABEL: define void @test3_f()
93 ; Create the first edge in the SCC cycle.
95 ; CHECK-NOT: @test3_g()
96 ; CHECK: call void @test3_f()
98 ; Pull interesting CFG into this function.
100 ; CHECK-NOT: call void @callee()