From: Daniel Sanders Date: Tue, 24 Oct 2017 18:11:54 +0000 (+0000) Subject: [globalisel][tablegen] Fix future undefined behaviour in r316463. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab1d119154e8a10be3d8e4731cdb23b3c0ff81d7;p=platform%2Fupstream%2Fllvm.git [globalisel][tablegen] Fix future undefined behaviour in r316463. I missed a dereference of `Matched` that preceeded the new check. Thanks to Justin Bogner for spotting it. llvm-svn: 316480 --- diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp index e472c8c..f75456d 100644 --- a/llvm/utils/TableGen/GlobalISelEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp @@ -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(&*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