[compiler-rt] [Compiler-rt] Fix wrong assignment in compiler_rt (PR #164713)
    Mikołaj Piróg via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Oct 23 04:23:51 PDT 2025
    
    
  
https://github.com/mikolaj-pirog updated https://github.com/llvm/llvm-project/pull/164713
>From 12cad6c7732ad7a28127c0a196d7351865df1516 Mon Sep 17 00:00:00 2001
From: "Pirog, Mikolaj Maciej" <mikolaj.maciej.pirog at intel.com>
Date: Thu, 23 Oct 2025 13:20:18 +0200
Subject: [PATCH 1/2] Fix wrong assignment in compiler_rt
---
 compiler-rt/lib/builtins/cpu_model/x86.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/compiler-rt/lib/builtins/cpu_model/x86.c b/compiler-rt/lib/builtins/cpu_model/x86.c
index 7ddfaa3e3ed6c..424767659e970 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,
@@ -322,8 +322,8 @@ static void detectX86FamilyModel(unsigned EAX, unsigned *Family,
 static const char *getIntelProcessorTypeAndSubtype(unsigned Family,
                                                    unsigned Model,
                                                    const unsigned *Features,
-                                                   unsigned *Type,
-                                                   unsigned *Subtype) {
+                                                   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 +616,7 @@ static const char *getIntelProcessorTypeAndSubtype(unsigned Family,
     // Clearwaterforest:
     case 0xdd:
       CPU = "clearwaterforest";
-      *Type = INTEL_COREI7;
-      *Subtype = INTEL_CLEARWATERFOREST;
+      *Type = INTEL_CLEARWATERFOREST;
       break;
 
     case 0x57:
@@ -670,8 +669,8 @@ static const char *getIntelProcessorTypeAndSubtype(unsigned Family,
 static const char *getAMDProcessorTypeAndSubtype(unsigned Family,
                                                  unsigned Model,
                                                  const unsigned *Features,
-                                                 unsigned *Type,
-                                                 unsigned *Subtype) {
+                                                 enum ProcessorTypes *Type,
+                                                 enum ProcessorSubtypes *Subtype) {
   const char *CPU = 0;
 
   switch (Family) {
@@ -1162,11 +1161,13 @@ __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
>From 13d3602f44486517de913eef24581c2a8ee00edc Mon Sep 17 00:00:00 2001
From: "Pirog, Mikolaj Maciej" <mikolaj.maciej.pirog at intel.com>
Date: Thu, 23 Oct 2025 13:23:40 +0200
Subject: [PATCH 2/2] Formatting
---
 compiler-rt/lib/builtins/cpu_model/x86.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/compiler-rt/lib/builtins/cpu_model/x86.c b/compiler-rt/lib/builtins/cpu_model/x86.c
index 424767659e970..d9ff116cdc292 100644
--- a/compiler-rt/lib/builtins/cpu_model/x86.c
+++ b/compiler-rt/lib/builtins/cpu_model/x86.c
@@ -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,
-                                                   enum ProcessorTypes *Type,
-                                                   enum ProcessorSubtypes *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;
@@ -666,11 +664,9 @@ static const char *getIntelProcessorTypeAndSubtype(unsigned Family,
   return CPU;
 }
 
-static const char *getAMDProcessorTypeAndSubtype(unsigned Family,
-                                                 unsigned Model,
-                                                 const unsigned *Features,
-                                                 enum ProcessorTypes *Type,
-                                                 enum ProcessorSubtypes *Subtype) {
+static const char *getAMDProcessorTypeAndSubtype(
+    unsigned Family, unsigned Model, const unsigned *Features,
+    enum ProcessorTypes *Type, enum ProcessorSubtypes *Subtype) {
   const char *CPU = 0;
 
   switch (Family) {
@@ -1161,12 +1157,13 @@ __attribute__((visibility("hidden")))
 #endif
 struct __processor_model {
   unsigned int __cpu_vendor;
-  enum ProcessorTypes  __cpu_type;
-  enum ProcessorSubtypes  __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");
+static_assert(sizeof(__cpu_model) == 16,
+              "Wrong size of __cpu_model will result in ABI break");
 
 #ifndef _WIN32
 __attribute__((visibility("hidden")))
    
    
More information about the llvm-commits
mailing list