diff --git a/compiler-rt/lib/builtins/cpu_model/x86.c b/compiler-rt/lib/builtins/cpu_model/x86.c index 7ddfaa3e3ed6c..d9ff116cdc292 100644 --- a/compiler-rt/lib/builtins/cpu_model/x86.c +++ b/compiler-rt/lib/builtins/cpu_model/x86.c @@ -36,14 +36,14 @@ enum VendorSignatures { SIG_AMD = 0x68747541, // Auth }; -enum ProcessorVendors { +enum ProcessorVendors : unsigned int { VENDOR_INTEL = 1, VENDOR_AMD, VENDOR_OTHER, VENDOR_MAX }; -enum ProcessorTypes { +enum ProcessorTypes : unsigned int { INTEL_BONNELL = 1, INTEL_CORE2, INTEL_COREI7, @@ -319,11 +319,9 @@ static void detectX86FamilyModel(unsigned EAX, unsigned *Family, #define testFeature(F) (Features[F / 32] & (1 << (F % 32))) != 0 -static const char *getIntelProcessorTypeAndSubtype(unsigned Family, - unsigned Model, - const unsigned *Features, - unsigned *Type, - unsigned *Subtype) { +static const char *getIntelProcessorTypeAndSubtype( + unsigned Family, unsigned Model, const unsigned *Features, + enum ProcessorTypes *Type, enum ProcessorSubtypes *Subtype) { // We select CPU strings to match the code in Host.cpp, but we don't use them // in compiler-rt. const char *CPU = 0; @@ -616,8 +614,7 @@ static const char *getIntelProcessorTypeAndSubtype(unsigned Family, // Clearwaterforest: case 0xdd: CPU = "clearwaterforest"; - *Type = INTEL_COREI7; - *Subtype = INTEL_CLEARWATERFOREST; + *Type = INTEL_CLEARWATERFOREST; break; case 0x57: @@ -667,11 +664,9 @@ static const char *getIntelProcessorTypeAndSubtype(unsigned Family, return CPU; } -static const char *getAMDProcessorTypeAndSubtype(unsigned Family, - unsigned Model, - const unsigned *Features, - unsigned *Type, - unsigned *Subtype) { +static const char *getAMDProcessorTypeAndSubtype( + unsigned Family, unsigned Model, const unsigned *Features, + enum ProcessorTypes *Type, enum ProcessorSubtypes *Subtype) { const char *CPU = 0; switch (Family) { @@ -1162,11 +1157,14 @@ __attribute__((visibility("hidden"))) #endif struct __processor_model { unsigned int __cpu_vendor; - unsigned int __cpu_type; - unsigned int __cpu_subtype; + enum ProcessorTypes __cpu_type; + enum ProcessorSubtypes __cpu_subtype; unsigned int __cpu_features[1]; } __cpu_model = {0, 0, 0, {0}}; +static_assert(sizeof(__cpu_model) == 16, + "Wrong size of __cpu_model will result in ABI break"); + #ifndef _WIN32 __attribute__((visibility("hidden"))) #endif