tsan: switch from SSE3 to SSE4.2

Switch x86_64 requirement for optimized code from SSE3 to SSE4.2.
The new tsan runtime will need few instructions that are only
supported by SSE4:

_mm_max_epu32
_mm_extract_epi8
_mm_insert_epi32

SSE3 was introcued in 2004 and SSE4 in 2006:
https://en.wikipedia.org/wiki/SSE3
https://en.wikipedia.org/wiki/SSE4

We are still providing non-optimized C++ version of the code,
so either way it's possible to build tsan runtime for any CPU.

But for Go this will bump strict requirement for -race because
Go contains prebuilt versions and these will be built with -msse4.2.
But requiring a CPU produced at least in 2006 looks reasonable for
a debugging tool (more reasonable than disabling optimizations
for everybody).

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D106948
This commit is contained in:
Dmitry Vyukov 2021-07-28 13:40:21 +02:00
parent a1a37ddc3f
commit cd0143c0f2
3 changed files with 3 additions and 2 deletions

View File

@ -18,7 +18,7 @@ if(COMPILER_RT_TSAN_DEBUG_OUTPUT)
endif()
set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})
append_list_if(COMPILER_RT_HAS_MSSE3_FLAG -msse3 TSAN_RTL_CFLAGS)
append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 TSAN_RTL_CFLAGS)
append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=530
TSAN_RTL_CFLAGS)
append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors

View File

@ -58,4 +58,5 @@ gcc ^
-DSANITIZER_DEBUG=0 ^
-O3 ^
-fomit-frame-pointer ^
-msse4.2 ^
-std=c++14

View File

@ -58,7 +58,7 @@ if [ "`uname -a | grep Linux`" != "" ]; then
ARCHCFLAGS="-m64 -mcpu=power8 -fno-function-sections"
elif [ "`uname -a | grep x86_64`" != "" ]; then
SUFFIX="linux_amd64"
ARCHCFLAGS="-m64 -msse3"
ARCHCFLAGS="-m64 -msse4.2"
OSCFLAGS="$OSCFLAGS -ffreestanding -Wno-unused-const-variable -Werror -Wno-unknown-warning-option"
elif [ "`uname -a | grep aarch64`" != "" ]; then
SUFFIX="linux_arm64"