[PATCH] D133257: [GISel] Fix match tree emitter.
Kai Nacke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 3 10:37:40 PDT 2022
Kai updated this revision to Diff 457806.
Kai added a comment.
Remove unused `Inserted` variable.
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
@@ -24,9 +24,9 @@
public:
void declare(StringRef Name, StringRef Expansion) {
- bool Inserted = Expansions.try_emplace(Name, Expansion).second;
- assert(Inserted && "Declared variable twice");
- (void)Inserted;
+ // Duplicates are not inserted. The expansion refers to different operands
+ // but to the same virtual register.
+ Expansions.try_emplace(Name, Expansion);
}
std::string lookup(StringRef Variable) const {
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.457806.patch
Type: text/x-patch
Size: 2575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220903/d5dd8488/attachment.bin>
More information about the llvm-commits
mailing list