[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used
Michał Górny via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 4 10:24:08 PST 2017
mgorny created this revision.
Herald added a subscriber: emaste.
Set the maximum width of atomic operations on x86-32 based on the target
CPU. The 64-bit inline atomics require cmpxchg8b which is an i586
instruction. Other inline atomics require cmpxchg which is an i486
instruction.
This fixes the incorrect value of __GCC_ATOMIC_LLONG_LOCK_FREE
and __atomic_always_lock_free() on FreeBSD where clang defaults to i486
CPU (PR#31864).
TODO: one CUDA test is broken:
/home/mgorny/llvm/_build/./bin/clang --cuda-host-only -nocudainc -target x86_64-windows-msvc -x cuda -E -dM -o - /dev/null | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' | grep -v '__LDBL\|_LONG_DOUBLE' > /home/mgorny/llvm/_build/tools/clang/test/Preprocessor/Output/x86_64-msvc-host-defines-filtered
/home/mgorny/llvm/_build/./bin/clang --cuda-device-only -nocudainc -nocudalib -target x86_64-windows-msvc -x cuda -E -dM -o - /dev/null | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' | grep -v '__LDBL\|_LONG_DOUBLE' > /home/mgorny/llvm/_build/tools/clang/test/Preprocessor/Output/x86_64-msvc-device-defines-filtered
diff /home/mgorny/llvm/_build/tools/clang/test/Preprocessor/Output/x86_64-msvc-host-defines-filtered /home/mgorny/llvm/_build/tools/clang/test/Preprocessor/Output/x86_64-msvc-device-defines-filtered
--
Exit Code: 1
Command Output (stdout):
--
9,17c9,17
< #define __GCC_ATOMIC_BOOL_LOCK_FREE 2
< #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
< #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
< #define __GCC_ATOMIC_CHAR_LOCK_FREE 2
< #define __GCC_ATOMIC_INT_LOCK_FREE 2
< #define __GCC_ATOMIC_LLONG_LOCK_FREE 2
< #define __GCC_ATOMIC_LONG_LOCK_FREE 2
< #define __GCC_ATOMIC_POINTER_LOCK_FREE 2
< #define __GCC_ATOMIC_SHORT_LOCK_FREE 2
---
> #define __GCC_ATOMIC_BOOL_LOCK_FREE 1
> #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1
> #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1
> #define __GCC_ATOMIC_CHAR_LOCK_FREE 1
> #define __GCC_ATOMIC_INT_LOCK_FREE 1
> #define __GCC_ATOMIC_LLONG_LOCK_FREE 1
> #define __GCC_ATOMIC_LONG_LOCK_FREE 1
> #define __GCC_ATOMIC_POINTER_LOCK_FREE 1
> #define __GCC_ATOMIC_SHORT_LOCK_FREE 1
19c19
< #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
---
> #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1
--
Could someone help me figure out what is the cause and correct solution to that failure? @jlebar?
Repository:
rL LLVM
https://reviews.llvm.org/D29542
Files:
lib/Basic/Targets.cpp
test/CodeGen/atomic-ops.c
test/CodeGen/ms-volatile.c
test/CodeGenCXX/atomicinit.cpp
test/Sema/atomic-ops.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29542.87098.patch
Type: text/x-patch
Size: 7615 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170204/6b5586a0/attachment.bin>
More information about the cfe-commits
mailing list