Skip to content

Revert "[clang][AArch64] Add getHostCPUFeatures to query for enabled … #114066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions clang/lib/Driver/ToolChains/Arch/AArch64.cpp
Original file line number Diff line number Diff line change
@@ -135,21 +135,15 @@ getAArch64ArchFeaturesFromMarch(const Driver &D, StringRef March,
return true;
}

static bool getAArch64ArchFeaturesFromMcpu(
const Driver &D, StringRef Mcpu, const ArgList &Args,
llvm::AArch64::ExtensionSet &Extensions, std::vector<StringRef> &Features) {
static bool
getAArch64ArchFeaturesFromMcpu(const Driver &D, StringRef Mcpu,
const ArgList &Args,
llvm::AArch64::ExtensionSet &Extensions) {
StringRef CPU;
std::string McpuLowerCase = Mcpu.lower();
if (!DecodeAArch64Mcpu(D, McpuLowerCase, CPU, Extensions))
return false;

if (Mcpu == "native") {
llvm::StringMap<bool> HostFeatures = llvm::sys::getHostCPUFeatures();
for (auto &[Feature, Enabled] : HostFeatures) {
Features.push_back(Args.MakeArgString((Enabled ? "+" : "-") + Feature));
}
}

return true;
}

@@ -216,11 +210,11 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
success =
getAArch64ArchFeaturesFromMarch(D, A->getValue(), Args, Extensions);
else if ((A = Args.getLastArg(options::OPT_mcpu_EQ)))
success = getAArch64ArchFeaturesFromMcpu(D, A->getValue(), Args, Extensions,
Features);
success =
getAArch64ArchFeaturesFromMcpu(D, A->getValue(), Args, Extensions);
else if (isCPUDeterminedByTriple(Triple))
success = getAArch64ArchFeaturesFromMcpu(
D, getAArch64TargetCPU(Args, Triple, A), Args, Extensions, Features);
D, getAArch64TargetCPU(Args, Triple, A), Args, Extensions);
else
// Default to 'A' profile if the architecture is not specified.
success = getAArch64ArchFeaturesFromMarch(D, "armv8-a", Args, Extensions);
8 changes: 0 additions & 8 deletions clang/test/Driver/Inputs/cpunative/cortex-a57

This file was deleted.

8 changes: 0 additions & 8 deletions clang/test/Driver/Inputs/cpunative/cortex-a72

This file was deleted.

8 changes: 0 additions & 8 deletions clang/test/Driver/Inputs/cpunative/cortex-a76

This file was deleted.

8 changes: 0 additions & 8 deletions clang/test/Driver/Inputs/cpunative/neoverse-n1

This file was deleted.

8 changes: 0 additions & 8 deletions clang/test/Driver/Inputs/cpunative/neoverse-v2

This file was deleted.

138 changes: 0 additions & 138 deletions clang/test/Driver/aarch64-mcpu-native.c

This file was deleted.

10 changes: 3 additions & 7 deletions llvm/lib/TargetParser/Host.cpp
Original file line number Diff line number Diff line change
@@ -68,15 +68,11 @@ using namespace llvm;

static std::unique_ptr<llvm::MemoryBuffer>
LLVM_ATTRIBUTE_UNUSED getProcCpuinfoContent() {
const char *CPUInfoFile = "/proc/cpuinfo";
if (const char *CpuinfoIntercept = std::getenv("LLVM_CPUINFO"))
CPUInfoFile = CpuinfoIntercept;
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Text =
llvm::MemoryBuffer::getFileAsStream(CPUInfoFile);

llvm::MemoryBuffer::getFileAsStream("/proc/cpuinfo");
if (std::error_code EC = Text.getError()) {
llvm::errs() << "Can't read " << CPUInfoFile << ": " << EC.message()
<< "\n";
llvm::errs() << "Can't read "
<< "/proc/cpuinfo: " << EC.message() << "\n";
return nullptr;
}
return std::move(*Text);