[llvm] [TableGen] Fix validateOperandClass for non Phyical Reg (PR #118146)
Jinsong Ji via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 29 19:20:38 PST 2024
https://github.com/jsji updated https://github.com/llvm/llvm-project/pull/118146
>From 9cc10d463928d0e3adc454294402cacc56eff640 Mon Sep 17 00:00:00 2001
From: Jinsong Ji <jinsong.ji at intel.com>
Date: Sat, 30 Nov 2024 01:54:03 +0100
Subject: [PATCH 1/2] Fix validateOperandClass for non Phyical Reg
https://github.com/llvm/llvm-project/commit/b71704436e61
Rewrote the register operands handling,
but the Table only contains physical regs, we will SEGV when there are
non physical regs.
---
llvm/utils/TableGen/AsmMatcherEmitter.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 28efd780c5c615..1823783e82be4a 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -2522,8 +2522,9 @@ static void emitValidateOperandClass(const CodeGenTarget &Target,
for (auto &MatchClassName : Table)
OS << " " << MatchClassName << ",\n";
OS << " };\n\n";
- OS << " MatchClassKind OpKind = "
- "(MatchClassKind)Table[Operand.getReg().id()];\n";
+ OS << " auto RegID=Operand.getReg().id();\n";
+ OS << " MatchClassKind OpKind = Register::isPhysicalRegister(RegID)?"
+ "(MatchClassKind)Table[RegID]: InvalidMatchClass;\n";
OS << " return isSubclass(OpKind, Kind) ? "
<< "(unsigned)MCTargetAsmParser::Match_Success :\n "
<< " getDiagKindFromRegisterClass(Kind);\n }\n\n";
>From 5b129ec407921fde8d33bc1fac35788fff270611 Mon Sep 17 00:00:00 2001
From: Jinsong Ji <jinsong.ji at intel.com>
Date: Sat, 30 Nov 2024 04:11:19 +0100
Subject: [PATCH 2/2] Use MCRegister
---
llvm/utils/TableGen/AsmMatcherEmitter.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 1823783e82be4a..b0804d35fadd56 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -2523,7 +2523,7 @@ static void emitValidateOperandClass(const CodeGenTarget &Target,
OS << " " << MatchClassName << ",\n";
OS << " };\n\n";
OS << " auto RegID=Operand.getReg().id();\n";
- OS << " MatchClassKind OpKind = Register::isPhysicalRegister(RegID)?"
+ OS << " MatchClassKind OpKind = MCRegister::isPhysicalRegister(RegID)?"
"(MatchClassKind)Table[RegID]: InvalidMatchClass;\n";
OS << " return isSubclass(OpKind, Kind) ? "
<< "(unsigned)MCTargetAsmParser::Match_Success :\n "
More information about the llvm-commits
mailing list