Fariborz Jahanian | ec99195 | 2011-04-25 22:30:02 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s |
Fariborz Jahanian | e42b8a5 | 2010-07-26 23:11:03 +0000 | [diff] [blame] | 2 | |
| 3 | int x; |
| 4 | int y(void); |
| 5 | void foo(); |
| 6 | void FUNC() { |
| 7 | // CHECK: [[call:%.*]] = call i32 @y |
| 8 | if (__builtin_expect (x, y())) |
| 9 | foo (); |
| 10 | } |
| 11 | |
Fariborz Jahanian | ec99195 | 2011-04-25 22:30:02 +0000 | [diff] [blame] | 12 | // rdar://9330105 |
| 13 | void isigprocmask(void); |
| 14 | long bar(); |
| 15 | |
| 16 | int main() { |
| 17 | (void) __builtin_expect((isigprocmask(), 0), bar()); |
| 18 | } |
| 19 | |
| 20 | // CHECK: call void @isigprocmask() |
John McCall | a8a16d5 | 2011-09-21 08:34:49 +0000 | [diff] [blame^] | 21 | // CHECK: [[C:%.*]] = call i64 (...)* @bar() |
Jakub Staszak | 558229f | 2011-07-08 22:45:14 +0000 | [diff] [blame] | 22 | |
| 23 | |
| 24 | // CHECK: @test1 |
| 25 | int test1(int x) { |
| 26 | // CHECK: @llvm.expect |
| 27 | if (__builtin_expect (x, 1)) |
| 28 | return 0; |
| 29 | return x; |
| 30 | } |
| 31 | |
| 32 | // CHECK: @test2 |
| 33 | int test2(int x) { |
| 34 | // CHECK: @llvm.expect |
| 35 | switch(__builtin_expect(x, 5)) { |
| 36 | default: |
| 37 | return 0; |
| 38 | case 0: |
| 39 | case 1: |
| 40 | case 2: |
| 41 | return 1; |
| 42 | case 5: |
| 43 | return 5; |
| 44 | }; |
| 45 | |
| 46 | return 0; |
| 47 | } |