@@ -1820,7 +1820,8 @@ bool TreePatternNode::UpdateNodeTypeFromInst(unsigned ResNo,
18201820 TreePattern &TP) {
18211821 // The 'unknown' operand indicates that types should be inferred from the
18221822 // context.
1823- if (Operand->isSubClassOf (" unknown_class" ))
1823+ if (Operand->isSubClassOf (" unknown_class" ) ||
1824+ Operand->isSubClassOf (" PointerLikeRegClass" ))
18241825 return false ;
18251826
18261827 // The Operand class specifies a type directly.
@@ -3020,7 +3021,13 @@ TreePatternNodePtr TreePattern::ParseTreePattern(const Init *TheInit,
30203021 return nullptr ;
30213022 }
30223023
3023- auto ParseCastOperand = [this ](const DagInit *Dag, StringRef OpName) {
3024+ auto ParseCastOperand = [this ](const DagInit *Dag,
3025+ StringRef OpName) -> TreePatternNodePtr {
3026+ if (Dag->getNumArgs () == 0 ) {
3027+ error (" type cast should not have zero arguments!" );
3028+ return nullptr ;
3029+ }
3030+
30243031 if (Dag->getNumArgs () != 1 )
30253032 error (" Type cast only takes one operand!" );
30263033
@@ -3034,6 +3041,8 @@ TreePatternNodePtr TreePattern::ParseTreePattern(const Init *TheInit,
30343041 // If the operator is a list (of value types), then this must be "type cast"
30353042 // of a leaf node with multiple results.
30363043 TreePatternNodePtr New = ParseCastOperand (Dag, OpName);
3044+ if (!New)
3045+ return nullptr ;
30373046
30383047 size_t NumTypes = New->getNumTypes ();
30393048 if (LI->empty () || LI->size () != NumTypes)
@@ -3059,6 +3068,8 @@ TreePatternNodePtr TreePattern::ParseTreePattern(const Init *TheInit,
30593068 // If the operator is a ValueType, then this must be "type cast" of a leaf
30603069 // node.
30613070 TreePatternNodePtr New = ParseCastOperand (Dag, OpName);
3071+ if (!New)
3072+ return nullptr ;
30623073
30633074 if (New->getNumTypes () != 1 )
30643075 error (" ValueType cast can only have one type!" );
@@ -3608,10 +3619,15 @@ void CodeGenDAGPatterns::FindPatternInputsAndOutputs(
36083619 // If this is not a set, verify that the children nodes are not void typed,
36093620 // and recurse.
36103621 for (unsigned i = 0 , e = Pat->getNumChildren (); i != e; ++i) {
3611- if (Pat->getChild (i).getNumTypes () == 0 )
3622+ TreePatternNodePtr Child = Pat->getChildShared (i);
3623+ if (!Child) {
3624+ I.error (" child node at index " + Twine (i) + " is null!" );
3625+ continue ;
3626+ }
3627+ if (Child->getNumTypes () == 0 )
36123628 I.error (" Cannot have void nodes inside of patterns!" );
3613- FindPatternInputsAndOutputs (I, Pat-> getChildShared (i) , InstInputs,
3614- InstResults, InstImpResults);
3629+ FindPatternInputsAndOutputs (I, Child , InstInputs, InstResults ,
3630+ InstImpResults);
36153631 }
36163632
36173633 // If this is a non-leaf node with no children, treat it basically as if
0 commit comments