brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · c906392 Raw
59 lines · plain
1; RUN: llc -mtriple=avr -print-after=finalize-isel -cgp-freq-ratio-to-skip-merge=10 < %s 2>&1 | FileCheck %s2 3; Because `switch` seems to trigger Machine Basic Blocks to be ordered4; in a different order than they were constructed, this exposes an5; error in the `expand-isel-pseudos` pass. Specifically, it thought we6; could always fallthrough to a newly-constructed MBB. However,7; there's no guarantee that either of the constructed MBBs need to8; occur immediately after the currently-focused one!9;10; This issue manifests in a CFG that looks something like this:11;12; %bb.2.finish:13;     successors: %bb.5(?%) %bb.6(?%)14;     Predecessors according to CFG: %bb.0 %bb.115;         %0 = PHI %3, <%bb.0>, %5, <%bb.1>16;         %7 = LDIRdK 217;         %8 = LDIRdK 118;         CPRdRr %2, %0, implicit-def %SREG19;         BREQk <%bb.6>, implicit %SREG20;21; The code assumes it the fallthrough block after this is %bb.5, but22; it's actually %bb.3! To be proper, there should be an unconditional23; jump tying this block to %bb.5.24 25define i8 @select_must_add_unconditional_jump(i8 %arg0, i8 %arg1) unnamed_addr {26entry-block:27  switch i8 %arg0, label %dead [28    i8 0, label %zero29    i8 1, label %one30  ]31 32zero:33  br label %finish34 35one:36  br label %finish37 38finish:39  %predicate = phi i8 [ 50, %zero ], [ 100, %one ]40  %is_eq = icmp eq i8 %arg1, %predicate41  %result = select i1 %is_eq, i8 1, i8 242  ret i8 %result43 44dead:45  ret i8 046}47 48; This check may be a bit brittle, but the important thing is that the49; basic block containing `select` needs to contain explicit jumps to50; both successors.51 52; CHECK: bb.2.finish:53; CHECK: successors:54; CHECK: BREQk [[BRANCHED:%bb.[0-9]+]]55; CHECK: RJMPk [[DIRECT:%bb.[0-9]+]]56; CHECK-SAME-DAG: {{.*}}[[BRANCHED]]57; CHECK-SAME-DAG: {{.*}}[[DIRECT]]58; CHECK: bb.3.dead:59