summaryrefslogtreecommitdiff
path: root/bolt/runtime
diff options
context:
space:
mode:
authorElvina Yakubova <elvina.yakubova@huawei.com>2022-07-06 08:19:22 +0300
committerElvina Yakubova <elvina.yakubova@huawei.com>2022-07-06 08:19:54 +0300
commit35155a0716784c54b9d0113bce3f12c62af91a70 (patch)
tree7b56a54cc6de9335437186885472ac4cee559bd4 /bolt/runtime
parent484b4f3579808386b6b9314be1e841ffe3d769a6 (diff)
downloadllvm-35155a0716784c54b9d0113bce3f12c62af91a70.tar.gz
[BOLT] Change mutex implementation
Changed acquire implemetaion to __atomic_test_and_set() and release to __atomic_clear() so it eliminates inline asm usage and is arch independent. Elvina Yakubova, Advanced Software Technology Lab, Huawei Reviewers: yota9, maksfb, rafauler Differential Revision: https://reviews.llvm.org/D129162
Diffstat (limited to 'bolt/runtime')
-rw-r--r--bolt/runtime/common.h9
1 files changed, 2 insertions, 7 deletions
diff --git a/bolt/runtime/common.h b/bolt/runtime/common.h
index f13cde9b2e98..b1e39e5f3e95 100644
--- a/bolt/runtime/common.h
+++ b/bolt/runtime/common.h
@@ -468,17 +468,12 @@ void assert(bool Assertion, const char *Msg) {
reportError(Buf, Ptr - Buf);
}
-/// 1B mutex accessed by lock xchg
class Mutex {
volatile bool InUse{false};
public:
- bool acquire() {
- bool Result = true;
- asm volatile("lock; xchg %0, %1" : "+m"(InUse), "=r"(Result) : : "cc");
- return !Result;
- }
- void release() { InUse = false; }
+ bool acquire() { return !__atomic_test_and_set(&InUse, __ATOMIC_ACQUIRE); }
+ void release() { __atomic_clear(&InUse, __ATOMIC_RELEASE); }
};
/// RAII wrapper for Mutex