On Mon, Aug 24, 2020 at 3:23 PM H.J. Lu <hjl.to...@gmail.com> wrote: > > Speaking of pragmas, these should be added outside cpuid.h, like: > > > > #pragma GCC push_options > > #pragma GCC target("general-regs-only") > > > > #include <cpuid.h> > > > > void cpuid_check () > > ... > > > > #pragma GCC pop_options > > > > >footnote > > > > Nowadays, -march=native is mostly used outside generic target > > compilations, so for relevant avx512 targets, we still generate spills > > to mask regs. In future, we can review the setting of the tuning flag > > for a generic target in the same way as with SSE2 inter-reg moves. > > > > Florian raised an issue that we need to limit <cpuid.h> to the basic ISAs. > <cpuid.h> should be handled similarly to other intrinsic header files. > That is <cpuid.h> should use > > #pragma GCC push_options > #ifdef __x86_64__ > #pragma GCC target("arch=x86-64") > #else > #pragma GCC target("arch=i386") > ... > #pragma GCC pop_options > > Here is a patch. OK for master?
-ENOPATCH However, how will this affect inlining? Every single function in cpuid.h is defined as static __inline, and due to target flags mismatch, it won't be inlined anymore. These inline functions are used in some bit testing functions, and to keep them inlined, these should also use the same options to avoid non-basic ISAs. This is the reason cpuid.h should be #included after pragma, together with bit testing functions, as shown above. Uros.