[compiler-rt] r190589 - [asan] use xchg instead of CAS in FakeStack::Allocate (5% faster for this case)
Kostya Serebryany
kcc at google.com
Thu Sep 12 00:28:43 PDT 2013
Author: kcc
Date: Thu Sep 12 02:28:42 2013
New Revision: 190589
URL: http://llvm.org/viewvc/llvm-project?rev=190589&view=rev
Log:
[asan] use xchg instead of CAS in FakeStack::Allocate (5% faster for this case)
Modified:
compiler-rt/trunk/lib/asan/asan_fake_stack.cc
Modified: compiler-rt/trunk/lib/asan/asan_fake_stack.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_fake_stack.cc?rev=190589&r1=190588&r2=190589&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_fake_stack.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_fake_stack.cc Thu Sep 12 02:28:42 2013
@@ -31,10 +31,9 @@ FakeFrame *FakeStack::Allocate(uptr stac
for (int i = 0; i < num_iter; i++) {
uptr pos = ModuloNumberOfFrames(stack_size_log, class_id, hint_position++);
if (flags[pos]) continue;
- u8 zero = 0;
// FIXME: this does not have to be thread-safe, just async-signal-safe.
- if (atomic_compare_exchange_strong((atomic_uint8_t *)&flags[pos], &zero, 1,
- memory_order_acquire)) {
+ if (0 == atomic_exchange((atomic_uint8_t *)&flags[pos], 1,
+ memory_order_relaxed)) {
FakeFrame *res = reinterpret_cast<FakeFrame *>(
GetFrame(stack_size_log, class_id, pos));
res->real_stack = real_stack;
More information about the llvm-commits
mailing list