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