[PATCH] D147706: [TableGen] Fix null pointer dereferences in TreePattern::ParseTreePattern()
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 9 18:06:28 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c07aa75b961: [TableGen] Fix null pointer dereferences in TreePattern::ParseTreePattern() (authored by SweetVishnya, committed by craig.topper).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147706/new/
https://reviews.llvm.org/D147706
Files:
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
Index: llvm/utils/TableGen/CodeGenDAGPatterns.cpp
===================================================================
--- llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -2897,16 +2897,20 @@
Init *II = BI->convertInitializerTo(IntRecTy::get(RK));
if (!II || !isa<IntInit>(II))
error("Bits value must be constants!");
- return ParseTreePattern(II, OpName);
+ return II ? ParseTreePattern(II, OpName) : nullptr;
}
DagInit *Dag = dyn_cast<DagInit>(TheInit);
if (!Dag) {
TheInit->print(errs());
error("Pattern has unexpected init kind!");
+ return nullptr;
}
DefInit *OpDef = dyn_cast<DefInit>(Dag->getOperator());
- if (!OpDef) error("Pattern has unexpected operator type!");
+ if (!OpDef) {
+ error("Pattern has unexpected operator type!");
+ return nullptr;
+ }
Record *Operator = OpDef->getDef();
if (Operator->isSubClassOf("ValueType")) {
@@ -3480,7 +3484,8 @@
DefInit *Val = dyn_cast<DefInit>(Dest->getLeafValue());
if (!Val || !Val->getDef()->isSubClassOf("Register"))
I.error("implicitly defined value should be a register!");
- InstImpResults.push_back(Val->getDef());
+ if (Val)
+ InstImpResults.push_back(Val->getDef());
}
return;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147706.520876.patch
Type: text/x-patch
Size: 1308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230510/1044ad85/attachment.bin>
More information about the llvm-commits
mailing list