Skip to content

Commit 2ba4537

Browse files
committed
[TableGen] Fix inconsistent indexing of the RegistersByName table.
Previously, the initialization of this table in CodeGenRegBank() indexed the table with the name of the tblgen def, while the only user of the table in CompressInstEmitter::validateRegister() indexed it using the name of the tblgen Def. Apparently these were the same essentially all of the time, so the issue never manifested. This patch standardizes on indexing using the tblgen def name, as that is guaranteed to be unique. This issue impacted the forthcoming implementation of the RISC Y extension (CHERI), in which the capability registers have the same AsmName as the GPRs, causing llvm-tblgen assertion failures.
1 parent 9e3bbbb commit 2ba4537

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/utils/TableGen/Common/CodeGenRegisters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ CodeGenRegBank::CodeGenRegBank(const RecordKeeper &Records,
11891189
// causes some failures in MIPS - perhaps they have duplicate register name
11901190
// entries? (or maybe there's a reason for it - I don't know much about this
11911191
// code, just drive-by refactoring)
1192-
RegistersByName.try_emplace(Reg.TheDef->getValueAsString("AsmName"), &Reg);
1192+
RegistersByName.try_emplace(Reg.getName().lower(), &Reg);
11931193

11941194
// Precompute all sub-register maps.
11951195
// This will create Composite entries for all inferred sub-register indices.

0 commit comments

Comments
 (0)