-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NFC][MLIR] Prefer triple overload of lookupTarget #162187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The overloads accepting a string will be deprecated soon, similar to other functions in TargetRegistry.
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-llvm Author: Aiden Grossman (boomanaiden154) ChangesThe 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:
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>
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this 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.
The overloads accepting a string will be deprecated soon, similar to other functions in TargetRegistry.