Skip to content

Commit

Permalink
Revert "[clang][AArch64] Add getHostCPUFeatures to query for enabled … (
Browse files Browse the repository at this point in the history
llvm#114066)

…features in cpu info (llvm#97749)"

This reverts commit d732c0b.

This is breaking buildbots
https://lab.llvm.org/buildbot/#/builders/190/builds/8413,
https://lab.llvm.org/buildbot/#/builders/56/builds/10880 and a few
others.
  • Loading branch information
ElvinaYakubova authored Oct 29, 2024
1 parent 2e612f8 commit 80a0973
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 198 deletions.
20 changes: 7 additions & 13 deletions clang/lib/Driver/ToolChains/Arch/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
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
Expand Up @@ -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);
Expand Down

0 comments on commit 80a0973

Please sign in to comment.