blob: a6475d7ef116ce3e5d7baaf3f42fed9fd8cd3b85 [file] [log] [blame]
Andrew Trick72c1a6a2012-06-26 18:13:12 +00001// 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
12void calla();
13void callb();
14void callc();
15
Andrew Trick7bbf9d12012-06-26 21:15:49 +000016// CHECK: @test1
17// CHECK: @calla
18// CHECK: @callb
19// CHECK: @callc
Andrew Trick72c1a6a2012-06-26 18:13:12 +000020// CHECK: ret void
21void test1(int a) {
22 if (a)
23 calla();
24 else
25 callb();
26 callc();
27}
28
Andrew Trick7bbf9d12012-06-26 21:15:49 +000029// CHECK: @test2
30// CHECK: @callb
31// CHECK: @calla
32// CHECK: @callc
Andrew Trick72c1a6a2012-06-26 18:13:12 +000033// CHECK: ret void
34void test2(int a) {
35 if (!a)
36 callb();
37 else
38 calla();
39 callc();
40}