1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -disable-llvm-optzns -o - %s -O1 | FileCheck %s 2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -O0 | FileCheck %s --check-prefix=CHECK_O0 3 4 // When optimizing, the builtin should be converted to metadata. 5 // When not optimizing, there should be no metadata created for the builtin. 6 // In both cases, the builtin should be removed from the code. 7 8 void foo(); 9 void branch(int x) { 10 // CHECK-LABEL: define void @branch( 11 12 // CHECK-NOT: builtin_unpredictable 13 // CHECK: !unpredictable [[METADATA:.+]] 14 15 // CHECK_O0-NOT: builtin_unpredictable 16 // CHECK_O0-NOT: !unpredictable 17 18 if (__builtin_unpredictable(x > 0)) 19 foo (); 20 } 21 22 int unpredictable_switch(int x) { 23 // CHECK-LABEL: @unpredictable_switch( 24 25 // CHECK-NOT: builtin_unpredictable 26 // CHECK: !unpredictable [[METADATA:.+]] 27 28 // CHECK_O0-NOT: builtin_unpredictable 29 // CHECK_O0-NOT: !unpredictable 30 31 switch(__builtin_unpredictable(x)) { 32 default: 33 return 0; 34 case 0: 35 case 1: 36 case 2: 37 return 1; 38 case 5: 39 return 5; 40 }; 41 42 return 0; 43 } 44 45 // CHECK: [[METADATA]] = !{} 46 47