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.
4 // RUN: llvm-profdata merge %S/Inputs/c-unprofiled-blocks.proftext -o %t.profdata
5 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-macosx10.9 -main-file-name c-unprofiled-blocks.c %s -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata | FileCheck -check-prefix=PGOUSE %s
7 // PGOUSE-LABEL: @never_called(i32 noundef %i)
8 int never_called(int i
) {
9 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
12 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
13 for (i
= 0; i
< 100; ++i
) {
16 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
19 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}, !llvm.loop [[LOOP1:!.*]]
20 do {} while (i
++ < 75);
22 // PGOUSE: switch {{.*}} [
23 // PGOUSE-NEXT: i32 12
24 // PGOUSE-NEXT: i32 82
25 // PGOUSE-NEXT: ]{{$}}
33 // PGOUSE-LABEL: @dead_code(i32 noundef %i)
34 int dead_code(int i
) {
35 // PGOUSE: br {{.*}}, !prof !{{[0-9]+}}
37 // This branch is never reached.
39 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
42 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
43 for (i
= 0; i
< 100; ++i
) {
46 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
49 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}, !llvm.loop [[LOOP2:!.*]]
50 do {} while (i
++ < 75);
52 // PGOUSE: switch {{.*}} [
53 // PGOUSE-NEXT: i32 12
54 // PGOUSE-NEXT: i32 82
55 // PGOUSE-NEXT: ]{{$}}
65 // PGOUSE-LABEL: @main(i32 noundef %argc, i8** noundef %argv)
66 int main(int argc
, const char *argv
[]) {