From 13c2964f6fe9e44a54ff4b1ae1be9e79d4739ff5 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Tue, 4 Feb 2025 21:50:58 -0500 Subject: [PATCH] Silence false-positive warnings about implicit CPU fallback. (#19907) In https://github.com/iree-org/iree/pull/19902 we added reporting of errors in `LLVMCPUTargetCLOptions::getTargetOptions` which allows reporting things like an unknown CPU before that causes assertion failures in LLVM. But we mistakenly also reported there the warning about the implicit CPU fallback, which is a false positive in this case as it triggers on default targets that we may not actually use. Signed-off-by: Benoit Jacob --- compiler/plugins/target/LLVMCPU/LLVMTargetOptions.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/plugins/target/LLVMCPU/LLVMTargetOptions.cpp b/compiler/plugins/target/LLVMCPU/LLVMTargetOptions.cpp index 88e10f86ce9b..611bf3c4346f 100644 --- a/compiler/plugins/target/LLVMCPU/LLVMTargetOptions.cpp +++ b/compiler/plugins/target/LLVMCPU/LLVMTargetOptions.cpp @@ -607,7 +607,13 @@ LLVMTargetOptions LLVMCPUTargetCLOptions::getTargetOptions() { ResolveCPUAndCPUFeaturesStatus status; std::optional maybeTarget = LLVMTarget::create( targetTriple, targetCPU, targetCPUFeatures, linkEmbedded, status); - if (status != ResolveCPUAndCPUFeaturesStatus::OK) { + // Only report serious errors here, not potentially verbose warnings such as + // ImplicitGenericFallback, which has false positives at this point as it + // triggers on default-constructed targets that we might not actually use. + // If the targets are used, they will trigger the warning again in + // LLVMTarget::loadFromConfigAttr. + if (status != ResolveCPUAndCPUFeaturesStatus::OK && + status != ResolveCPUAndCPUFeaturesStatus::ImplicitGenericFallback) { llvm::errs() << getMessage(status, targetTriple); } if (maybeTarget) {