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:
Augie Fackler 2025-10-07 11:02:13 -04:00
parent 4a54b26d30
commit eb20c6abd6

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;