[llvm-commits] [llvm] r111221 - in /llvm/trunk: lib/CodeGen/MachineBasicBlock.cpp lib/CodeGen/PHIElimination.cpp test/CodeGen/ARM/code-placement.ll test/CodeGen/X86/lsr-reuse.ll

Jakob Stoklund Olesen stoklund at 2pi.dk
Tue Aug 17 00:11:04 PDT 2010


On Aug 16, 2010, at 6:20 PM, Evan Cheng wrote:

> Author: evancheng
> Date: Mon Aug 16 20:20:36 2010
> New Revision: 111221
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=111221&view=rev
> Log:
> PHI elimination should not break back edge. It can cause some significant code placement issues. rdar://8263994

> Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=111221&r1=111220&r2=111221&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
> +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Mon Aug 16 20:20:36 2010
> @@ -439,6 +439,14 @@
>   if (TII->AnalyzeBranch(*this, TBB, FBB, Cond))
>     return NULL;
> 
> +  // Avoid splitting backedges of loops. It would introduce small out-of-line
> +  // blocks into the loop which is very bad for code placement.
> +  if (this == Succ)
> +    return NULL;
> +  MachineLoopInfo *MLI = P->getAnalysisIfAvailable<MachineLoopInfo>();
> +  if (MLI->isLoopHeader(Succ))
> +    return NULL;
> +

Careful you don't dereference a NULL pointer. You can't count on MLI being available here.

Also, I think the decision to not split a back edge should go in PHIElimination as a policy decision. Other callers of SplitCriticalEdge may have really good reasons for splitting a back edge. That should be allowed.

/jakob

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100817/7f807197/attachment.bin>


More information about the llvm-commits mailing list