[llvm-dev] Restrict global constructors to base ISA

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Mon Dec 3 11:30:57 PST 2018


On 12/1/2018 2:17 AM, Jeffrey Walton via llvm-dev wrote:
> I'm testing on older OS X 10.8 with older SSE4 hardware from about
> 2010. I've got updated gear from MacPorts and it includes GCC and
> Clang. GCC is the compiler, and Clang is the assembler.
>
> We perform a compile/link on a test file to ensure an ISA is supported
> by the toolchain. If an ISA is available then we compile a source file
> to the ISA as needed. Then, we guard the higher ISAs at runtime to
> avoid SIGILLs. It worked well until we added AVX2.
>
> For AVX2 we see this as expected:
>
>      $ CXX=/opt/local/bin/clang++-mp-5.0 make
>      /opt/local/bin/clang++-mp-5.0 ... -c chacha.cpp
>      /opt/local/bin/clang++-mp-5.0 ... -mavx2 -c chacha_avx.cpp
>      /opt/local/bin/clang++-mp-5.0 ... -msse2 -c chacha_simd.cpp
>      ...
>
> At runtime we catch a SIGILL due to chacha_avx.cpp as shown below. It
> looks like global constructors are using instructions from AVX
> (vxorps), which is beyond what the machine supports.
>
> How do we tell Clang to use the base ISA for global constructors?

There isn't any way to specifically restrict the ISA for global 
constructors/inline functions/etc.  The inverse works, though: you can 
specify the base ISA for the whole file, then mark specific functions 
using __attribute__((target("avx2"))).

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list