[llvm] Revert "[MCA] Ignore host -mcpu when target lacks said CPU" (PR #174087)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 31 04:20:47 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-tools-llvm-mca
Author: Amina Chabane (Amichaxx)
<details>
<summary>Changes</summary>
Reverts llvm/llvm-project#<!-- -->174004
---
Full diff: https://github.com/llvm/llvm-project/pull/174087.diff
2 Files Affected:
- (renamed) llvm/test/tools/llvm-mca/mcpu-help.test ()
- (modified) llvm/tools/llvm-mca/llvm-mca.cpp (+8-36)
``````````diff
diff --git a/llvm/test/tools/llvm-mca/AArch64/mcpu-help.test b/llvm/test/tools/llvm-mca/mcpu-help.test
similarity index 100%
rename from llvm/test/tools/llvm-mca/AArch64/mcpu-help.test
rename to llvm/test/tools/llvm-mca/mcpu-help.test
diff --git a/llvm/tools/llvm-mca/llvm-mca.cpp b/llvm/tools/llvm-mca/llvm-mca.cpp
index 45fa4973d4399..c4aa081a095f8 100644
--- a/llvm/tools/llvm-mca/llvm-mca.cpp
+++ b/llvm/tools/llvm-mca/llvm-mca.cpp
@@ -392,6 +392,9 @@ int main(int argc, char **argv) {
if (!TheTarget)
return 1;
+ if (MCPU == "native")
+ MCPU = std::string(llvm::sys::getHostCPUName());
+
// Package up features to be passed to target/subtarget
std::string FeaturesStr;
if (MATTRS.size()) {
@@ -401,44 +404,13 @@ int main(int argc, char **argv) {
FeaturesStr = Features.getString();
}
- auto CreateSubtargetInfo = [&](StringRef CPU) {
- return std::unique_ptr<MCSubtargetInfo>(
- TheTarget->createMCSubtargetInfo(TheTriple, CPU, FeaturesStr));
- };
-
- std::unique_ptr<MCSubtargetInfo> STI;
- if (MCPU == "native") {
- std::string HostCPU = std::string(llvm::sys::getHostCPUName());
- STI = CreateSubtargetInfo("");
- if (!STI) {
- WithColor::error() << "unable to create subtarget info\n";
- return 1;
- }
- if (!HostCPU.empty() && STI->isCPUStringValid(HostCPU)) {
- // Only utilise the detected host CPU when it exists in the processor
- // table for the requested triple.
- STI = CreateSubtargetInfo(HostCPU);
- if (!STI) {
- WithColor::error() << "unable to create subtarget info\n";
- return 1;
- }
- MCPU = HostCPU;
- } else {
- MCPU.clear();
- }
- } else {
- STI = CreateSubtargetInfo(MCPU);
- if (!STI) {
- WithColor::error() << "unable to create subtarget info\n";
- return 1;
- }
+ std::unique_ptr<MCSubtargetInfo> STI(
+ TheTarget->createMCSubtargetInfo(TheTriple, MCPU, FeaturesStr));
+ if (!STI) {
+ WithColor::error() << "unable to create subtarget info\n";
+ return 1;
}
- if (MCPU.empty())
- // MCPU being empty here means the target default was selected above,
- // which avoids forwarding incompatible host CPUs when cross-compiling.
- MCPU = std::string(STI->getCPU());
-
if (MCPU == "help")
return 0;
``````````
</details>
https://github.com/llvm/llvm-project/pull/174087
More information about the llvm-commits
mailing list