]> granicus.if.org Git - llvm/commitdiff
[globalisel][tablegen] Fix future undefined behaviour in r316463.
authorDaniel Sanders <daniel_l_sanders@apple.com>
Tue, 24 Oct 2017 18:11:54 +0000 (18:11 +0000)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Tue, 24 Oct 2017 18:11:54 +0000 (18:11 +0000)
I missed a dereference of `Matched` that preceeded the new check. Thanks to
Justin Bogner for spotting it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316480 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/GlobalISelEmitter.cpp

index e472c8c43bfdf66c54eb89c9154aed5f32fd8d4d..f75456db87059dab3ee0e789f6183f5c64e748f1 100644 (file)
@@ -1758,13 +1758,16 @@ private:
 
   /// True if the instruction can be built solely by mutating the opcode.
   bool canMutate(RuleMatcher &Rule) const {
+    if (!Matched)
+      return false;
+
     if (OperandRenderers.size() != Matched->getNumOperands())
       return false;
 
     for (const auto &Renderer : enumerate(OperandRenderers)) {
       if (const auto *Copy = dyn_cast<CopyRenderer>(&*Renderer.value())) {
         const OperandMatcher &OM = Rule.getOperandMatcher(Copy->getSymbolicName());
-        if ((Matched != nullptr && Matched != &OM.getInstructionMatcher()) ||
+        if (Matched != &OM.getInstructionMatcher() ||
             OM.getOperandIndex() != Renderer.index())
           return false;
       } else