1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -disable-llvm-passes -o - %s -O1 | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -disable-llvm-passes -o - -x c++ %s -O1 | FileCheck %s
3 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O0 | FileCheck %s --check-prefix=CHECK_O0
5 // When optimizing, the builtin should be converted to metadata.
6 // When not optimizing, there should be no metadata created for the builtin.
7 // In both cases, the builtin should be removed from the code.
15 // CHECK-LABEL: define{{.*}} void @branch(
17 // CHECK-NOT: builtin_unpredictable
18 // CHECK: !unpredictable [[METADATA:.+]]
20 // CHECK_O0-NOT: builtin_unpredictable
21 // CHECK_O0-NOT: !unpredictable
23 if (__builtin_unpredictable(x
> 0))
27 int unpredictable_switch(int x
) {
28 // CHECK-LABEL: @unpredictable_switch(
30 // CHECK-NOT: builtin_unpredictable
31 // CHECK: !unpredictable [[METADATA:.+]]
33 // CHECK_O0-NOT: builtin_unpredictable
34 // CHECK_O0-NOT: !unpredictable
36 switch(__builtin_unpredictable(x
)) {
55 // CHECK: [[METADATA]] = !{}