[PATCH] D133257: [GISel] Fix match tree emitter.
Kai Nacke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 3 10:28:58 PDT 2022
Kai updated this revision to Diff 457803.
Kai added a comment.
Added missing test.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133257/new/
https://reviews.llvm.org/D133257
Files:
llvm/test/TableGen/GICombinerEmitter/match-tree.td
llvm/utils/TableGen/GlobalISel/CodeExpansions.h
llvm/utils/TableGen/GlobalISel/GIMatchTree.cpp
Index: llvm/utils/TableGen/GlobalISel/GIMatchTree.cpp
===================================================================
--- llvm/utils/TableGen/GlobalISel/GIMatchTree.cpp
+++ llvm/utils/TableGen/GlobalISel/GIMatchTree.cpp
@@ -762,13 +762,14 @@
void GIMatchTreeVRegDefPartitioner::generatePartitionSelectorCode(
raw_ostream &OS, StringRef Indent) const {
- OS << Indent << "Partition = -1\n"
- << Indent << "if (MIs.size() <= NewInstrID) MIs.resize(NewInstrID + 1);\n"
+ OS << Indent << "Partition = -1;\n"
+ << Indent << "if (MIs.size() <= " << NewInstrID << ") MIs.resize("
+ << (NewInstrID + 1) << ");\n"
<< Indent << "MIs[" << NewInstrID << "] = nullptr;\n"
- << Indent << "if (MIs[" << InstrID << "].getOperand(" << OpIdx
- << ").isReg()))\n"
+ << Indent << "if (MIs[" << InstrID << "]->getOperand(" << OpIdx
+ << ").isReg())\n"
<< Indent << " MIs[" << NewInstrID << "] = MRI.getVRegDef(MIs[" << InstrID
- << "].getOperand(" << OpIdx << ").getReg()));\n";
+ << "]->getOperand(" << OpIdx << ").getReg());\n";
for (const auto &Pair : ResultToPartition)
OS << Indent << "if (MIs[" << NewInstrID << "] "
Index: llvm/utils/TableGen/GlobalISel/CodeExpansions.h
===================================================================
--- llvm/utils/TableGen/GlobalISel/CodeExpansions.h
+++ llvm/utils/TableGen/GlobalISel/CodeExpansions.h
@@ -25,7 +25,8 @@
public:
void declare(StringRef Name, StringRef Expansion) {
bool Inserted = Expansions.try_emplace(Name, Expansion).second;
- assert(Inserted && "Declared variable twice");
+ // Duplicates are not inserted. The expansion refers to different operands
+ // but to the same virtual register.
(void)Inserted;
}
Index: llvm/test/TableGen/GICombinerEmitter/match-tree.td
===================================================================
--- llvm/test/TableGen/GICombinerEmitter/match-tree.td
+++ llvm/test/TableGen/GICombinerEmitter/match-tree.td
@@ -1,6 +1,11 @@
// RUN: llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \
// RUN: -combiners=MyCombinerHelper -gicombiner-stop-after-build %s \
// RUN: -o %t.inc | FileCheck %s
+//
+// This only checks that the code emitter does not crash.
+// RUN: llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \
+// RUN: -combiners=MyCombinerHelper %s \
+// RUN: -o %t.inc
include "llvm/Target/Target.td"
include "llvm/Target/GlobalISel/Combine.td"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133257.457803.patch
Type: text/x-patch
Size: 2477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220903/24939b8e/attachment-0001.bin>
More information about the llvm-commits
mailing list