[PATCH] D150633: [X86]check that Uses, Defs are same for entries in memory folding table
Wang, Xin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 16 19:54:16 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG744b12adb4ec: [X86]check that Uses, Defs are same for entries in memory folding table (authored by XinWang10).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150633/new/
https://reviews.llvm.org/D150633
Files:
llvm/utils/TableGen/X86FoldTablesEmitter.cpp
Index: llvm/utils/TableGen/X86FoldTablesEmitter.cpp
===================================================================
--- llvm/utils/TableGen/X86FoldTablesEmitter.cpp
+++ llvm/utils/TableGen/X86FoldTablesEmitter.cpp
@@ -107,6 +107,21 @@
OS << SimplifiedAttrs << "},\n";
}
+#ifndef NDEBUG
+ // Check that Uses and Defs are same after memory fold.
+ void checkCorrectness() const {
+ auto &RegInstRec = *RegInst->TheDef;
+ auto &MemInstRec = *MemInst->TheDef;
+ auto ListOfUsesReg = RegInstRec.getValueAsListOfDefs("Uses");
+ auto ListOfUsesMem = MemInstRec.getValueAsListOfDefs("Uses");
+ auto ListOfDefsReg = RegInstRec.getValueAsListOfDefs("Defs");
+ auto ListOfDefsMem = MemInstRec.getValueAsListOfDefs("Defs");
+ if (ListOfUsesReg != ListOfUsesMem || ListOfDefsReg != ListOfDefsMem)
+ report_fatal_error("Uses/Defs couldn't be changed after folding " +
+ RegInstRec.getName() + " to " +
+ MemInstRec.getName());
+ }
+#endif
};
// NOTE: We check the fold tables are sorted in X86InstrFoldTables.cpp by the enum of the
@@ -600,6 +615,20 @@
&(Target.getInstruction(MemInstIter)), Entry.Strategy, true);
}
+#ifndef NDEBUG
+ auto CheckMemFoldTable = [](const FoldTable &Table) -> void {
+ for (const auto &Record : Table) {
+ auto &FoldEntry = Record.second;
+ FoldEntry.checkCorrectness();
+ }
+ };
+ CheckMemFoldTable(Table2Addr);
+ CheckMemFoldTable(Table0);
+ CheckMemFoldTable(Table1);
+ CheckMemFoldTable(Table2);
+ CheckMemFoldTable(Table3);
+ CheckMemFoldTable(Table4);
+#endif
// Print all tables.
printTable(Table2Addr, "Table2Addr", OS);
printTable(Table0, "Table0", OS);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150633.522886.patch
Type: text/x-patch
Size: 1764 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230517/ca1c00ce/attachment.bin>
More information about the llvm-commits
mailing list