1 // Test that instrumentation based profiling sets function attributes correctly.
3 // RUN: llvm-profdata merge %S/Inputs/c-attributes.proftext -o %t.profdata
4 // RUN: %clang %s -o - -mllvm -disable-llvm-optzns -emit-llvm -S -fprofile-instr-use=%t.profdata | FileCheck %s
6 extern int atoi(const char *);
8 // CHECK: hot_100_percent(i32{{.*}}%i) [[HOT:#[0-9]+]]
9 void hot_100_percent(int i
) {
14 // CHECK: hot_40_percent(i32{{.*}}%i) [[HOT]]
15 void hot_40_percent(int i
) {
20 // CHECK: normal_func(i32{{.*}}%i) [[NORMAL:#[0-9]+]]
21 void normal_func(int i
) {
26 // CHECK: cold_func(i32{{.*}}%i) [[COLD:#[0-9]+]]
27 void cold_func(int i
) {
32 // CHECK: attributes [[HOT]] = { inlinehint nounwind {{.*}} }
33 // CHECK: attributes [[NORMAL]] = { nounwind {{.*}} }
34 // CHECK: attributes [[COLD]] = { cold nounwind {{.*}} }
36 int main(int argc
, const char *argv
[]) {
37 int max
= atoi(argv
[1]);
39 for (i
= 0; i
< max
; i
++)
41 for (i
= 0; i
< max
* 4 / 10; i
++)
43 for (i
= 0; i
< max
* 2 / 10; i
++)
45 for (i
= 0; i
< max
/ 200; i
++)