<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class="">The shrink-wrapping pass landed in r<span style="font-family: Menlo; font-size: 11px;" class="">236507</span>. This email gives a brief survey on how you can use it and for out-of-tree target, how you have to update the TargetFrameLowering to be able to compile.</div><div class=""><br class=""></div><div class="">To know more about the goal of the shrink-wrapping pass, look at the description in <a href="http://reviews.llvm.org/D9210" class="">http://reviews.llvm.org/D9210</a>. The short story is that shrink-wrapping provides a cheaper placement, in terms of frequency, of the prologue and epilogue code sequence.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><font size="2" class="">** Out-of-Tree Target: TargetFrameLowering API Changes **</font></div><div class=""><br class=""></div><div class="">This section helps the maintainers of Out-of-Tree targets to update their code to the latest APIs. It also describes why those changes are necessary and thus, may be useful for anyone that want to use the shrink-wrapping pass. The shrink-wrapping pass is disabled by default (see <i class="">How Can I Use Shrink-Wrapping?</i> for more details).</div><div class=""><br class=""></div><div class="">With the introduction of shrink-wrapping some APIs in <font face="Menlo" style="font-size: 11px;" class=""><b class="">TargetFrameLowering</b></font> needed to be updated to accommodate the fact, that the prologue block is not necessarily the entry block of the function.</div><div class=""><br class=""></div><div class="">The impacted functions are:</div><div class=""><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class="">virtual void emitPrologue(MachineFunction &MF,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""> <b class=""><i class="">MachineBasicBlock &MBB</i></b>) const = 0;</div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;" class=""><div style="margin: 0px;" class="">virtual void adjustForSegmentedStacks(MachineFunction &MF,</div><div style="margin: 0px;" class=""> <b class=""><i class="">MachineBasicBlock &PrologueMBB</i></b>) const {}</div><div style="margin: 0px;" class=""><div style="margin: 0px;" class="">virtual void adjustForHiPEPrologue(MachineFunction &MF,</div><div style="margin: 0px;" class=""> <b class=""><i class="">MachineBasicBlock &PrologueMBB</i></b>) const {}</div><div style="margin: 0px;" class=""><div style="margin: 0px;" class="">virtual void</div><div style="margin: 0px;" class="">adjustForFrameAllocatePrologue(MachineFunction &MF,</div><div style="margin: 0px;" class=""> <b class=""><i class="">MachineBasicBlock &PrologueMBB</i></b>) const {}</div></div></div></div><div class=""><br class=""></div><div class="">The additional MachineBasicBlock parameter represents the basic-block where the prologue will be inserted. When shrink-wrapping is disabled (the default), you can assert that this block is the same as the entry block of the MachineFunction.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><font size="2" class="">** How Can I Use Shrink-Wrapping? **</font></div><div class=""><font size="2" class=""><br class=""></font></div><div class=""><font size="2" class="">* Fix emitPrologue and emitEpilogue *</font></div><div class=""><br class=""></div><div class="">To be able to use the shrink-wrapping you need to make sure emitPrologue (respectively emitEpilogue) works on basic block that are not necessarily the entry block (rest. exit blocks) of the function. In particular, the block used for the epilogue may be empty.</div><div class="">You can have a look at the targeting of AArch64 in r<span style="font-family: Menlo; font-size: 11px;" class="">236507</span> to see what it takes to implement such support.</div><div class=""><br class=""></div><div class=""><font size="2" class="">* Play with Shrink-Wrapping *</font></div><div class=""><br class=""></div><div class="">The shrink-wrapping pass can be enabled via the command switch: (-mllvm) -enable-shrink-wrap.</div><div class="">You can also see how it applies by using the "(-mllvm) -stats” switch, and look for shrink-wrap output.</div><div class="">Finally, you can look at what it does by using “(-mllvm) -debug-only=shrink-wrap”.</div><div class=""><br class=""></div><div class="">Please file any bug that you might encounter.</div><div class=""><br class=""></div><div class=""><font size="2" class="">* How Do I Turn This On By Default *</font></div><div class=""><br class=""></div><div class="">You can turn the shrink-wrapping pass on by default for your target, by setting the field <span style="font-family: Menlo; font-size: 11px;" class="">EnableShrinkWrap </span>to<span style="font-family: Menlo; font-size: 11px;" class=""> true </span>in the your derived class of<span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">TargetPassConfig.</span></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class=""><br class=""></span></div><div class="">Note: The (-mllvm) -enable-shrink-wrap switch overrides the default setting for the current run.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><font size="2" class="">** What Is Next? **</font></div><div class=""><br class=""></div><div class="">Here are a few items for futur direction of the shrink-wrapping pass:</div><div class="">- Enable it by default for AArch64.</div><div class="">- Implement ARM/X86 support.</div><div class="">- Enable it by default for ARM/X86.</div><div class="">- Refine the shrink-wrapping pass to support multi insertion point for the prologue and epilogue.</div><div class=""><br class=""></div><div class="">The last item should be driven by motivating examples. I do not what to complicate the implementation is it is not proven beneficial.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><font size="2" class="">** AArch64 Developers: We Need Your Help **</font></div><div class=""><br class=""></div><div class="">As r<span style="font-family: Menlo; font-size: 11px;" class="">236507</span> the shrink-wrapping support is implemented in AArch64. I would like AArch64 developers to give it a try and report any bug/regression they might see. The idea would be to enable the shrink-wrapping pass by default based on those feedbacks.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">-Quentin</div></body></html>