|
12 | 12 | ; ------------------------------------------------
|
13 | 13 |
|
14 | 14 | ; Pseudo-code:
|
15 |
| -; Before: |
16 | 15 | ; void foo()
|
17 | 16 | ; {
|
18 | 17 | ; st_foo a;
|
|
29 | 28 | ; {
|
30 | 29 | ; *out = {1, 2};
|
31 | 30 | ; }
|
32 |
| -; After: |
33 |
| -; void foo() |
34 |
| -; { |
35 |
| -; st_foo a; |
36 |
| -; a = bar_0(); |
37 |
| -; consume(&a); |
38 |
| -; } |
39 |
| -; |
40 |
| -; st_foo bar_0() |
41 |
| -; { |
42 |
| -; return bar_1(); |
43 |
| -; } |
44 |
| -; |
45 |
| -; st_foo bar_1(st_foo* in) |
46 |
| -; { |
47 |
| -; st_foo out = {1, 2}; |
48 |
| -; return out; |
49 |
| -; } |
50 | 31 |
|
51 | 32 | %struct._st_foo = type { i32, i32 }
|
52 | 33 |
|
53 | 34 | define spir_kernel void @foo() #1 {
|
54 | 35 | ; CHECK: define spir_kernel void @foo()
|
55 |
| - %a = alloca %struct._st_foo |
56 | 36 | ; CHECK-NEXT: [[A:%.*]] = alloca %struct._st_foo, align 8
|
| 37 | +; CHECK-NEXT: call void @bar_0(ptr sret(%struct._st_foo) [[A]]) |
| 38 | +; CHECK-NEXT: call void @consume(ptr [[A]]) |
| 39 | +; CHECK-NEXT: ret void |
| 40 | + %a = alloca %struct._st_foo |
57 | 41 | call void @bar_0(ptr sret(%struct._st_foo) %a)
|
58 |
| -; CHECK-NEXT: [[RET_BAR_0:%.*]] = call %struct._st_foo @bar_0() |
59 |
| -; CHECK-NEXT: [[M_0_PTR:%.*]] = getelementptr inbounds %struct._st_foo, ptr [[A]], i32 0, i32 0 |
60 |
| -; CHECK-NEXT: [[M_0:%.*]] = extractvalue %struct._st_foo [[RET_BAR_0]], 0 |
61 |
| -; CHECK-NEXT: store i32 [[M_0]], ptr [[M_0_PTR]], align 4 |
62 |
| -; CHECK-NEXT: [[M_1_PTR:%.*]] = getelementptr inbounds %struct._st_foo, ptr [[A]], i32 0, i32 1 |
63 |
| -; CHECK-NEXT: [[M_1:%.*]] = extractvalue %struct._st_foo [[RET_BAR_0]], 1 |
64 |
| -; CHECK-NEXT: store i32 [[M_1]], ptr [[M_1_PTR]], align 4 |
65 | 42 | call void @consume(ptr %a)
|
66 |
| -; CHECK-NEXT: call void @consume(ptr [[A]]) |
67 | 43 | ret void
|
68 |
| -; CHECK-NEXT: ret void |
69 | 44 | }
|
70 | 45 | ; CHECK-NEXT: }
|
71 | 46 |
|
72 | 47 | define linkonce_odr spir_func void @bar_0(ptr sret(%struct._st_foo) %out) {
|
73 |
| -; CHECK: define linkonce_odr spir_func %struct._st_foo @bar_0() |
74 |
| -; CHECK-NEXT: [[OUT:%.*]] = alloca %struct._st_foo, align 8 |
| 48 | +; CHECK: define linkonce_odr spir_func void @bar_0(ptr sret(%struct._st_foo) %out) { |
| 49 | +; CHECK-NEXT: call void @bar_1(ptr sret(%struct._st_foo) %out) |
| 50 | +; CHECK-NEXT: ret void |
75 | 51 | call void @bar_1(ptr sret(%struct._st_foo) %out)
|
76 |
| -; CHECK-NEXT: [[RET_BAR_1:%.*]] = call %struct._st_foo @bar_1() |
77 |
| -; CHECK-NEXT: [[M_0_PTR:%.*]] = getelementptr inbounds %struct._st_foo, ptr [[OUT]], i32 0, i32 0 |
78 |
| -; CHECK-NEXT: [[M_0:%.*]] = extractvalue %struct._st_foo [[RET_BAR_1]], 0 |
79 |
| -; CHECK-NEXT: store i32 [[M_0]], ptr [[M_0_PTR]], align 4 |
80 |
| -; CHECK-NEXT: [[M_1_PTR:%.*]] = getelementptr inbounds %struct._st_foo, ptr [[OUT]], i32 0, i32 1 |
81 |
| -; CHECK-NEXT: [[M_1:%.*]] = extractvalue %struct._st_foo [[RET_BAR_1]], 1 |
82 |
| -; CHECK-NEXT: store i32 [[M_1]], ptr [[M_1_PTR]], align 4 |
83 | 52 | ret void
|
84 |
| -; CHECK-NEXT: [[M_0_PTR:%.*]] = getelementptr inbounds %struct._st_foo, ptr [[OUT]], i32 0, i32 0 |
85 |
| -; CHECK-NEXT: [[M_0:%.*]] = load i32, ptr [[M_0_PTR]], align 4 |
86 |
| -; CHECK-NEXT: [[R_0:%.*]] = insertvalue %struct._st_foo undef, i32 [[M_0]], 0 |
87 |
| -; CHECK-NEXT: [[M_1_PTR:%.*]] = getelementptr inbounds %struct._st_foo, ptr [[OUT]], i32 0, i32 1 |
88 |
| -; CHECK-NEXT: [[M_1:%.*]] = load i32, ptr [[M_1_PTR]], align 4 |
89 |
| -; CHECK-NEXT: [[R_1:%.*]] = insertvalue %struct._st_foo [[R_0]], i32 [[M_1]], 1 |
90 |
| -; CHECK-NEXT: ret %struct._st_foo [[R_1]] |
91 | 53 | }
|
92 | 54 | ; CHECK-NEXT: }
|
93 | 55 |
|
94 | 56 | define linkonce_odr spir_func void @bar_1(ptr sret(%struct._st_foo) %out) {
|
95 |
| -; CHECK: define linkonce_odr spir_func %struct._st_foo @bar_1() |
96 |
| -; CHECK-NEXT: [[OUT:%.*]] = alloca %struct._st_foo, align 8 |
| 57 | +; CHECK: define linkonce_odr spir_func void @bar_1(ptr sret(%struct._st_foo) %out) { |
| 58 | +; CHECK-NEXT: store %struct._st_foo { i32 1, i32 2 }, ptr %out, align 4 |
| 59 | +; CHECK-NEXT: ret void |
97 | 60 | store %struct._st_foo { i32 1, i32 2 }, ptr %out, align 4
|
98 |
| -; CHECK-NEXT: store %struct._st_foo { i32 1, i32 2 }, ptr [[OUT]], align 4 |
99 | 61 | ret void
|
100 |
| -; CHECK-NEXT: [[M_0_PTR:%.*]] = getelementptr inbounds %struct._st_foo, ptr [[OUT]], i32 0, i32 0 |
101 |
| -; CHECK-NEXT: [[M_0:%.*]] = load i32, ptr [[M_0_PTR]], align 4 |
102 |
| -; CHECK-NEXT: [[R_0:%.*]] = insertvalue %struct._st_foo undef, i32 [[M_0]], 0 |
103 |
| -; CHECK-NEXT: [[M_1_PTR:%.*]] = getelementptr inbounds %struct._st_foo, ptr [[OUT]], i32 0, i32 1 |
104 |
| -; CHECK-NEXT: [[M_1:%.*]] = load i32, ptr [[M_1_PTR]], align 4 |
105 |
| -; CHECK-NEXT: [[R_1:%.*]] = insertvalue %struct._st_foo [[R_0]], i32 [[M_1]], 1 |
106 |
| -; CHECK-NEXT: ret %struct._st_foo [[R_1]] |
107 | 62 | }
|
108 | 63 | ; CHECK-NEXT: }
|
109 | 64 |
|
|
0 commit comments