Skip to content

Commit 823625c

Browse files
authored
[nfc][tsan] Simplify morder conversion (llvm#115075)
All valid values should fit into a byte. This slightly reduce generated code on x86_64.
1 parent a353e25 commit 823625c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,9 @@ static morder to_morder(int mo) {
515515
// since we use __sync_ atomics for actual atomic operations,
516516
// we can safely ignore it as well. It also subtly affects semantics,
517517
// but we don't model the difference.
518-
return static_cast<morder>(mo & 0x7fff);
518+
morder res = static_cast<morder>(static_cast<u8>(mo));
519+
DCHECK_LE(res, mo_seq_cst);
520+
return res;
519521
}
520522

521523
# define ATOMIC_IMPL(func, mo, ...) \

0 commit comments

Comments
 (0)