Since D129288, callbr is allowed to have duplicate successors. This patch removes a limitation which prevents optimizations from actually producing such callbrs.
This is probably the riskiest of all the recent callbr changes, because code with incorrect assumptions might be lurking somewhere. I fixed the one case I encountered ahead of time in https://github.com/llvm/llvm-project/commit/8201e3ef5c84561260218bc041209611aac690e3.
I believe this change is correct, because we know from a previous condition that w0 must already be zero at this point. The full assembly is:
test3: // @test3 .cfi_startproc // %bb.0: str x30, [sp, #-16]! // 8-byte Folded Spill .cfi_def_cfa_offset 16 .cfi_offset w30, -16 bl g cbz w0, .LBB2_3 // %bb.1: bl i cmp w0, #0 cset w0, ne .Ltmp4: // Block address taken // %bb.2: ldr x30, [sp], #16 // 8-byte Folded Reload ret .LBB2_3: //APP .Ltmp5: nop .xword c b .Ltmp4 .xword 0 //NO_APP ldr x30, [sp], #16 // 8-byte Folded Reload ret .Lfunc_end2: .size test3, .Lfunc_end2-test3 .cfi_endproc // -- End function .hidden l // @l .type l,@object .comm l,4,4 .section ".note.GNU-stack","",@progbitsThis code path is reached through the cbz w0.