Skip to content

Conversation

boomanaiden154
Copy link
Contributor

The overloads accepting a string will be deprecated soon, similar to other functions in TargetRegistry.

The overloads accepting a string will be deprecated soon, similar to
other functions in TargetRegistry.
@llvmbot
Copy link
Member

llvmbot commented Oct 6, 2025

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-llvm

Author: Aiden Grossman (boomanaiden154)

Changes

The overloads accepting a string will be deprecated soon, similar to other functions in TargetRegistry.


Full diff: https://github.com/llvm/llvm-project/pull/162187.diff

3 Files Affected:

  • (modified) mlir/lib/Target/LLVM/ModuleToObject.cpp (+3-2)
  • (modified) mlir/lib/Target/LLVM/ROCDL/Target.cpp (+1-1)
  • (modified) mlir/lib/Target/LLVMIR/Transforms/TargetUtils.cpp (+3-2)
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>

Copy link

github-actions bot commented Oct 6, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@fabianmcg fabianmcg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Please fix the format before merging.

@boomanaiden154 boomanaiden154 enabled auto-merge (squash) October 6, 2025 22:49
@boomanaiden154 boomanaiden154 merged commit 1553802 into llvm:main Oct 6, 2025
9 checks passed
@boomanaiden154 boomanaiden154 deleted the mlir-lookup-target branch October 6, 2025 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants