[Mlir-commits] [mlir] [NFC][MLIR] Prefer triple overload of lookupTarget (PR #162187)
Aiden Grossman
llvmlistbot at llvm.org
Mon Oct 6 15:41:27 PDT 2025
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/162187
The overloads accepting a string will be deprecated soon, similar to other functions in TargetRegistry.
>From 93e1c72a9c11db73fe5ba21381395a8a806f4386 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Mon, 6 Oct 2025 22:27:41 +0000
Subject: [PATCH] [NFC][MLIR] Prefer triple overload of lookupTarget
The overloads accepting a string will be deprecated soon, similar to
other functions in TargetRegistry.
---
mlir/lib/Target/LLVM/ModuleToObject.cpp | 5 +++--
mlir/lib/Target/LLVM/ROCDL/Target.cpp | 2 +-
mlir/lib/Target/LLVMIR/Transforms/TargetUtils.cpp | 5 +++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/mlir/lib/Target/LLVM/ModuleToObject.cpp b/mlir/lib/Target/LLVM/ModuleToObject.cpp
index 5055cd9938c72..08e7f7e6156c0 100644
--- a/mlir/lib/Target/LLVM/ModuleToObject.cpp
+++ b/mlir/lib/Target/LLVM/ModuleToObject.cpp
@@ -56,8 +56,9 @@ ModuleToObject::getOrCreateTargetMachine() {
return targetMachine.get();
// Load the target.
std::string error;
+ llvm::Triple parsedTriple(triple);
const llvm::Target *target =
- llvm::TargetRegistry::lookupTarget(triple, error);
+ llvm::TargetRegistry::lookupTarget(parsedTriple, error);
if (!target) {
getOperation().emitError()
<< "Failed to lookup target for triple '" << triple << "' " << error;
@@ -65,7 +66,7 @@ ModuleToObject::getOrCreateTargetMachine() {
}
// Create the target machine using the target.
- targetMachine.reset(target->createTargetMachine(llvm::Triple(triple), chip,
+ targetMachine.reset(target->createTargetMachine(parsedTriple, chip,
features, {}, {}));
if (!targetMachine)
return std::nullopt;
diff --git a/mlir/lib/Target/LLVM/ROCDL/Target.cpp b/mlir/lib/Target/LLVM/ROCDL/Target.cpp
index c9888c39ac891..f813f8db8fc94 100644
--- a/mlir/lib/Target/LLVM/ROCDL/Target.cpp
+++ b/mlir/lib/Target/LLVM/ROCDL/Target.cpp
@@ -289,7 +289,7 @@ SerializeGPUModuleBase::assembleIsa(StringRef isa) {
llvm::Triple triple(llvm::Triple::normalize(targetTriple));
std::string error;
const llvm::Target *target =
- llvm::TargetRegistry::lookupTarget(triple.normalize(), error);
+ llvm::TargetRegistry::lookupTarget(triple, error);
if (!target) {
emitError(loc, Twine("failed to lookup target: ") + error);
return std::nullopt;
diff --git a/mlir/lib/Target/LLVMIR/Transforms/TargetUtils.cpp b/mlir/lib/Target/LLVMIR/Transforms/TargetUtils.cpp
index f1d36228bef1f..437f6fc28bf1c 100644
--- a/mlir/lib/Target/LLVMIR/Transforms/TargetUtils.cpp
+++ b/mlir/lib/Target/LLVMIR/Transforms/TargetUtils.cpp
@@ -43,16 +43,17 @@ getTargetMachine(mlir::LLVM::TargetAttrInterface attr) {
llvm::cast_if_present<LLVM::TargetFeaturesAttr>(attr.getFeatures());
std::string features = featuresAttr ? featuresAttr.getFeaturesString() : "";
+ llvm::Triple parsedTriple(triple);
std::string error;
const llvm::Target *target =
- llvm::TargetRegistry::lookupTarget(triple, error);
+ llvm::TargetRegistry::lookupTarget(parsedTriple, error);
if (!target || !error.empty()) {
LDBG() << "Looking up target '" << triple << "' failed: " << error << "\n";
return failure();
}
return std::unique_ptr<llvm::TargetMachine>(target->createTargetMachine(
- llvm::Triple(triple), chipAKAcpu, features, {}, {}));
+ parsedTriple, chipAKAcpu, features, {}, {}));
}
FailureOr<llvm::DataLayout>
More information about the Mlir-commits
mailing list