[llvm] f7b6cc1 - [llvm-reduce] Set the target triple before parsing machine functions (#189989)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 2 11:55:50 PDT 2026
Author: Dominik Montada
Date: 2026-04-02T20:55:45+02:00
New Revision: f7b6cc1efab188a375a6932d879cb5510618d698
URL: https://github.com/llvm/llvm-project/commit/f7b6cc1efab188a375a6932d879cb5510618d698
DIFF: https://github.com/llvm/llvm-project/commit/f7b6cc1efab188a375a6932d879cb5510618d698.diff
LOG: [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.
Added:
llvm/test/tools/llvm-reduce/mir/set-triple-on-module.mir
Modified:
llvm/tools/llvm-reduce/ReducerWorkItem.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-reduce/mir/set-triple-on-module.mir b/llvm/test/tools/llvm-reduce/mir/set-triple-on-module.mir
new file mode 100644
index 0000000000000..1f1e6b145bd32
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/mir/set-triple-on-module.mir
@@ -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
+...
diff --git a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
index c479233a712e7..b7e8118ea73a2 100644
--- a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
+++ b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
@@ -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);
More information about the llvm-commits
mailing list