[llvm] Fix llvm-tblgen on C++23 libc++ (PR #209783)
Nikhil Kalra via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 15 07:50:46 PDT 2026
https://github.com/nikalra created https://github.com/llvm/llvm-project/pull/209783
libc++ in C++23 mode evaluates make_unique eagerly, which requires InstructionMatcher to be defined at the constexpr call to make_unique. Currently, it's defined later in the file.
This patch moves the call to make_unique to the C++ file so that InstructionMatcher is fully defined at time of instantiation.
>From b3d280a16b3510a6c4e84c5d9e876f134a66a4f2 Mon Sep 17 00:00:00 2001
From: Nikhil Kalra <nkalra at apple.com>
Date: Wed, 15 Jul 2026 07:47:55 -0700
Subject: [PATCH] Fix llvm-tblgen on C++23 libc++
libc++ in C++23 mode evaluates make_unique eagerly, which requires InstructionMatcher
to be defined at the constexpr call to make_unique. Currently, it's defined later in
the file.
This patch moves the call to make_unique to the C++ file so that InstructionMatcher
is fully defined at time of instantiation.
---
.../TableGen/Common/GlobalISel/MatchTable/Matchers.cpp | 7 +++++++
.../utils/TableGen/Common/GlobalISel/MatchTable/Matchers.h | 5 +----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.cpp b/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.cpp
index 7f22cbfc7f58d..cc1089fc316c7 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.cpp
@@ -649,6 +649,13 @@ Error RuleMatcher::defineComplexSubOperand(StringRef SymbolicName,
return Error::success();
}
+InstructionMatcher &
+RuleMatcher::allocateInstructionMatcher(StringRef SymbolicName,
+ bool AllowNumOpsCheck) {
+ return *InsnMatchers.emplace_back(std::make_unique<InstructionMatcher>(
+ *this, InsnMatchers.size(), SymbolicName, AllowNumOpsCheck));
+}
+
InstructionMatcher &RuleMatcher::addInstructionMatcher(StringRef SymbolicName) {
auto &Res = allocateInstructionMatcher(SymbolicName);
Roots.push_back(&Res);
diff --git a/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.h b/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.h
index 8a09c0a23a4c0..b7ea01279eea9 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.h
+++ b/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matchers.h
@@ -373,10 +373,7 @@ class RuleMatcher : public Matcher {
friend class InstructionOperandMatcher;
InstructionMatcher &allocateInstructionMatcher(StringRef SymbolicName,
- bool AllowNumOpsCheck = true) {
- return *InsnMatchers.emplace_back(std::make_unique<InstructionMatcher>(
- *this, InsnMatchers.size(), SymbolicName, AllowNumOpsCheck));
- }
+ bool AllowNumOpsCheck = true);
public:
RuleMatcher(ArrayRef<SMLoc> SrcLoc, bool UsesRecordOperand = true);
More information about the llvm-commits
mailing list