Please see my replies embedded.<div><br></div><div>Thanks,</div><div>Jatin<br><br>On Thursday, May 18, 2017, Matthias Braun <<a href="mailto:mbraun@apple.com">mbraun@apple.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>- Please do not add any more uses of the LiveVariables pass! It is deprecated and only kept around for one last pass that isn't converted. All new code should use LiveIntervalAnalysis!</div><div>- Kill flags are optional: If they are present they must be correct, but it is legal to have a value die without having a kill flag on the operand. So often a simple fix is to clear out the kill flags from instructions you touch instead of recomputing them. The only downside is that some later passes will only perform the maximum amount of optimization will kill flags present [1]</div><div><br></div></div></blockquote><div> </div><div>PMDataManager keeps tracks of analysis requirements explicitely set by a perticular pass by calling getAnaysisUsage for that pass i.e to either run a specified analysis if its needed or preserve already performed analysis through the execution of the pass if transformation is sure about not dirtying the already computed analysis or simply allow invalidation of analysis.</div><div><br></div><div>Once a pass in the optimization pipeline does not preserve already computed analysis by calling setPreservedAll then any transformation occuring later down the pipeline must recompute the required analysis.</div><div><br></div><div>However, if a pass does not call setPreserveAll then it does not own the responsibility of updating the already computed analysis if it dirty it as a side effect of some other transformation. This is exactly what is happening in this case.  Livevariable analysis was called up the pipeline so that MachineCSE could use the needed analysis. Peephole optimization which is called later in the pipeline does not preserve not requires live variables and dirty the liveness information as a side effect.</div><div><br></div><div>All is correct nothing wrong in the flow as if any other pass in pipeline which need liveness will mention the same in its getAnalysisUsage and since perticular analysis is not preserved by pass ahead of it in the optimization pipeline hence it will get recomputed during schedulePass.</div><div><br></div><div>Now, MachineInstrVerifier pass which is a dumb validation pass always check for consistency of liveness information attached to IR even if transformation which ran just before it does not either require or preserve i.e may invalidate liveness as a side effect.</div><div><br></div><div>Please refer to following citation from llvm documentation</div><div><br></div><div><a href="http://llvm.org/docs/WritingAnLLVMPass.html#id38">http://llvm.org/docs/WritingAnLLVMPass.html#id38</a></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>- Matthias</div><div><br></div><div>[1] Long term we want to get rid of kill flags completely which should clean up a lot of code. But that is unfortunately a very tedious process, last time I tried to switch the biggest user of killflags (RegisterScavenger) to a new algorithm a powerpc stage2 buildbot broke and I never figured out why...</div></div></blockquote><div><br></div><div>Ok. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div style="word-wrap:break-word"><br></div><br><div><blockquote type="cite"><div>On May 17, 2017, at 11:29 AM, Nemanja Ivanovic via llvm-dev <<a href="javascript:_e(%7B%7D,'cvml','llvm-dev@lists.llvm.org');" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br><div><div dir="ltr">This kind of sounds like the peephole optimization should really be resetting the kill flag if it's extending the live range of a [virtual] register (which is what the description here seems to imply).<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 5, 2017 at 9:54 AM, Jatin Bhateja via llvm-dev <span dir="ltr"><<a href="javascript:_e(%7B%7D,'cvml','llvm-dev@lists.llvm.org');" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Devs,<div><br></div><div>Machine Instruction verifier pass always validates Live variable info associated with MachineInstr along with other checks.</div><div><br></div><div>Please consider following scenario (w.r.t bugZilla <span style="font-size:12.8px;white-space:nowrap">32583)</span></div><div><span style="font-size:12.8px;white-space:nowrap"><br></span></div><div><span style="font-size:12.8px;white-space:nowrap">1/  MachineCSE pass may prohibit optimising out a common sub-expression for instruction using physical registers </span></div><div><span style="font-size:12.8px;white-space:nowrap">by looking at the LiveIn info of successor basic blocks. </span></div><div><span style="font-size:12.8px;white-space:nowrap"><br></span></div><div><span style="font-size:12.8px;white-space:nowrap">2/ Which means we need Live Variables analysis to happen prior to executing MachineCSE.</span></div><div><span style="font-size:12.8px;white-space:nowrap"><br></span></div><div><span style="font-size:12.8px;white-space:nowrap">3/ Live variable analysis associates Kill/def information with MachineOperands.</span></div><div><span style="font-size:12.8px;white-space:nowrap"><br></span></div><div><span style="font-size:12.8px;white-space:nowrap">4/ In one of the regression Peephole optimizer (which does not uses liveness information)</span><br></div><div><span style="font-size:12.8px;white-space:nowrap">performs certain transformations over MachineBasicBlock which potentially dirties the</span></div><div><span style="font-size:12.8px;white-space:nowrap">liveness information computed early. </span></div><div><span style="font-size:12.8px;white-space:nowrap"><br></span></div><div><span style="font-size:12.8px;white-space:nowrap">5/ Now, when Machine Instruction verifier kicks in after Peephole optimizer it reports use after kill violation</span></div><div><span style="font-size:12.8px;white-space:nowrap">over a particular instruction.  </span></div><div><br></div><div>Can we selectively turn of the live variable checking in Machine instruction verifier till next Live variable pass is invoked (as per the need of following pass).<br></div><div><br></div><div>This may sound like defeating the purpose of machine instruction verifier which checks instruction validity against different parameters after each transformation pass, but if a pass does not use Live ness information should not be constrained to do other transformations which may dirty the live ness information.</div><div><br></div><div>Please provide you comments.</div><div><br></div><div>Thanks,</div><div>Jatin Bhateja</div></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="javascript:_e(%7B%7D,'cvml','llvm-dev@lists.llvm.org');" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
______________________________<wbr>_________________<br>LLVM Developers mailing list<br><a href="javascript:_e(%7B%7D,'cvml','llvm-dev@lists.llvm.org');" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br></div></blockquote></div><br></div></blockquote><div> </div></div>