[llvm] r309422 - Fix conditional tail call branch folding when both edges are the same

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 09:42:37 PDT 2017


On Fri, Jul 28, 2017 at 12:48 PM, Reid Kleckner via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: rnk
> Date: Fri Jul 28 12:48:40 2017
> New Revision: 309422
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309422&view=rev
> Log:
> Fix conditional tail call branch folding when both edges are the same
>
> The conditional tail call logic did the wrong thing when both
> destinations of a conditional branch were the same:
>
> BB#1: derived from LLVM BB %entry
>     Live Ins: %EFLAGS
>     Predecessors according to CFG: BB#0
>         JE_1 <BB#5>, %EFLAGS<imp-use,kill>
>         JMP_1 <BB#5>
>
> BB#5: derived from LLVM BB %sw.epilog
>     Predecessors according to CFG: BB#1
>         TCRETURNdi64 <ga:@mergeable_conditional_tailcall>, 0, ...
>
> We would fold the JE_1 to a TCRETURNdi64cc, and then remove our BB#5
> successor. Then BB#5 would be deleted as it had no predecessors, leaving
> a dangling "JMP_1 <BB#5>" reference behind to cause assertions later.
>
> This patch checks that both conditional branch destinations are
> different before doing the transform. The standard branch folding logic
> is able to remove both the JMP_1 and the JE_1, and for my test case we
> end up forming a better conditional tail call later.
>
> Fixes PR33980

Thanks for fixing! Merged to 5.0 in r309574.


More information about the llvm-commits mailing list