2011-04-26 06:30:02 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
|
2015-01-27 04:51:58 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O0 | FileCheck %s --check-prefix=CHECK_O0
|
2010-07-27 07:11:03 +08:00
|
|
|
|
|
|
|
int x;
|
|
|
|
int y(void);
|
|
|
|
void foo();
|
|
|
|
void FUNC() {
|
2015-01-27 04:51:58 +08:00
|
|
|
// CHECK-LABEL: define void @FUNC()
|
2010-07-27 07:11:03 +08:00
|
|
|
// CHECK: [[call:%.*]] = call i32 @y
|
2015-01-27 04:51:58 +08:00
|
|
|
// CHECK_O0: [[call:%.*]] = call i32 @y
|
|
|
|
// CHECK_O0-NOT: call i64 @llvm.expect
|
2010-07-27 07:11:03 +08:00
|
|
|
if (__builtin_expect (x, y()))
|
|
|
|
foo ();
|
|
|
|
}
|
|
|
|
|
2011-04-26 06:30:02 +08:00
|
|
|
// rdar://9330105
|
|
|
|
void isigprocmask(void);
|
|
|
|
long bar();
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
(void) __builtin_expect((isigprocmask(), 0), bar());
|
|
|
|
}
|
|
|
|
|
2015-01-27 04:51:58 +08:00
|
|
|
// CHECK-LABEL: define i32 @main()
|
2011-04-26 06:30:02 +08:00
|
|
|
// CHECK: call void @isigprocmask()
|
2011-09-21 16:34:49 +08:00
|
|
|
// CHECK: [[C:%.*]] = call i64 (...)* @bar()
|
2015-01-27 04:51:58 +08:00
|
|
|
// CHECK_O0: call void @isigprocmask()
|
|
|
|
// CHECK_O0: [[C:%.*]] = call i64 (...)* @bar()
|
|
|
|
// CHECK_O0-NOT: call i64 @llvm.expect
|
2011-07-09 06:45:14 +08:00
|
|
|
|
|
|
|
|
2015-01-27 04:51:58 +08:00
|
|
|
// CHECK-LABEL: define i32 @test1
|
2011-07-09 06:45:14 +08:00
|
|
|
int test1(int x) {
|
2015-01-27 04:51:58 +08:00
|
|
|
// CHECK_O0-NOT: call i64 @llvm.expect
|
2011-07-09 06:45:14 +08:00
|
|
|
if (__builtin_expect (x, 1))
|
|
|
|
return 0;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2015-01-27 04:51:58 +08:00
|
|
|
// CHECK: define i32 @test2
|
2011-07-09 06:45:14 +08:00
|
|
|
int test2(int x) {
|
2015-01-27 04:51:58 +08:00
|
|
|
// CHECK_O0-NOT: call i64 @llvm.expect
|
2011-07-09 06:45:14 +08:00
|
|
|
switch(__builtin_expect(x, 5)) {
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
return 1;
|
|
|
|
case 5:
|
|
|
|
return 5;
|
|
|
|
};
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|