2014-04-04 10:48:51 +08:00
|
|
|
// Blocks that we have no profile data for (ie, it was never reached in training
|
|
|
|
// runs) shouldn't have any branch weight metadata added.
|
|
|
|
|
2014-04-18 06:49:06 +08:00
|
|
|
// RUN: llvm-profdata merge %S/Inputs/c-unprofiled-blocks.proftext -o %t.profdata
|
2016-03-03 04:59:36 +08:00
|
|
|
// RUN: %clang_cc1 -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
|
2014-04-04 10:48:51 +08:00
|
|
|
|
|
|
|
// PGOUSE-LABEL: @never_called(i32 %i)
|
|
|
|
int never_called(int i) {
|
|
|
|
// PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
|
|
|
|
if (i) {}
|
|
|
|
|
|
|
|
// PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
|
|
|
|
for (i = 0; i < 100; ++i) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
|
|
|
|
while (--i) {}
|
|
|
|
|
|
|
|
// PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
|
|
|
|
do {} while (i++ < 75);
|
|
|
|
|
|
|
|
// PGOUSE: switch {{.*}} [
|
|
|
|
// PGOUSE-NEXT: i32 12
|
|
|
|
// PGOUSE-NEXT: i32 82
|
|
|
|
// PGOUSE-NEXT: ]{{$}}
|
|
|
|
switch (i) {
|
|
|
|
case 12: return 3;
|
|
|
|
case 82: return 0;
|
|
|
|
default: return 89;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PGOUSE-LABEL: @dead_code(i32 %i)
|
|
|
|
int dead_code(int i) {
|
|
|
|
// PGOUSE: br {{.*}}, !prof !{{[0-9]+}}
|
|
|
|
if (i) {
|
|
|
|
// This branch is never reached.
|
|
|
|
|
|
|
|
// PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
|
|
|
|
if (!i) {}
|
|
|
|
|
|
|
|
// PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
|
|
|
|
for (i = 0; i < 100; ++i) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
|
|
|
|
while (--i) {}
|
|
|
|
|
|
|
|
// PGOUSE: br i1 %{{[^,]*}}, label %{{[^,]*}}, label %{{[^,]*}}{{$}}
|
|
|
|
do {} while (i++ < 75);
|
|
|
|
|
|
|
|
// PGOUSE: switch {{.*}} [
|
|
|
|
// PGOUSE-NEXT: i32 12
|
|
|
|
// PGOUSE-NEXT: i32 82
|
|
|
|
// PGOUSE-NEXT: ]{{$}}
|
|
|
|
switch (i) {
|
|
|
|
case 12: return 3;
|
|
|
|
case 82: return 0;
|
|
|
|
default: return 89;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// PGOUSE-LABEL: @main(i32 %argc, i8** %argv)
|
|
|
|
int main(int argc, const char *argv[]) {
|
|
|
|
dead_code(0);
|
|
|
|
return 0;
|
|
|
|
}
|