Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 %s -O3 -emit-llvm -o - | FileCheck %s
      2 //
      3 // PR13214
      4 // No assumption may be made about the order that a frontend emits branch
      5 // targets (basic blocks). However, the backend's basic block layout makes an
      6 // attempt to preserve source order of control flow, and any bias toward source
      7 // order must start with the frontend.
      8 //
      9 // Note that the frontend inverts branches to simplify the condition, so the
     10 // order of a branch instruction's labels cannot be used as a source order bias.
     11 
     12 void calla();
     13 void callb();
     14 void callc();
     15 
     16 // CHECK: @test1
     17 // CHECK: @calla
     18 // CHECK: @callb
     19 // CHECK: @callc
     20 // CHECK: ret void
     21 void test1(int a) {
     22   if (a)
     23     calla();
     24   else
     25     callb();
     26   callc();
     27 }
     28 
     29 // CHECK: @test2
     30 // CHECK: @callb
     31 // CHECK: @calla
     32 // CHECK: @callc
     33 // CHECK: ret void
     34 void test2(int a) {
     35   if (!a)
     36     callb();
     37   else
     38     calla();
     39   callc();
     40 }
     41