Rollup merge of #147446 - durin42:llvm-22-lookupTarget-deprecation, r=Zalathar

PassWrapper: use non-deprecated lookupTarget method

This avoids an extra trip through a triple string by directly passing the Triple, and has been available since LLVM 21. The string overload was deprecated today and throws an error on our CI for HEAD due to -Werror paranoia, so we may as well clean this up now and also skip the conversion on LLVM 21 since we can.

`@rustbot` label llvm-main
This commit is contained in:
Stuart Cook 2025-10-09 21:29:04 +11:00 committed by GitHub
commit c33f0b373b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -283,7 +283,11 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
std::string Error;
auto Trip = Triple(Triple::normalize(TripleStr));
const llvm::Target *TheTarget =
#if LLVM_VERSION_GE(21, 0)
TargetRegistry::lookupTarget(Trip, Error);
#else
TargetRegistry::lookupTarget(Trip.getTriple(), Error);
#endif
if (TheTarget == nullptr) {
LLVMRustSetLastError(Error.c_str());
return nullptr;