<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Prathamesh,<div class=""><br class=""></div><div class="">What is the machine verifier error that you get?</div><div class=""><br class=""></div><div class="">I am wondering if the issue is not in the machine verifier itself in the sense that it is somewhat reasonable to have calls “document” which memory slot they access.</div><div class=""><br class=""></div><div class="">I am not fan of the idea of removing the addition of the memory operands because:</div><div class="">1. This was part of the interface contract</div><div class="">2. This may prevent unfolding to work</div><div class=""><br class=""></div><div class="">For #1 see that comment on <span style="font-family: Menlo; font-size: 11px;" class="">TargetInstrInfo::foldMemoryOperandImpl</span>:</div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> /// Target-independent code in foldMemoryOperand will</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> /// take care of adding a MachineMemOperand to the newly created instruction.</span></div></div><div class=""><div><br class=""></div><div>For #2, I am guessing folding at one point and unfolding later is a rare enough thing that we may not care.</div><div><br class=""></div><div>Cheers,</div><div>-Quentin</div><div><br class=""><blockquote type="cite" class=""><div class="">On Sep 7, 2020, at 2:17 AM, Prathamesh Kulkarni via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi,<br class="">While working on <a href="https://reviews.llvm.org/D79785" class="">https://reviews.llvm.org/D79785</a>, we wanted to define<br class="">foldMemoryOperandImpl hook for Thumb1, that folds load, indirect call<br class="">to direct call tLDRpci, tBLX -> tBL. This triggered an assertion<br class="">error with expensive checks turned on in MachineVerifier because the<br class="">newly created tBL insn by<br class="">Thumb1InstrInfo::foldMemoryOperandImpl had memory operands of LoadMI<br class="">attached by TargetInstrInfo::foldMemoryOperand, which is done<br class="">unconditionally:<br class=""><br class="">// Copy the memoperands from the load to the folded instruction.<br class="">if (MI.memoperands_empty()) {<br class=""> NewMI->setMemRefs(MF, LoadMI.memoperands())<br class=""><br class="">In this case, we don't want the memory loads to be added to MI from<br class="">LoadMI. Should there be some mechanism for target specific<br class="">foldMemoryOperandImpl hook to signal to foldMemoryOperand to not add<br class="">memory operands from LoadMI ?<br class=""><br class="">I was wondering if either of these approaches look good ?<br class="">(a) Make foldMemoryOperandImpl return two values via std::pair or use<br class="">OUT param (reference). The first is the MI instruction, and second a<br class="">bool whether or not to add memory operands from LoadMI. This will<br class="">however require adjusting other targets that override<br class="">foldMemoryOperandImpl. Would that be OK ?<br class=""><br class="">(b) Define another method in TargetInstrInfo that decides whether or<br class="">not to add memory operands to the MI returned by<br class="">foldMemoryOperandImpl, which will not require to modify existing code,<br class="">but not sure if it's a good idea ?<br class=""><br class="">(c) Make foldMemoryOperandImpl itself add memory operands, which will<br class="">require somewhat more complicated changes in targets that already<br class="">implement foldMemoryOperandImpl.<br class=""><br class="">I would be grateful for suggestions on how to proceed.<br class=""><br class="">Thanks,<br class="">Prathamesh<br class="">_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></div></blockquote></div><br class=""></div></body></html>