Skip to content

[TargetRegistry] Accept Triple in createTargetMachine() (NFC) #130940

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

Merged
merged 3 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bolt/lib/Passes/AsmDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void dumpFunction(const BinaryFunction &BF) {
std::move(MCEInstance.MCE), std::move(MAB)));
AsmStreamer->initSections(true, *BC.STI);
std::unique_ptr<TargetMachine> TM(BC.TheTarget->createTargetMachine(
BC.TripleName, "", "", TargetOptions(), std::nullopt));
*BC.TheTriple, "", "", TargetOptions(), std::nullopt));
std::unique_ptr<AsmPrinter> MAP(
BC.TheTarget->createAsmPrinter(*TM, std::move(AsmStreamer)));

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ static void setCommandLineOpts(const CodeGenOptions &CodeGenOpts) {
void EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
// Create the TargetMachine for generating code.
std::string Error;
std::string Triple = TheModule->getTargetTriple().str();
const llvm::Triple &Triple = TheModule->getTargetTriple();
const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
if (!TheTarget) {
if (MustCreateTM)
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Interpreter/DeviceOffload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ llvm::Expected<llvm::StringRef> IncrementalCUDADeviceParser::GeneratePTX() {
std::error_code());
llvm::TargetOptions TO = llvm::TargetOptions();
llvm::TargetMachine *TargetMachine = Target->createTargetMachine(
PTU.TheModule->getTargetTriple().str(), TargetOpts.CPU, "", TO,
PTU.TheModule->getTargetTriple(), TargetOpts.CPU, "", TO,
llvm::Reloc::Model::PIC_);
PTU.TheModule->setDataLayout(TargetMachine->createDataLayout());

Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Interpreter/Wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
}

llvm::TargetOptions TO = llvm::TargetOptions();
llvm::TargetMachine *TargetMachine =
Target->createTargetMachine(PTU.TheModule->getTargetTriple().str(), "",
"", TO, llvm::Reloc::Model::PIC_);
llvm::TargetMachine *TargetMachine = Target->createTargetMachine(
PTU.TheModule->getTargetTriple(), "", "", TO, llvm::Reloc::Model::PIC_);
PTU.TheModule->setDataLayout(TargetMachine->createDataLayout());
std::string ObjectFileName = PTU.TheModule->getName().str() + ".o";
std::string BinaryFileName = PTU.TheModule->getName().str() + ".wasm";
Expand Down
4 changes: 2 additions & 2 deletions clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ static std::string OptLLVM(const std::string &IR, CodeGenOptLevel OLvl) {
ErrorAndExit(E);

std::unique_ptr<TargetMachine> TM(TheTarget->createTargetMachine(
M->getTargetTriple().str(), codegen::getCPUStr(),
codegen::getFeaturesStr(), Options, codegen::getExplicitRelocModel(),
M->getTargetTriple(), codegen::getCPUStr(), codegen::getFeaturesStr(),
Options, codegen::getExplicitRelocModel(),
codegen::getExplicitCodeModel(), OLvl));
if (!TM)
ErrorAndExit("Could not create target machine");
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ Expected<StringRef> compileModule(Module &M, OffloadKind Kind) {
StringRef CPU = "";
StringRef Features = "";
std::unique_ptr<TargetMachine> TM(
T->createTargetMachine(M.getTargetTriple().str(), CPU, Features, Options,
T->createTargetMachine(M.getTargetTriple(), CPU, Features, Options,
Reloc::PIC_, M.getCodeModel()));

if (M.getDataLayout().isDefault())
Expand Down
16 changes: 10 additions & 6 deletions clang/tools/driver/cc1_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ static void ensureSufficientStack() {}

/// Print supported cpus of the given target.
static int PrintSupportedCPUs(std::string TargetStr) {
llvm::Triple Triple(TargetStr);
std::string Error;
const llvm::Target *TheTarget =
llvm::TargetRegistry::lookupTarget(TargetStr, Error);
llvm::TargetRegistry::lookupTarget(Triple, Error);
if (!TheTarget) {
llvm::errs() << Error;
return 1;
Expand All @@ -122,23 +123,24 @@ static int PrintSupportedCPUs(std::string TargetStr) {
// the target machine will handle the mcpu printing
llvm::TargetOptions Options;
std::unique_ptr<llvm::TargetMachine> TheTargetMachine(
TheTarget->createTargetMachine(TargetStr, "", "+cpuhelp", Options,
TheTarget->createTargetMachine(Triple, "", "+cpuhelp", Options,
std::nullopt));
return 0;
}

static int PrintSupportedExtensions(std::string TargetStr) {
llvm::Triple Triple(TargetStr);
std::string Error;
const llvm::Target *TheTarget =
llvm::TargetRegistry::lookupTarget(TargetStr, Error);
llvm::TargetRegistry::lookupTarget(Triple, Error);
if (!TheTarget) {
llvm::errs() << Error;
return 1;
}

llvm::TargetOptions Options;
std::unique_ptr<llvm::TargetMachine> TheTargetMachine(
TheTarget->createTargetMachine(TargetStr, "", "", Options, std::nullopt));
TheTarget->createTargetMachine(Triple, "", "", Options, std::nullopt));
const llvm::Triple &MachineTriple = TheTargetMachine->getTargetTriple();
const llvm::MCSubtargetInfo *MCInfo = TheTargetMachine->getMCSubtargetInfo();
const llvm::ArrayRef<llvm::SubtargetFeatureKV> Features =
Expand All @@ -165,9 +167,10 @@ static int PrintSupportedExtensions(std::string TargetStr) {
}

static int PrintEnabledExtensions(const TargetOptions& TargetOpts) {
llvm::Triple Triple(TargetOpts.Triple);
std::string Error;
const llvm::Target *TheTarget =
llvm::TargetRegistry::lookupTarget(TargetOpts.Triple, Error);
llvm::TargetRegistry::lookupTarget(Triple, Error);
if (!TheTarget) {
llvm::errs() << Error;
return 1;
Expand All @@ -179,7 +182,8 @@ static int PrintEnabledExtensions(const TargetOptions& TargetOpts) {
llvm::TargetOptions BackendOptions;
std::string FeaturesStr = llvm::join(TargetOpts.FeaturesAsWritten, ",");
std::unique_ptr<llvm::TargetMachine> TheTargetMachine(
TheTarget->createTargetMachine(TargetOpts.Triple, TargetOpts.CPU, FeaturesStr, BackendOptions, std::nullopt));
TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr,
BackendOptions, std::nullopt));
const llvm::Triple &MachineTriple = TheTargetMachine->getTargetTriple();
const llvm::MCSubtargetInfo *MCInfo = TheTargetMachine->getMCSubtargetInfo();

Expand Down
2 changes: 1 addition & 1 deletion flang/tools/bbc/bbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ createTargetMachine(llvm::StringRef targetTriple, std::string &error) {
if (!theTarget)
return nullptr;
return std::unique_ptr<llvm::TargetMachine>{
theTarget->createTargetMachine(triple, /*CPU=*/"",
theTarget->createTargetMachine(llvm::Triple(triple), /*CPU=*/"",
/*Features=*/"", llvm::TargetOptions(),
/*Reloc::Model=*/std::nullopt)};
}
Expand Down
4 changes: 2 additions & 2 deletions flang/tools/flang-driver/fc1_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ static int printSupportedCPUs(llvm::StringRef triple) {
// the target machine will handle the mcpu printing
llvm::TargetOptions targetOpts;
std::unique_ptr<llvm::TargetMachine> targetMachine(
target->createTargetMachine(triple, "", "+cpuhelp", targetOpts,
std::nullopt));
target->createTargetMachine(llvm::Triple(triple), "", "+cpuhelp",
targetOpts, std::nullopt));
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/examples/Kaleidoscope/Chapter8/toy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ int main() {

TargetOptions opt;
auto TheTargetMachine = Target->createTargetMachine(
TargetTriple, CPU, Features, opt, Reloc::PIC_);
Triple(TargetTriple), CPU, Features, opt, Reloc::PIC_);

TheModule->setDataLayout(TheTargetMachine->createDataLayout());

Expand Down
16 changes: 13 additions & 3 deletions llvm/include/llvm/MC/TargetRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,24 @@ class Target {
/// either the target triple from the module, or the target triple of the
/// host if that does not exist.
TargetMachine *createTargetMachine(
StringRef TT, StringRef CPU, StringRef Features,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep a StringRef overload, at least for a while? As-is this is going to break a lot of downstream builds

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Restored StringRef overload with deprecation.

const Triple &TT, StringRef CPU, StringRef Features,
const TargetOptions &Options, std::optional<Reloc::Model> RM,
std::optional<CodeModel::Model> CM = std::nullopt,
CodeGenOptLevel OL = CodeGenOptLevel::Default, bool JIT = false) const {
if (!TargetMachineCtorFn)
return nullptr;
return TargetMachineCtorFn(*this, Triple(TT), CPU, Features, Options, RM,
CM, OL, JIT);
return TargetMachineCtorFn(*this, TT, CPU, Features, Options, RM, CM, OL,
JIT);
}

[[deprecated("Use overload accepting Triple instead")]]
TargetMachine *createTargetMachine(
StringRef TT, StringRef CPU, StringRef Features,
const TargetOptions &Options, std::optional<Reloc::Model> RM,
std::optional<CodeModel::Model> CM = std::nullopt,
CodeGenOptLevel OL = CodeGenOptLevel::Default, bool JIT = false) const {
return createTargetMachine(Triple(TT), CPU, Features, Options, RM, CM, OL,
JIT);
}

/// createMCAsmBackend - Create a target specific assembly parser.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/CommandFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ codegen::createTargetMachineForTriple(StringRef TargetTriple,
if (!TheTarget)
return createStringError(inconvertibleErrorCode(), Error);
auto *Target = TheTarget->createTargetMachine(
TheTriple.getTriple(), codegen::getCPUStr(), codegen::getFeaturesStr(),
TheTriple, codegen::getCPUStr(), codegen::getFeaturesStr(),
codegen::InitTargetOptionsFromCodeGenFlags(TheTriple),
codegen::getExplicitRelocModel(), codegen::getExplicitCodeModel(),
OptLevel);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Error DwarfStreamer::init(Triple TheTriple,
TripleName.c_str());

// Finally create the AsmPrinter we'll use to emit the DIEs.
TM.reset(TheTarget->createTargetMachine(TripleName, "", "", TargetOptions(),
TM.reset(TheTarget->createTargetMachine(TheTriple, "", "", TargetOptions(),
std::nullopt));
if (!TM)
return createStringError(std::errc::invalid_argument,
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Error DwarfEmitterImpl::init(Triple TheTriple,
TripleName.c_str());

// Finally create the AsmPrinter we'll use to emit the DIEs.
TM.reset(TheTarget->createTargetMachine(TripleName, "", "", TargetOptions(),
TM.reset(TheTarget->createTargetMachine(TheTriple, "", "", TargetOptions(),
std::nullopt));
if (!TM)
return createStringError(std::errc::invalid_argument,
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ JITTargetMachineBuilder::createTargetMachine() {
return make_error<StringError>("Target has no JIT support",
inconvertibleErrorCode());

auto *TM =
TheTarget->createTargetMachine(TT.getTriple(), CPU, Features.getString(),
Options, RM, CM, OptLevel, /*JIT*/ true);
auto *TM = TheTarget->createTargetMachine(
TT, CPU, Features.getString(), Options, RM, CM, OptLevel, /*JIT=*/true);
if (!TM)
return make_error<StringError>("Could not allocate target machine",
inconvertibleErrorCode());
Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/ExecutionEngine/TargetSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,9 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple,
}

// Allocate a target...
TargetMachine *Target =
TheTarget->createTargetMachine(TheTriple.getTriple(), MCPU, FeaturesStr,
Options, RelocModel, CMModel, OptLevel,
/*JIT*/ true);
TargetMachine *Target = TheTarget->createTargetMachine(
TheTriple, MCPU, FeaturesStr, Options, RelocModel, CMModel, OptLevel,
/*JIT=*/true);
Target->Options.EmulatedTLS = EmulatedTLS;

assert(Target && "Could not allocate target machine!");
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5505,7 +5505,7 @@ createTargetMachine(Function *F, CodeGenOptLevel OptLevel) {

StringRef CPU = F->getFnAttribute("target-cpu").getValueAsString();
StringRef Features = F->getFnAttribute("target-features").getValueAsString();
const std::string &Triple = M->getTargetTriple().str();
const llvm::Triple &Triple = M->getTargetTriple();

std::string Error;
const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Triple, Error);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/LTO/LTOBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ createTargetMachine(const Config &Conf, const Target *TheTarget, Module &M) {
}

std::unique_ptr<TargetMachine> TM(TheTarget->createTargetMachine(
TheTriple.str(), Conf.CPU, Features.getString(), TargetOpts, RelocModel,
TheTriple, Conf.CPU, Features.getString(), TargetOpts, RelocModel,
CodeModel, Conf.CGOptLevel));

assert(TM && "Failed to create target machine");
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/LTO/LTOCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ bool LTOCodeGenerator::determineTarget() {
std::unique_ptr<TargetMachine> LTOCodeGenerator::createTargetMachine() {
assert(MArch && "MArch is not set!");
return std::unique_ptr<TargetMachine>(MArch->createTargetMachine(
TripleStr, Config.CPU, FeatureStr, Config.Options, Config.RelocModel,
std::nullopt, Config.CGOptLevel));
Triple(TripleStr), Config.CPU, FeatureStr, Config.Options,
Config.RelocModel, std::nullopt, Config.CGOptLevel));
}

// If a linkonce global is present in the MustPreserveSymbols, we need to make
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/LTO/LTOModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ LTOModule::makeLTOModule(MemoryBufferRef Buffer, const TargetOptions &options,
CPU = "cyclone";
}

TargetMachine *target = march->createTargetMachine(
Triple.str(), CPU, FeatureStr, options, std::nullopt);
TargetMachine *target = march->createTargetMachine(Triple, CPU, FeatureStr,
options, std::nullopt);

std::unique_ptr<LTOModule> Ret(new LTOModule(std::move(M), Buffer, target));
Ret->parseSymbols();
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/LTO/ThinLTOCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ std::unique_ptr<TargetMachine> TargetMachineBuilder::create() const {
std::string FeatureStr = Features.getString();

std::unique_ptr<TargetMachine> TM(
TheTarget->createTargetMachine(TheTriple.str(), MCpu, FeatureStr, Options,
TheTarget->createTargetMachine(TheTriple, MCpu, FeatureStr, Options,
RelocModel, std::nullopt, CGOptLevel));
assert(TM && "Cannot create target machine");

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/SPIRV/SPIRVAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ SPIRVTranslate(Module *M, std::string &SpirvObj, std::string &ErrMsg,
std::optional<Reloc::Model> RM;
std::optional<CodeModel::Model> CM;
std::unique_ptr<TargetMachine> Target(TheTarget->createTargetMachine(
TargetTriple.getTriple(), "", "", Options, RM, CM, OLevel));
TargetTriple, "", "", Options, RM, CM, OLevel));
if (!Target) {
ErrMsg = "Could not allocate target machine!";
return false;
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/TargetMachineC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ void LLVMTargetMachineOptionsSetCodeModel(LLVMTargetMachineOptionsRef Options,
}

LLVMTargetMachineRef
LLVMCreateTargetMachineWithOptions(LLVMTargetRef T, const char *Triple,
LLVMCreateTargetMachineWithOptions(LLVMTargetRef T, const char *TripleStr,
LLVMTargetMachineOptionsRef Options) {
auto *Opt = unwrap(Options);
TargetOptions TO;
TO.MCOptions.ABIName = Opt->ABI;
return wrap(unwrap(T)->createTargetMachine(Triple, Opt->CPU, Opt->Features,
TO, Opt->RM, Opt->CM, Opt->OL,
Opt->JIT));
return wrap(unwrap(T)->createTargetMachine(Triple(TripleStr), Opt->CPU,
Opt->Features, TO, Opt->RM,
Opt->CM, Opt->OL, Opt->JIT));
}

LLVMTargetMachineRef
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llc/llc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ static int compileModule(char **argv, LLVMContext &Context) {

InitializeOptions(TheTriple);
Target = std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine(
TheTriple.getTriple(), CPUStr, FeaturesStr, Options, RM, CM, OLvl));
TheTriple, CPUStr, FeaturesStr, Options, RM, CM, OLvl));
assert(Target && "Could not allocate target machine!");

return Target->createDataLayout().getStringRepresentation();
Expand Down Expand Up @@ -598,7 +598,7 @@ static int compileModule(char **argv, LLVMContext &Context) {

InitializeOptions(TheTriple);
Target = std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine(
TheTriple.getTriple(), CPUStr, FeaturesStr, Options, RM, CM, OLvl));
TheTriple, CPUStr, FeaturesStr, Options, RM, CM, OLvl));
assert(Target && "Could not allocate target machine!");

// If we don't have a module then just exit now. We do this down
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-exegesis/lib/LlvmState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Expected<LLVMState> LLVMState::Create(std::string TripleName,
}
const TargetOptions Options;
std::unique_ptr<const TargetMachine> TM(TheTarget->createTargetMachine(
TripleName, CpuName, Features, Options, Reloc::Model::Static));
TheTriple, CpuName, Features, Options, Reloc::Model::Static));
if (!TM) {
return make_error<StringError>("unable to create target machine",
inconvertibleErrorCode());
Expand Down Expand Up @@ -93,7 +93,7 @@ LLVMState::LLVMState(std::unique_ptr<const TargetMachine> TM,
std::unique_ptr<TargetMachine> LLVMState::createTargetMachine() const {
return std::unique_ptr<TargetMachine>(
TheTargetMachine->getTarget().createTargetMachine(
TheTargetMachine->getTargetTriple().normalize(),
Triple(TheTargetMachine->getTargetTriple().normalize()),
TheTargetMachine->getTargetCPU(),
TheTargetMachine->getTargetFeatureString(), TheTargetMachine->Options,
Reloc::Model::Static));
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-split/llvm-split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int main(int argc, char **argv) {

TargetOptions Options;
TM = std::unique_ptr<TargetMachine>(T->createTargetMachine(
MTriple, MCPU, /*FS*/ "", Options, std::nullopt, std::nullopt));
Triple(MTriple), MCPU, /*FS*/ "", Options, std::nullopt, std::nullopt));
}

std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context);
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AArch64SelectionDAGTest : public testing::Test {

TargetOptions Options;
TM = std::unique_ptr<TargetMachine>(
T->createTargetMachine("AArch64", "", "+sve", Options, std::nullopt,
T->createTargetMachine(TargetTriple, "", "+sve", Options, std::nullopt,
std::nullopt, CodeGenOptLevel::Aggressive));
if (!TM)
GTEST_SKIP();
Expand Down
5 changes: 3 additions & 2 deletions llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ class AMDGPUSelectionDAGTest : public testing::Test {

void SetUp() override {
std::string Error;
const Target *T = TargetRegistry::lookupTarget("amdgcn--amdpal", Error);
Triple TargetTriple("amdgcn--amdpal");
const Target *T = TargetRegistry::lookupTarget(TargetTriple, Error);
if (!T)
GTEST_SKIP();

TargetOptions Options;
TM = std::unique_ptr<TargetMachine>(T->createTargetMachine(
"amdgcn--amdpal", "gfx1010", "", Options, std::nullopt));
TargetTriple, "gfx1010", "", Options, std::nullopt));
if (!TM)
GTEST_SKIP();

Expand Down
3 changes: 2 additions & 1 deletion llvm/unittests/CodeGen/DroppedVariableStatsMIRTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ using namespace llvm;
namespace {

std::unique_ptr<TargetMachine>
createTargetMachine(std::string TT, StringRef CPU, StringRef FS) {
createTargetMachine(std::string TargetStr, StringRef CPU, StringRef FS) {
std::string Error;
Triple TT(TargetStr);
const Target *T = TargetRegistry::lookupTarget(TT, Error);
if (!T)
return nullptr;
Expand Down
Loading