[llvm] [TableGen] Assert that InstrMapping column values are valid (PR #182052)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 18 08:10:03 PST 2026


https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/182052

For an InstrMapping table with multiple ValueCols, assert that the
column value passed into the generated map functions matches one of the
columns.

This functionality is only used a few times by a few in-tree targets and
they all seem fine with this change.


>From a8250eb14ddc1f599405b78d982f15cf42f4ddc7 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Wed, 18 Feb 2026 16:05:41 +0000
Subject: [PATCH] [TableGen] Assert that InstrMapping column values are valid

For an InstrMapping table with multiple ValueCols, assert that the
column value passed into the generated map functions matches one of the
columns.

This functionality is only used a few times by a few in-tree targets and
they all seem fine with this change.
---
 llvm/utils/TableGen/CodeGenMapTable.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/utils/TableGen/CodeGenMapTable.cpp b/llvm/utils/TableGen/CodeGenMapTable.cpp
index 9724493642d75..d258d49a2e76c 100644
--- a/llvm/utils/TableGen/CodeGenMapTable.cpp
+++ b/llvm/utils/TableGen/CodeGenMapTable.cpp
@@ -455,7 +455,7 @@ void MapTableEmitter::emitMapFuncBody(raw_ostream &OS, unsigned TableSize) {
       OS << ")\n";
       OS << "    return Table[mid][" << I + 1 << "];\n";
     }
-    OS << "  return (uint32_t)-1U;";
+    OS << "  llvm_unreachable(\"Unrecognized column value!\");\n";
   } else {
     OS << "  return Table[mid][1];\n";
   }



More information about the llvm-commits mailing list