|
12 | 12 | ; ------------------------------------------------
|
13 | 13 |
|
14 | 14 | ; Pseudo-code:
|
| 15 | +; Before: |
15 | 16 | ; void foo()
|
16 | 17 | ; {
|
17 | 18 | ; st_foo a;
|
|
28 | 29 | ; {
|
29 | 30 | ; *out = {1, 2};
|
30 | 31 | ; }
|
| 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 | +; } |
31 | 50 |
|
32 | 51 | %struct._st_foo = type { i32, i32 }
|
33 | 52 |
|
34 | 53 | define spir_kernel void @foo() #1 {
|
35 | 54 | ; CHECK: define spir_kernel void @foo()
|
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 | 55 | %a = alloca %struct._st_foo
|
| 56 | +; CHECK-NEXT: [[A:%.*]] = alloca %struct._st_foo, align 8 |
41 | 57 | 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 |
42 | 65 | call void @consume(ptr %a)
|
| 66 | +; CHECK-NEXT: call void @consume(ptr [[A]]) |
43 | 67 | ret void
|
| 68 | +; CHECK-NEXT: ret void |
44 | 69 | }
|
45 | 70 | ; CHECK-NEXT: }
|
46 | 71 |
|
47 | 72 | define linkonce_odr spir_func void @bar_0(ptr sret(%struct._st_foo) %out) {
|
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 |
| 73 | +; CHECK: define linkonce_odr spir_func %struct._st_foo @bar_0() |
| 74 | +; CHECK-NEXT: [[OUT:%.*]] = alloca %struct._st_foo, align 8 |
51 | 75 | 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 |
52 | 83 | 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]] |
53 | 91 | }
|
54 | 92 | ; CHECK-NEXT: }
|
55 | 93 |
|
56 | 94 | define linkonce_odr spir_func void @bar_1(ptr sret(%struct._st_foo) %out) {
|
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 |
| 95 | +; CHECK: define linkonce_odr spir_func %struct._st_foo @bar_1() |
| 96 | +; CHECK-NEXT: [[OUT:%.*]] = alloca %struct._st_foo, align 8 |
60 | 97 | 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 |
61 | 99 | 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]] |
62 | 107 | }
|
63 | 108 | ; CHECK-NEXT: }
|
64 | 109 |
|
|
0 commit comments