Skip to content

Commit df9fe1e

Browse files
Use Overload of lookupTarget Accepting Triple (#8432)
The overload accepting a llvm::StringRef is deprecated and will be removed when LLVM 22 branches. There is also one case where there is needless conversion (llvm::Triple->std::string->llvm::Triple). <!--- The core Triton is a small number of people, and we receive many PRs (thank you!). To help us review your code more quickly, **if you are a new contributor (less than 3 PRs merged) we ask that you complete the following tasks and include the filled-out checklist in your PR description.** Complete the following tasks before sending your PR, and replace `[ ]` with `[x]` to indicate you have done them. --> # New contributor declaration - [x] I am not making a trivial change, such as fixing a typo in a comment. - [x] I have written a PR description following these [rules](https://cbea.ms/git-commit/#why-not-how). - [x] I have run `pre-commit run --from-ref origin/main --to-ref HEAD`. - Select one of the following. - [ ] I have added tests. - `/test` for `lit` tests - `/unittest` for C++ tests - `/python/test` for end-to-end tests - [x] This PR does not need a test because `This is a simple API update, so existing test coverage should be sufficient.`. - Select one of the following. - [x] I have not added any `lit` tests. - [ ] The `lit` tests I have added follow these [best practices](https://mlir.llvm.org/getting_started/TestingGuide/#filecheck-best-practices), including the "tests should be minimal" section. (Usually running Python code and using the instructions it generates is not minimal.)
1 parent 0766464 commit df9fe1e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

python/src/llvm.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ std::unique_ptr<TargetMachine>
4747
createTargetMachine(llvm::Module *module, std::string proc,
4848
bool enable_fp_fusion, const std::string &features) {
4949
std::string error;
50-
auto target = llvm::TargetRegistry::lookupTarget(
51-
module->getTargetTriple().str(), error);
50+
auto target =
51+
llvm::TargetRegistry::lookupTarget(module->getTargetTriple(), error);
5252
llvm::TargetOptions opt;
5353
bool disableLLVMOpt = mlir::triton::tools::getBoolEnv("DISABLE_LLVM_OPT");
5454
if (enable_fp_fusion)
@@ -278,15 +278,16 @@ void init_triton_llvm(py::module &&m) {
278278
const std::string proc,
279279
const std::string features) {
280280
std::string error;
281-
auto target = llvm::TargetRegistry::lookupTarget(triple, error);
281+
llvm::Triple targetTriple(triple);
282+
auto target = llvm::TargetRegistry::lookupTarget(targetTriple, error);
282283
if (!target) {
283284
throw std::runtime_error("target lookup error: " + error);
284285
}
285286
llvm::TargetOptions opt;
286287
// Target machine is only used to create the data layout.
287288
std::unique_ptr<llvm::TargetMachine> machine{target->createTargetMachine(
288-
llvm::Triple(triple), proc, features, opt, llvm::Reloc::PIC_,
289-
std::nullopt, llvm::CodeGenOptLevel::None)};
289+
targetTriple, proc, features, opt, llvm::Reloc::PIC_, std::nullopt,
290+
llvm::CodeGenOptLevel::None)};
290291
// set data layout
291292
mod->setDataLayout(machine->createDataLayout());
292293
});

0 commit comments

Comments
 (0)