@@ -162,6 +162,7 @@ detect_cpuid_maxleaf(void)
162162static inline void
163163detect_cpuid_features (py_cpuid_features * flags , CPUID_REG ecx , CPUID_REG edx )
164164{
165+ assert (flags -> maxleaf >= 1 );
165166 // Keep the ordering and newlines as they are declared in the structure.
166167#ifdef SIMD_SSE_INSTRUCTIONS_DETECTION_GUARD
167168#ifdef Py_CAN_COMPILE_SIMD_SSE_INSTRUCTIONS
@@ -206,6 +207,7 @@ static inline void
206207detect_cpuid_extended_features_L7S0 (py_cpuid_features * flags ,
207208 CPUID_REG ebx , CPUID_REG ecx , CPUID_REG edx )
208209{
210+ assert (flags -> maxleaf >= 7 );
209211 (void )ebx , (void )ecx , (void )edx ; // to suppress unused warnings
210212 // Keep the ordering and newlines as they are declared in the structure.
211213#ifdef SIMD_AVX2_INSTRUCTIONS_DETECTION_GUARD
@@ -282,6 +284,7 @@ detect_cpuid_extended_features_L7S1(py_cpuid_features *flags,
282284 CPUID_REG ecx ,
283285 CPUID_REG edx )
284286{
287+ assert (flags -> maxleaf >= 7 );
285288 (void )eax , (void )ebx , (void )ecx , (void )edx ; // to suppress unused warnings
286289 // Keep the ordering and newlines as they are declared in the structure.
287290#ifdef SIMD_AVX_INSTRUCTIONS_DETECTION_GUARD
@@ -309,6 +312,7 @@ static inline void
309312detect_cpuid_xsave_state (py_cpuid_features * flags )
310313{
311314 // Keep the ordering and newlines as they are declared in the structure.
315+ assert (flags -> maxleaf >= 1 );
312316#ifdef HAS_XGETBV_SUPPORT
313317 uint64_t xcr0 = flags -> osxsave ? get_xgetbv (0 ) : 0 ;
314318 flags -> xcr0_sse = XSAVE_CHECK_REG (xcr0 , XCR0_SSE );
@@ -501,6 +505,7 @@ cpuid_detect_l1_features(py_cpuid_features *flags)
501505static inline void
502506cpuid_detect_l7s0_features (py_cpuid_features * flags )
503507{
508+ assert (flags -> maxleaf >= 7 );
504509 CPUID_REG eax = 0 , ebx = 0 , ecx = 0 , edx = 0 ;
505510 get_cpuid_info (7 , 0 , & eax , & ebx , & ecx , & edx );
506511 detect_cpuid_extended_features_L7S0 (flags , ebx , ecx , edx );
@@ -513,6 +518,7 @@ cpuid_detect_l7s0_features(py_cpuid_features *flags)
513518static inline void
514519cpuid_detect_l7s1_features (py_cpuid_features * flags )
515520{
521+ assert (flags -> maxleaf >= 7 );
516522 CPUID_REG eax = 0 , ebx = 0 , ecx = 0 , edx = 0 ;
517523 get_cpuid_info (7 , 1 , & eax , & ebx , & ecx , & edx );
518524 detect_cpuid_extended_features_L7S1 (flags , eax , ebx , ecx , edx );
0 commit comments