1 // Blocks that we have no profile data for (ie, it was never reached in training 2 // runs) shouldn't have any branch weight metadata added. 3 4 // RUN: llvm-profdata merge %S/Inputs/c-unprofiled-blocks.proftext -o %t.profdata 5 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-unprofiled-blocks.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s 6 7 // PGOUSE-LABEL: @never_called(i32 %i) 8 int never_called(int i) { 9 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}} 10 if (i) {} 11 12 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}} 13 for (i = 0; i < 100; ++i) { 14 } 15 16 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}} 17 while (--i) {} 18 19 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}} 20 do {} while (i++ < 75); 21 22 // PGOUSE: switch {{.*}} [ 23 // PGOUSE-NEXT: i32 12 24 // PGOUSE-NEXT: i32 82 25 // PGOUSE-NEXT: ]{{$}} 26 switch (i) { 27 case 12: return 3; 28 case 82: return 0; 29 default: return 89; 30 } 31 } 32 33 // PGOUSE-LABEL: @dead_code(i32 %i) 34 int dead_code(int i) { 35 // PGOUSE: br {{.*}}, !prof !{{[0-9]+}} 36 if (i) { 37 // This branch is never reached. 38 39 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}} 40 if (!i) {} 41 42 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}} 43 for (i = 0; i < 100; ++i) { 44 } 45 46 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}} 47 while (--i) {} 48 49 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}} 50 do {} while (i++ < 75); 51 52 // PGOUSE: switch {{.*}} [ 53 // PGOUSE-NEXT: i32 12 54 // PGOUSE-NEXT: i32 82 55 // PGOUSE-NEXT: ]{{$}} 56 switch (i) { 57 case 12: return 3; 58 case 82: return 0; 59 default: return 89; 60 } 61 } 62 return 2; 63 } 64 65 // PGOUSE-LABEL: @main(i32 %argc, i8** %argv) 66 int main(int argc, const char *argv[]) { 67 dead_code(0); 68 return 0; 69 } 70