[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Profile / c-unprofiled-blocks.c
blobfc633057e98068c188a904152aa5b5bf0880ae8a
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 %{{[^,]*}}{{$}}
10 if (i) {}
12 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
13 for (i = 0; i < 100; ++i) {
16 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
17 while (--i) {}
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: ]{{$}}
26 switch (i) {
27 case 12: return 3;
28 case 82: return 0;
29 default: return 89;
33 // PGOUSE-LABEL: @dead_code(i32 noundef %i)
34 int dead_code(int i) {
35 // PGOUSE: br {{.*}}, !prof !{{[0-9]+}}
36 if (i) {
37 // This branch is never reached.
39 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
40 if (!i) {}
42 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
43 for (i = 0; i < 100; ++i) {
46 // PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
47 while (--i) {}
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: ]{{$}}
56 switch (i) {
57 case 12: return 3;
58 case 82: return 0;
59 default: return 89;
62 return 2;
65 // PGOUSE-LABEL: @main(i32 noundef %argc, i8** noundef %argv)
66 int main(int argc, const char *argv[]) {
67 dead_code(0);
68 return 0;