This is NOOP in x86_64.
On arch64 it avoids Data Memory Barrier with visible improvements on micro benchmarks.
Details
- Reviewers
dvyukov - Commits
- rG948b91a08e17: [NFC][sanitizer] Atomix relaxed in TwoLevelMap
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h | ||
---|---|---|
128 | The new code is incorrect. So I would add an explanatory comment that this is intentional and why we assume this will work in practice. Otherwise the next maintainer may revert this. | |
154 | I assume this part does not affect performance, right? And the store side has much higher chances of causing real problems. So I would keep the release here. |
LGTM with a nit
compiler-rt/lib/sanitizer_common/sanitizer_flat_map.h | ||
---|---|---|
133 | The problem is with the other case: the load returns non-nullptr, but we don't have proper visibility over the returned memory. This code needs to use memory_order_acquire/consume, but we use memory_order_relaxed for performance reasons (matters for arm64). We expect memory_order_relaxed to be effectively equivalent to memory_order_consume in this case for all relevant architectures: all dependent data is reachable only by dereferencing the resulting pointer. |
The new code is incorrect. So I would add an explanatory comment that this is intentional and why we assume this will work in practice. Otherwise the next maintainer may revert this.