Commit b527b4a
committed
race: Relax success ordering from
See the analogous change in rust-lang/rust#131746 and
the discussion in matklad#220.
What is the effect of this change? Consider this example:
```diff
#[no_mangle]
fn foo1(y: &mut i32) -> bool {
- let r = X.compare_exchange(0, 1, Ordering::AcqRel, Ordering::Acquire).is_ok();
+ let r = X.compare_exchange(0, 1, Ordering::Release, Ordering::Acquire).is_ok();
r
}
```
On x86_64, there is no change. Here is the generated code before and after:
```
foo1:
mov rcx, qword ptr [rip + example::X::h9e1b81da80078af7@GOTPCREL]
mov edx, 1
xor eax, eax
lock cmpxchg dword ptr [rcx], edx
sete al
ret
example::X::h9e1b81da80078af7:
.zero 4
```
On AArch64, regardless of whether atomics are outlined or not, there is no change. Here
is the generated code with inlined atomics:
```
foo1:
adrp x8, :got:example::X::h40b04fb69d714de3
ldr x8, [x8, :got_lo12:example::X::h40b04fb69d714de3]
.LBB0_1:
ldaxr w9, [x8]
cbnz w9, .LBB0_4
mov w0, matklad#1
stlxr w9, w0, [x8]
cbnz w9, .LBB0_1
ret
.LBB0_4:
mov w0, wzr
clrex
ret
example::X::h40b04fb69d714de3:
.zero 4
```
For 32-bit ARMv7, with inlined atomics, the resulting diff in the object code is:
```diff
@@ -10,14 +10,13 @@
mov r0, matklad#1
strex r2, r0, [r1]
cmp r2, #0
- beq .LBB0_5
+ bxeq lr
ldrex r0, [r1]
cmp r0, #0
beq .LBB0_2
.LBB0_4:
- mov r0, #0
clrex
-.LBB0_5:
+ mov r0, #0
dmb ish
bx lr
.LCPI0_0:
@@ -54,4 +53,3 @@
example::X::h47e2038445e1c648:
.zero 4
```AcqRel to Release.1 parent 0d6bc31 commit b527b4a
1 file changed
Lines changed: 42 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
84 | 90 | | |
85 | | - | |
| 91 | + | |
86 | 92 | | |
87 | 93 | | |
88 | 94 | | |
| |||
128 | 134 | | |
129 | 135 | | |
130 | 136 | | |
131 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
132 | 144 | | |
133 | 145 | | |
134 | 146 | | |
| |||
241 | 253 | | |
242 | 254 | | |
243 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
244 | 262 | | |
245 | | - | |
| 263 | + | |
246 | 264 | | |
247 | 265 | | |
248 | 266 | | |
| |||
282 | 300 | | |
283 | 301 | | |
284 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
285 | 309 | | |
286 | 310 | | |
287 | 311 | | |
288 | | - | |
| 312 | + | |
289 | 313 | | |
290 | 314 | | |
291 | 315 | | |
| |||
377 | 401 | | |
378 | 402 | | |
379 | 403 | | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
380 | 410 | | |
381 | 411 | | |
382 | 412 | | |
383 | | - | |
| 413 | + | |
384 | 414 | | |
385 | 415 | | |
386 | 416 | | |
| |||
423 | 453 | | |
424 | 454 | | |
425 | 455 | | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
426 | 462 | | |
427 | 463 | | |
428 | 464 | | |
429 | | - | |
| 465 | + | |
430 | 466 | | |
431 | 467 | | |
432 | 468 | | |
| |||
0 commit comments