[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:20:31 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] 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
More information about the llvm-commits
mailing list