<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 11, 2016 at 3:32 PM, Justin Bogner <span dir="ltr"><<a href="mailto:mail@justinbogner.com" target="_blank" class="cremed">mail@justinbogner.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Kyle Butt via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="cremed">llvm-commits@lists.llvm.org</a>> writes:<br>
> Author: iteratee<br>
> Date: Fri Apr  8 15:35:01 2016<br>
> New Revision: 265842<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=265842&view=rev" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=265842&view=rev</a><br>
> Log:<br>
> Codegen: Factor tail duplication into a utility class. NFC<br>
><br>
> This is in preparation for tail duplication during block placement. See D18226.<br>
> This needs to be a utility class for 2 reasons. No passes may run after block<br>
> placement, and also, tail-duplication affects subsequent layout decisions, so<br>
> it must be interleaved with placement, and can't be separated out into its own<br>
> pass. The original pass is still useful, and now runs by delegating to the<br>
> utility class.<br>
><br>
> Added:<br>
>     llvm/trunk/include/llvm/CodeGen/TailDuplicator.h<br>
>     llvm/trunk/lib/CodeGen/TailDuplicator.cpp<br>
>       - copied, changed from r265841, llvm/trunk/lib/CodeGen/TailDuplication.cpp<br>
> Modified:<br>
>     llvm/trunk/lib/CodeGen/CMakeLists.txt<br>
>     llvm/trunk/lib/CodeGen/TailDuplication.cpp<br>
<br>
</span>We probably don't really need TailDuplicator and TailDuplication to be<br>
in different source files - the TailDuplication is basically just a few<br>
lines at this point and could pretty easily fit at the bottom of the<br>
source file with the utilities. <br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=265842&r1=265841&r2=265842&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=265842&r1=265841&r2=265842&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original)<br>
> +++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Fri Apr  8 15:35:01 2016<br>
> @@ -8,147 +8,52 @@<br>
</span> ...<br>
<span class="">>  bool TailDuplicatePass::runOnMachineFunction(MachineFunction &MF) {<br>
>    if (skipOptnoneFunction(*MF.getFunction()))<br>
>      return false;<br>
><br>
> -  TII = MF.getSubtarget().getInstrInfo();<br>
> -  TRI = MF.getSubtarget().getRegisterInfo();<br>
> -  MRI = &MF.getRegInfo();<br>
> -  MMI = getAnalysisIfAvailable<MachineModuleInfo>();<br>
> -  MBPI = &getAnalysis<MachineBranchProbabilityInfo>();<br>
> -<br>
> -  PreRegAlloc = MRI->isSSA();<br>
> -  RS.reset();<br>
> -  if (MRI->tracksLiveness() && TRI->trackLivenessAfterRegAlloc(MF))<br>
> -    RS.reset(new RegScavenger());<br>
> +  auto MMI = getAnalysisIfAvailable<MachineModuleInfo>();<br>
> +  auto MBPI = &getAnalysis<MachineBranchProbabilityInfo>();<br>
> +<br>
> +  Duplicator.initMF(MF, MMI, MBPI);<br>
<br>
</span>Why is this a member rather than just being on the stack here?<br>
Duplicator.initMF() fully reinitializes the object anyway, so it's not<br>
like we're avoiding some expensive setup or anything.<br>
<br>
This would also let us get rid of initMF and do the initialization in a<br>
constructor, which is simpler.<br></blockquote><div><br></div><div>I agree. I'll make it a constructor.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
>    bool MadeChange = false;<br>
> -  while (TailDuplicateBlocks(MF))<br>
> +  while (Duplicator.tailDuplicateBlocks(MF))<br>
>      MadeChange = true;<br>
><br>
>    return MadeChange;<br>
</div></div></blockquote></div><br></div></div>