<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 24 Oct 2017, at 10:35, Justin Bogner <<a href="mailto:mail@justinbogner.com" class="">mail@justinbogner.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Daniel Sanders via llvm-commits <</span><a href="mailto:llvm-commits@lists.llvm.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">llvm-commits@lists.llvm.org</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">> writes:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">Author: dsanders<br class="">Date: Tue Oct 24 10:08:43 2017<br class="">New Revision: 316463<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=316463&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=316463&view=rev</a><br class="">Log:<br class="">[globalisel][tablegen] Multi-insn emission requires that BuildMIAction<br class="">support not being linked to an InstructionMatcher. NFC<br class=""><br class="">When multi-instruction emission is supported, it will no longer be guaranteed<br class="">that every BuildMIAction has a corresponding matched instruction. BuildMIAction<br class="">should support not having one to cover the case where a rule produces more<br class="">instructions than it matched.<br class=""><br class=""><br class="">Modified:<br class=""> llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp<br class=""><br class="">Modified: llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp<br class="">URL:<br class=""><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp?rev=316463&r1=316462&r2=316463&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp?rev=316463&r1=316462&r2=316463&view=diff</a><br class="">==============================================================================<br class=""><br class="">--- llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp (original)<br class="">+++ llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp Tue Oct 24 10:08:43 2017<br class="">@@ -1753,18 +1753,18 @@ class BuildMIAction : public MatchAction<br class="">private:<br class=""> unsigned InsnID;<br class=""> const CodeGenInstruction *I;<br class="">- const InstructionMatcher &Matched;<br class="">+ const InstructionMatcher *Matched;<br class=""> std::vector<std::unique_ptr<OperandRenderer>> OperandRenderers;<br class=""><br class=""> /// True if the instruction can be built solely by mutating the opcode.<br class=""> bool canMutate(RuleMatcher &Rule) const {<br class="">- if (OperandRenderers.size() != Matched.getNumOperands())<br class="">+ if (OperandRenderers.size() != Matched->getNumOperands())<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Did you mean to check for !Matched here first?</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>You're right, it should be checked before this. Thanks for noticing that.</div><br class=""><blockquote type="cite" class=""><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""> return false;<br class=""><br class=""> for (const auto &Renderer : enumerate(OperandRenderers)) {<br class=""> if (const auto *Copy = dyn_cast<CopyRenderer>(&*Renderer.value())) {<br class=""> const OperandMatcher &OM = Rule.getOperandMatcher(Copy->getSymbolicName());<br class="">- if (&Matched != &OM.getInstructionMatcher() ||<br class="">+ if ((Matched != nullptr && Matched != &OM.getInstructionMatcher()) ||<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">If not, you've already executed UB by the time you do this check.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""> OM.getOperandIndex() != Renderer.index())<br class=""> return false;<br class=""> } else<br class="">@@ -1776,7 +1776,7 @@ private:<br class=""><br class="">public:<br class=""> BuildMIAction(unsigned InsnID, const CodeGenInstruction *I,<br class="">- const InstructionMatcher &Matched)<br class="">+ const InstructionMatcher *Matched)<br class=""> : InsnID(InsnID), I(I), Matched(Matched) {}<br class=""><br class=""> template <class Kind, class... Args><br class="">@@ -2651,7 +2651,7 @@ Expected<BuildMIAction &> GlobalISelEmit<br class=""> IsExtractSubReg = true;<br class=""> }<br class=""><br class="">- auto &DstMIBuilder = M.addAction<BuildMIAction>(0, DstI, InsnMatcher);<br class="">+ auto &DstMIBuilder = M.addAction<BuildMIAction>(0, DstI, &InsnMatcher);<br class=""><br class=""> // Render the explicit defs.<br class=""> for (unsigned I = 0; I < DstI->Operands.NumDefs; ++I) {<br class="">@@ -2802,7 +2802,7 @@ Expected<RuleMatcher> GlobalISelEmitter:<br class=""> M.defineOperand(OM0.getSymbolicName(), OM0);<br class=""> OM0.addPredicate<RegisterBankOperandMatcher>(RC);<br class=""><br class="">- auto &DstMIBuilder = M.addAction<BuildMIAction>(0, &DstI, InsnMatcher);<br class="">+ auto &DstMIBuilder = M.addAction<BuildMIAction>(0, &DstI, &InsnMatcher);<br class=""> DstMIBuilder.addRenderer<CopyRenderer>(0, DstIOperand.Name);<br class=""> DstMIBuilder.addRenderer<CopyRenderer>(0, Dst->getName());<br class=""> M.addAction<ConstrainOperandToRegClassAction>(0, 0, RC);<br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</blockquote></div></blockquote></div><br class=""></body></html>