xref: /llvm-project/clang/test/CodeGen/xray-function-groups.cpp (revision 6f7fbdd2857fc8a7280afbb26fd4e1a6450069e4)
1*6f7fbdd2SIan Levesque // RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -fxray-function-groups=3 -fxray-selected-function-group=0 \
2*6f7fbdd2SIan Levesque // RUN:            -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck --check-prefix=GROUP0 %s
3*6f7fbdd2SIan Levesque 
4*6f7fbdd2SIan Levesque // RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -fxray-function-groups=3 -fxray-selected-function-group=1 \
5*6f7fbdd2SIan Levesque // RUN:            -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck --check-prefix=GROUP1 %s
6*6f7fbdd2SIan Levesque 
7*6f7fbdd2SIan Levesque // RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -fxray-function-groups=3 -fxray-selected-function-group=2 \
8*6f7fbdd2SIan Levesque // RUN:            -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck --check-prefix=GROUP2 %s
9*6f7fbdd2SIan Levesque 
foo()10*6f7fbdd2SIan Levesque static int foo() { // part of group 0
11*6f7fbdd2SIan Levesque   return 1;
12*6f7fbdd2SIan Levesque }
13*6f7fbdd2SIan Levesque 
bar()14*6f7fbdd2SIan Levesque int bar() { // part of group 2
15*6f7fbdd2SIan Levesque   return 1;
16*6f7fbdd2SIan Levesque }
17*6f7fbdd2SIan Levesque 
yarr()18*6f7fbdd2SIan Levesque int yarr() { // part of group 1
19*6f7fbdd2SIan Levesque   foo();
20*6f7fbdd2SIan Levesque   return 1;
21*6f7fbdd2SIan Levesque }
22*6f7fbdd2SIan Levesque 
always()23*6f7fbdd2SIan Levesque [[clang::xray_always_instrument]] int always() { // part of group 0
24*6f7fbdd2SIan Levesque   return 1;
25*6f7fbdd2SIan Levesque }
26*6f7fbdd2SIan Levesque 
never()27*6f7fbdd2SIan Levesque [[clang::xray_never_instrument]] int never() { // part of group 1
28*6f7fbdd2SIan Levesque   return 1;
29*6f7fbdd2SIan Levesque }
30*6f7fbdd2SIan Levesque 
31*6f7fbdd2SIan Levesque // GROUP0: define{{.*}} i32 @_Z3barv() #[[ATTRS_BAR:[0-9]+]] {
32*6f7fbdd2SIan Levesque // GROUP0: define{{.*}} i32 @_Z4yarrv() #[[ATTRS_BAR]] {
33*6f7fbdd2SIan Levesque // GROUP0: define{{.*}} i32 @_ZL3foov() #[[ATTRS_FOO:[0-9]+]] {
34*6f7fbdd2SIan Levesque // GROUP0: define{{.*}} i32 @_Z6alwaysv() #[[ATTRS_ALWAYS:[0-9]+]] {
35*6f7fbdd2SIan Levesque // GROUP0: define{{.*}} i32 @_Z5neverv() #[[ATTRS_NEVER:[0-9]+]] {
36*6f7fbdd2SIan Levesque // GROUP0-DAG: attributes #[[ATTRS_BAR]] = {{.*}} "function-instrument"="xray-never" {{.*}}
37*6f7fbdd2SIan Levesque // GROUP0-DAG: attributes #[[ATTRS_ALWAYS]] = {{.*}} "function-instrument"="xray-always" {{.*}}
38*6f7fbdd2SIan Levesque // GROUP0-DAG: attributes #[[ATTRS_NEVER]] = {{.*}} "function-instrument"="xray-never" {{.*}}
39*6f7fbdd2SIan Levesque 
40*6f7fbdd2SIan Levesque // GROUP1: define{{.*}} i32 @_Z3barv() #[[ATTRS_BAR:[0-9]+]] {
41*6f7fbdd2SIan Levesque // GROUP1: define{{.*}} i32 @_Z4yarrv() #[[ATTRS_YARR:[0-9]+]] {
42*6f7fbdd2SIan Levesque // GROUP1: define{{.*}} i32 @_ZL3foov() #[[ATTRS_BAR]] {
43*6f7fbdd2SIan Levesque // GROUP1: define{{.*}} i32 @_Z6alwaysv() #[[ATTRS_ALWAYS:[0-9]+]] {
44*6f7fbdd2SIan Levesque // GROUP1: define{{.*}} i32 @_Z5neverv() #[[ATTRS_NEVER:[0-9]+]] {
45*6f7fbdd2SIan Levesque // GROUP1-DAG: attributes #[[ATTRS_BAR]] = {{.*}} "function-instrument"="xray-never" {{.*}}
46*6f7fbdd2SIan Levesque // GROUP1-DAG: attributes #[[ATTRS_ALWAYS]] = {{.*}} "function-instrument"="xray-always" {{.*}}
47*6f7fbdd2SIan Levesque // GROUP1-DAG: attributes #[[ATTRS_NEVER]] = {{.*}} "function-instrument"="xray-never" {{.*}}
48*6f7fbdd2SIan Levesque 
49*6f7fbdd2SIan Levesque // GROUP2: define{{.*}} i32 @_Z3barv() #[[ATTRS_BAR:[0-9]+]] {
50*6f7fbdd2SIan Levesque // GROUP2: define{{.*}} i32 @_Z4yarrv() #[[ATTRS_YARR:[0-9]+]] {
51*6f7fbdd2SIan Levesque // GROUP2: define{{.*}} i32 @_ZL3foov() #[[ATTRS_YARR]] {
52*6f7fbdd2SIan Levesque // GROUP2: define{{.*}} i32 @_Z6alwaysv() #[[ATTRS_ALWAYS:[0-9]+]] {
53*6f7fbdd2SIan Levesque // GROUP2: define{{.*}} i32 @_Z5neverv() #[[ATTRS_NEVER:[0-9]+]] {
54*6f7fbdd2SIan Levesque // GROUP2-DAG: attributes #[[ATTRS_YARR]] = {{.*}} "function-instrument"="xray-never" {{.*}}
55*6f7fbdd2SIan Levesque // GROUP2-DAG: attributes #[[ATTRS_ALWAYS]] = {{.*}} "function-instrument"="xray-always" {{.*}}
56*6f7fbdd2SIan Levesque // GROUP2-DAG: attributes #[[ATTRS_NEVER]] = {{.*}} "function-instrument"="xray-never" {{.*}}
57