llvm.org GIT mirror llvm / 00666a1
Reverse ordering of base and derived pointer during safepoint lowering. According to the documentation in StackMap section for the safepoint we should have: "The first Location in each pair describes the base pointer for the object. The second is the derived pointer actually being relocated." But before this change we emitted them in reverse order - derived pointer first, base pointer second. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237126 91177308-0d34-0410-b5e6-96231b3b80d8 Igor Laevsky 5 years ago
3 changed file(s) with 168 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
472472 SDValue Incoming = Builder.getValue(V);
473473 reservePreviousStackSlotForValue(Incoming, Builder);
474474 }
475 for (unsigned i = 0; i < Bases.size() * 2; ++i) {
476 // Even elements will contain base, odd elements - derived ptr
477 const Value *V = i % 2 ? Bases[i / 2] : Ptrs[i / 2];
478 SDValue Incoming = Builder.getValue(V);
479 reservePreviousStackSlotForValue(Incoming, Builder);
475 for (unsigned i = 0; i < Bases.size(); ++i) {
476 const Value *Base = Bases[i];
477 reservePreviousStackSlotForValue(Builder.getValue(Base), Builder);
478
479 const Value *Ptr = Ptrs[i];
480 reservePreviousStackSlotForValue(Builder.getValue(Ptr), Builder);
480481 }
481482
482483 // First, prefix the list with the number of unique values to be
511512 // arrays interwoven with each (lowered) base pointer immediately followed by
512513 // it's (lowered) derived pointer. i.e
513514 // (base[0], ptr[0], base[1], ptr[1], ...)
514 for (unsigned i = 0; i < Bases.size() * 2; ++i) {
515 // Even elements will contain base, odd elements - derived ptr
516 const Value *V = i % 2 ? Bases[i / 2] : Ptrs[i / 2];
517 SDValue Incoming = Builder.getValue(V);
518 lowerIncomingStatepointValue(Incoming, Ops, Builder);
515 for (unsigned i = 0; i < Bases.size(); ++i) {
516 const Value *Base = Bases[i];
517 lowerIncomingStatepointValue(Builder.getValue(Base), Ops, Builder);
518
519 const Value *Ptr = Ptrs[i];
520 lowerIncomingStatepointValue(Builder.getValue(Ptr), Ops, Builder);
519521 }
520522
521523 // If there are any explicit spill slots passed to the statepoint, record
1010 define i32 @back_to_back_calls(i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c) #1 gc "statepoint-example" {
1111 ; CHECK-LABEL: back_to_back_calls
1212 ; The exact stores don't matter, but there need to be three stack slots created
13 ; CHECK: movq %rdx, 16(%rsp)
14 ; CHECK: movq %rdi, 8(%rsp)
13 ; CHECK: movq %rdi, 16(%rsp)
14 ; CHECK: movq %rdx, 8(%rsp)
1515 ; CHECK: movq %rsi, (%rsp)
1616 %safepoint_token = tail call i32 (void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* undef, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0, i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c)
1717 %a1 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 10, i32 10)
3333 define i32 @reserve_first(i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c) #1 gc "statepoint-example" {
3434 ; CHECK-LABEL: reserve_first
3535 ; The exact stores don't matter, but there need to be three stack slots created
36 ; CHECK: movq %rdx, 16(%rsp)
37 ; CHECK: movq %rdi, 8(%rsp)
36 ; CHECK: movq %rdi, 16(%rsp)
37 ; CHECK: movq %rdx, 8(%rsp)
3838 ; CHECK: movq %rsi, (%rsp)
3939 %safepoint_token = tail call i32 (void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* undef, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0, i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c)
4040 %a1 = tail call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 10, i32 10)
77
88 declare zeroext i1 @return_i1()
99
10 define i1 @test(i32 addrspace(1)* %ptr) gc "statepoint-example" {
10 define i1 @test(i32 addrspace(1)* %ptr_base, i32 %arg)
11 gc "statepoint-example" {
1112 ; CHECK-LABEL: test
12 ; Do we see one spill for the local value and the store to the
13 ; Do we see two spills for the local values and the store to the
1314 ; alloca?
14 ; CHECK: subq $24, %rsp
15 ; CHECK: movq $0, 8(%rsp)
16 ; CHECK: movq %rdi, (%rsp)
15 ; CHECK: subq $40, %rsp
16 ; CHECK: movq $0, 24(%rsp)
17 ; CHECK: movq %rdi, 16(%rsp)
18 ; CHECK: movq %rax, 8(%rsp)
1719 ; CHECK: callq return_i1
18 ; CHECK: addq $24, %rsp
20 ; CHECK: addq $40, %rsp
1921 ; CHECK: retq
2022 entry:
2123 %metadata1 = alloca i32 addrspace(1)*, i32 2, align 8
2224 store i32 addrspace(1)* null, i32 addrspace(1)** %metadata1
23 %safepoint_token = tail call i32 (i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 2, i32 addrspace(1)* %ptr, i32 addrspace(1)* null, i32 addrspace(1)* %ptr, i32 addrspace(1)* null)
25 %ptr_derived = getelementptr i32, i32 addrspace(1)* %ptr_base, i32 %arg
26 %safepoint_token = tail call i32 (i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 2, i32 addrspace(1)* %ptr_base, i32 addrspace(1)* null, i32 addrspace(1)* %ptr_base, i32 addrspace(1)* %ptr_derived, i32 addrspace(1)* null)
2427 %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(i32 %safepoint_token)
2528 %a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 7, i32 7)
26 %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 8, i32 8)
29 %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 7, i32 8)
30 %c = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 9)
2731 ;
2832 ret i1 %call1
2933 }
3034
35 ; This is similar to the previous test except that we have derived pointer as
36 ; argument to the function. Despite that this can not happen after the
37 ; RewriteSafepointForGC pass, lowering should be able to handle it anyway.
38 define i1 @test_derived_arg(i32 addrspace(1)* %ptr_base,
39 i32 addrspace(1)* %ptr_derived)
40 gc "statepoint-example" {
41 ; CHECK-LABEL: test_derived_arg
42 ; Do we see two spills for the local values and the store to the
43 ; alloca?
44 ; CHECK: subq $40, %rsp
45 ; CHECK: movq $0, 24(%rsp)
46 ; CHECK: movq %rdi, 16(%rsp)
47 ; CHECK: movq %rsi, 8(%rsp)
48 ; CHECK: callq return_i1
49 ; CHECK: addq $40, %rsp
50 ; CHECK: retq
51 entry:
52 %metadata1 = alloca i32 addrspace(1)*, i32 2, align 8
53 store i32 addrspace(1)* null, i32 addrspace(1)** %metadata1
54 %safepoint_token = tail call i32 (i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 2, i32 addrspace(1)* %ptr_base, i32 addrspace(1)* null, i32 addrspace(1)* %ptr_base, i32 addrspace(1)* %ptr_derived, i32 addrspace(1)* null)
55 %call1 = call zeroext i1 @llvm.experimental.gc.result.i1(i32 %safepoint_token)
56 %a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 7, i32 7)
57 %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 7, i32 8)
58 %c = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32 %safepoint_token, i32 9, i32 9)
59 ;
60 ret i1 %call1
61 }
62
63
3164 declare i32 @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()*, i32, i32, ...)
3265 declare i1 @llvm.experimental.gc.result.i1(i32)
3366 declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(i32, i32, i32) #3
34
3567
3668 ; CHECK-LABEL: .section .llvm_stackmaps
3769 ; CHECK-NEXT: __LLVM_StackMaps:
4072 ; CHECK-NEXT: .byte 0
4173 ; CHECK-NEXT: .short 0
4274 ; Num Functions
43 ; CHECK-NEXT: .long 1
75 ; CHECK-NEXT: .long 2
4476 ; Num LargeConstants
4577 ; CHECK-NEXT: .long 0
4678 ; Num Callsites
47 ; CHECK-NEXT: .long 1
79 ; CHECK-NEXT: .long 2
4880
4981 ; Functions and stack size
5082 ; CHECK-NEXT: .quad test
51 ; CHECK-NEXT: .quad 24
83 ; CHECK-NEXT: .quad 40
84 ; CHECK-NEXT: .quad test_derived_arg
85 ; CHECK-NEXT: .quad 40
86
87 ;
88 ; test
89 ;
5290
5391 ; Large Constants
5492 ; Statepoint ID only
5896 ; Constant arguments
5997 ; CHECK: .long .Ltmp1-test
6098 ; CHECK: .short 0
61 ; CHECK: .short 8
99 ; CHECK: .short 10
62100 ; SmallConstant (0)
63101 ; CHECK: .byte 4
64102 ; CHECK: .byte 8
73111 ; CHECK: .byte 2
74112 ; CHECK: .byte 8
75113 ; CHECK: .short 7
76 ; CHECK: .long 0
77 ; SmallConstant (0)
78 ; CHECK: .byte 4
79 ; CHECK: .byte 8
80 ; CHECK: .short 0
81 ; CHECK: .long 0
82 ; SmallConstant (0)
83 ; CHECK: .byte 4
84 ; CHECK: .byte 8
85 ; CHECK: .short 0
86 ; CHECK: .long 0
87 ; SmallConstant (0)
88 ; CHECK: .byte 4
89 ; CHECK: .byte 8
90 ; CHECK: .short 0
91 ; CHECK: .long 0
114 ; CHECK: .long 16
115 ; SmallConstant (0)
116 ; CHECK: .byte 4
117 ; CHECK: .byte 8
118 ; CHECK: .short 0
119 ; CHECK: .long 0
120 ; SmallConstant (0)
121 ; CHECK: .byte 4
122 ; CHECK: .byte 8
123 ; CHECK: .short 0
124 ; CHECK: .long 0
125 ; SmallConstant (0)
126 ; CHECK: .byte 4
127 ; CHECK: .byte 8
128 ; CHECK: .short 0
129 ; CHECK: .long 0
130 ; Direct Spill Slot [RSP+16]
131 ; CHECK: .byte 2
132 ; CHECK: .byte 8
133 ; CHECK: .short 7
134 ; CHECK: .long 16
135 ; Direct Spill Slot [RSP+8]
136 ; CHECK: .byte 2
137 ; CHECK: .byte 8
138 ; CHECK: .short 7
139 ; CHECK: .long 8
140 ; Direct Spill Slot [RSP+16]
141 ; CHECK: .byte 2
142 ; CHECK: .byte 8
143 ; CHECK: .short 7
144 ; CHECK: .long 16
145 ; Direct Spill Slot [RSP+16]
146 ; CHECK: .byte 2
147 ; CHECK: .byte 8
148 ; CHECK: .short 7
149 ; CHECK: .long 16
150
151 ; No Padding or LiveOuts
152 ; CHECK: .short 0
153 ; CHECK: .short 0
154 ; CHECK: .align 8
155
156 ;
157 ; test_derived_arg
158 ;
159
160 ; Large Constants
161 ; Statepoint ID only
162 ; CHECK: .quad 2882400000
163
164 ; Callsites
165 ; Constant arguments
166 ; CHECK: .long .Ltmp3-test_derived_arg
167 ; CHECK: .short 0
168 ; CHECK: .short 10
169 ; SmallConstant (0)
170 ; CHECK: .byte 4
171 ; CHECK: .byte 8
172 ; CHECK: .short 0
173 ; CHECK: .long 0
174 ; SmallConstant (2)
175 ; CHECK: .byte 4
176 ; CHECK: .byte 8
177 ; CHECK: .short 0
178 ; CHECK: .long 2
92179 ; Direct Spill Slot [RSP+0]
93180 ; CHECK: .byte 2
94181 ; CHECK: .byte 8
95182 ; CHECK: .short 7
96 ; CHECK: .long 0
97 ; Direct Spill Slot [RSP+0]
98 ; CHECK: .byte 2
99 ; CHECK: .byte 8
100 ; CHECK: .short 7
101 ; CHECK: .long 0
183 ; CHECK: .long 16
184 ; SmallConstant (0)
185 ; CHECK: .byte 4
186 ; CHECK: .byte 8
187 ; CHECK: .short 0
188 ; CHECK: .long 0
189 ; SmallConstant (0)
190 ; CHECK: .byte 4
191 ; CHECK: .byte 8
192 ; CHECK: .short 0
193 ; CHECK: .long 0
194 ; SmallConstant (0)
195 ; CHECK: .byte 4
196 ; CHECK: .byte 8
197 ; CHECK: .short 0
198 ; CHECK: .long 0
199 ; Direct Spill Slot [RSP+16]
200 ; CHECK: .byte 2
201 ; CHECK: .byte 8
202 ; CHECK: .short 7
203 ; CHECK: .long 16
204 ; Direct Spill Slot [RSP+8]
205 ; CHECK: .byte 2
206 ; CHECK: .byte 8
207 ; CHECK: .short 7
208 ; CHECK: .long 8
209 ; Direct Spill Slot [RSP+16]
210 ; CHECK: .byte 2
211 ; CHECK: .byte 8
212 ; CHECK: .short 7
213 ; CHECK: .long 16
214 ; Direct Spill Slot [RSP+16]
215 ; CHECK: .byte 2
216 ; CHECK: .byte 8
217 ; CHECK: .short 7
218 ; CHECK: .long 16
102219
103220 ; No Padding or LiveOuts
104221 ; CHECK: .short 0
105222 ; CHECK: .short 0
106223 ; CHECK: .align 8
107
108