Skip to content

Commit fc3cdd0

Browse files
committed
Revert "[AArch64] Add support for -march=native for Apple M1 CPU"
This reverts commit fcca10c.
1 parent 7504dd5 commit fc3cdd0

File tree

2 files changed

+26
-40
lines changed

2 files changed

+26
-40
lines changed

clang/lib/Driver/ToolChains/Arch/AArch64.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ getAArch64ArchFeaturesFromMarch(const Driver &D, StringRef March,
151151
std::pair<StringRef, StringRef> Split = StringRef(MarchLowerCase).split("+");
152152

153153
llvm::AArch64::ArchKind ArchKind = llvm::AArch64::parseArch(Split.first);
154-
if (Split.first == "native")
155-
ArchKind = llvm::AArch64::getCPUArchKind(llvm::sys::getHostCPUName().str());
156154
if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
157155
!llvm::AArch64::getArchFeatures(ArchKind, Features))
158156
return false;

llvm/lib/Support/Host.cpp

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
#include <mach/mach.h>
4242
#include <mach/mach_host.h>
4343
#include <mach/machine.h>
44-
#include <sys/param.h>
45-
#include <sys/sysctl.h>
4644
#endif
4745
#ifdef _AIX
4846
#include <sys/systemcfg.h>
@@ -1299,45 +1297,32 @@ StringRef sys::getHostCPUName() {
12991297
bool HaveVectorSupport = CVT[244] & 0x80;
13001298
return getCPUNameFromS390Model(Id, HaveVectorSupport);
13011299
}
1302-
#elif defined(__APPLE__) && (defined(__arm__) || defined(__aarch64__))
1303-
#define CPUFAMILY_ARM_SWIFT 0x1e2d6381
1304-
#define CPUFAMILY_ARM_CYCLONE 0x37a09642
1305-
#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e
1306-
#define CPUFAMILY_ARM_TWISTER 0x92fb37c8
1307-
#define CPUFAMILY_ARM_HURRICANE 0x67ceee93
1308-
#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6
1309-
#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f
1310-
#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2
1311-
#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3
1312-
1300+
#elif defined(__APPLE__) && defined(__aarch64__)
13131301
StringRef sys::getHostCPUName() {
1314-
uint32_t Family;
1315-
size_t Length = sizeof(Family);
1316-
sysctlbyname("hw.cpufamily", &Family, &Length, NULL, 0);
1302+
return "cyclone";
1303+
}
1304+
#elif defined(__APPLE__) && defined(__arm__)
1305+
StringRef sys::getHostCPUName() {
1306+
host_basic_info_data_t hostInfo;
1307+
mach_msg_type_number_t infoCount;
13171308

1318-
switch (Family) {
1319-
case CPUFAMILY_ARM_SWIFT:
1320-
return "swift";
1321-
case CPUFAMILY_ARM_CYCLONE:
1322-
return "apple-a7";
1323-
case CPUFAMILY_ARM_TYPHOON:
1324-
return "apple-a8";
1325-
case CPUFAMILY_ARM_TWISTER:
1326-
return "apple-a9";
1327-
case CPUFAMILY_ARM_HURRICANE:
1328-
return "apple-a10";
1329-
case CPUFAMILY_ARM_MONSOON_MISTRAL:
1330-
return "apple-a11";
1331-
case CPUFAMILY_ARM_VORTEX_TEMPEST:
1332-
return "apple-a12";
1333-
case CPUFAMILY_ARM_LIGHTNING_THUNDER:
1334-
return "apple-a13";
1335-
case CPUFAMILY_ARM_FIRESTORM_ICESTORM:
1336-
return "apple-m1";
1337-
default:
1338-
// Default to the newest CPU we know about.
1339-
return "apple-m1";
1309+
infoCount = HOST_BASIC_INFO_COUNT;
1310+
mach_port_t hostPort = mach_host_self();
1311+
host_info(hostPort, HOST_BASIC_INFO, (host_info_t)&hostInfo,
1312+
&infoCount);
1313+
mach_port_deallocate(mach_task_self(), hostPort);
1314+
1315+
if (hostInfo.cpu_type != CPU_TYPE_ARM) {
1316+
assert(false && "CPUType not equal to ARM should not be possible on ARM");
1317+
return "generic";
13401318
}
1319+
switch (hostInfo.cpu_subtype) {
1320+
case CPU_SUBTYPE_ARM_V7S:
1321+
return "swift";
1322+
default:;
1323+
}
1324+
1325+
return "generic";
13411326
}
13421327
#elif defined(_AIX)
13431328
StringRef sys::getHostCPUName() {
@@ -1468,6 +1453,9 @@ int computeHostNumPhysicalCores() {
14681453
#elif defined(__linux__) && defined(__s390x__)
14691454
int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
14701455
#elif defined(__APPLE__)
1456+
#include <sys/param.h>
1457+
#include <sys/sysctl.h>
1458+
14711459
// Gets the number of *physical cores* on the machine.
14721460
int computeHostNumPhysicalCores() {
14731461
uint32_t count;

0 commit comments

Comments
 (0)