[llvm-reduce] Set the target triple before parsing machine functions (#189989)

Make sure that the module has a target triple set before trying to parse
machine functions. This can be required for (downstream) targets if MIR
parsing relies on features guarded by the target triple.
This commit is contained in:
Dominik Montada 2026-04-02 20:55:45 +02:00 committed by GitHub
parent fdc54c9a1e
commit f7b6cc1efa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,16 @@
# REQUIRES: x86-registered-target
# RUN: llvm-reduce -simplify-mir -mtriple="x86_64-unknown-linux-gnu" --test FileCheck --test-arg --check-prefix=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
# RUN: FileCheck %s < %t
# CHECK-INTERESTINGNESS: RET64
# CHECK: target triple = "x86_64-unknown-linux-gnu"
# CHECK: name: func
---
name: func
body: |
bb.0:
RET64
...

View File

@ -859,6 +859,9 @@ llvm::parseReducerWorkItem(StringRef ToolName, StringRef Filename,
std::unique_ptr<Module> M = MParser->parseIRModule(SetDataLayout);
if (!TheTriple.empty())
M->setTargetTriple(TheTriple);
MMM->MMI = std::make_unique<MachineModuleInfo>(TM.get());
MParser->parseMachineFunctions(*M, *MMM->MMI);
MMM->M = std::move(M);