From d5090963ac70299b4185aee4698fc2d387b21458 Mon Sep 17 00:00:00 2001 From: bjacob Date: Tue, 7 Nov 2023 21:56:13 -0500 Subject: [PATCH] Treat `iree-llvmcpu-target-cpu` as an error outside of x86, and continue past errors (#15477) See the discussion thread below https://discord.com/channels/689900678990135345/1171569395697467403/1171572035336548453 . Implementing `iree-llvmcpu-target-cpu` on arm64 is hopeless because Arm CPU names are under-defined. For instance, LLVM thinks that Cortex-A710 implies SVE, but most current Cortex-A710 based devices do not support SVE. --- .../HAL/Target/LLVMCPU/LLVMTargetOptions.cpp | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVMCPU/LLVMTargetOptions.cpp b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVMCPU/LLVMTargetOptions.cpp index 839ed9120dad..7e0179925ed1 100644 --- a/compiler/src/iree/compiler/Dialect/HAL/Target/LLVMCPU/LLVMTargetOptions.cpp +++ b/compiler/src/iree/compiler/Dialect/HAL/Target/LLVMCPU/LLVMTargetOptions.cpp @@ -14,7 +14,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Target/TargetOptions.h" -#include "llvm/TargetParser/AArch64TargetParser.h" #include "llvm/TargetParser/Host.h" #include "llvm/TargetParser/SubtargetFeature.h" #include "llvm/TargetParser/Triple.h" @@ -81,24 +80,6 @@ bool resolveCPUAndCPUFeatures(llvm::StringRef inCpu, targetCpuFeatures.AddFeature(feature); } outCpuFeatures = targetCpuFeatures.getString(); - } else if (triple.isAArch64()) { - std::vector UpdatedFeaturesVec; - std::optional cpuInfo = - llvm::AArch64::parseCpu(outCpu); - if (!cpuInfo) { - llvm::errs() << "error: Failed to resolve AArch64 CPU features for the " - "specified CPU.\n"; - return false; - } - auto cpuExts = cpuInfo->getImpliedExtensions(); - std::vector cpuExtFeatures; - llvm::AArch64::getExtensionFeatures(cpuExts, cpuExtFeatures); - for (auto feature : cpuExtFeatures) { - if (!outCpuFeatures.empty()) { - outCpuFeatures.append(","); - } - outCpuFeatures.append(feature); - } } else { llvm::errs() << "error: Resolution of target CPU to target CPU features is not " @@ -158,7 +139,9 @@ std::optional LLVMTarget::create(std::string_view triple, } if (!resolveCPUAndCPUFeatures(cpu, cpuFeatures, llvm::Triple(triple), target.cpu, target.cpuFeatures)) { - return {}; + // Something bad happened, and our target might not be what the user expects + // but we need to continue to avoid breaking existing users. Hopefully + // resolveCPUAndCPUFeatures logged a helpful error already. } return target; }