xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/attr-optnone.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -emit-llvm < %s > %t
2*0a6a1f1dSLionel Sambuc // RUN: FileCheck %s --check-prefix=PRESENT < %t
3*0a6a1f1dSLionel Sambuc // RUN: FileCheck %s --check-prefix=ABSENT  < %t
4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -Os < %s > %t
5*0a6a1f1dSLionel Sambuc // RUN: FileCheck %s --check-prefix=PRESENT < %t
6*0a6a1f1dSLionel Sambuc // RUN: FileCheck %s --check-prefix=OPTSIZE < %t
7*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -Oz < %s > %t
8*0a6a1f1dSLionel Sambuc // RUN: FileCheck %s --check-prefix=PRESENT < %t
9*0a6a1f1dSLionel Sambuc // RUN: FileCheck %s --check-prefix=MINSIZE < %t
10*0a6a1f1dSLionel Sambuc 
11*0a6a1f1dSLionel Sambuc __attribute__((always_inline))
test2()12*0a6a1f1dSLionel Sambuc int test2() { return 0; }
13*0a6a1f1dSLionel Sambuc // OPTSIZE: @test2{{.*}}[[ATTR2:#[0-9]+]]
14*0a6a1f1dSLionel Sambuc // MINSIZE: @test2{{.*}}[[ATTR2:#[0-9]+]]
15*0a6a1f1dSLionel Sambuc 
16*0a6a1f1dSLionel Sambuc __attribute__((optnone))
test3()17*0a6a1f1dSLionel Sambuc int test3() { return 0; }
18*0a6a1f1dSLionel Sambuc // PRESENT-DAG: @test3{{.*}}[[ATTR3:#[0-9]+]]
19*0a6a1f1dSLionel Sambuc 
20*0a6a1f1dSLionel Sambuc __attribute__((optnone)) __attribute__((cold))
test4()21*0a6a1f1dSLionel Sambuc int test4() { return test2(); }
22*0a6a1f1dSLionel Sambuc // PRESENT-DAG: @test4{{.*}}[[ATTR4:#[0-9]+]]
23*0a6a1f1dSLionel Sambuc // Also check that test2 is inlined into test4 (always_inline still works).
24*0a6a1f1dSLionel Sambuc // PRESENT-NOT: call i32 @test2
25*0a6a1f1dSLionel Sambuc 
26*0a6a1f1dSLionel Sambuc // Check for both noinline and optnone on each optnone function.
27*0a6a1f1dSLionel Sambuc // PRESENT-DAG: attributes [[ATTR3]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
28*0a6a1f1dSLionel Sambuc // PRESENT-DAG: attributes [[ATTR4]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
29*0a6a1f1dSLionel Sambuc 
30*0a6a1f1dSLionel Sambuc // Check that no 'optsize' or 'minsize' attributes appear.
31*0a6a1f1dSLionel Sambuc // ABSENT-NOT: optsize
32*0a6a1f1dSLionel Sambuc // ABSENT-NOT: minsize
33*0a6a1f1dSLionel Sambuc 
34*0a6a1f1dSLionel Sambuc // With -Os, check that 'optsize' appears only on test2.
35*0a6a1f1dSLionel Sambuc // OPTSIZE-NOT: optsize
36*0a6a1f1dSLionel Sambuc // OPTSIZE: attributes [[ATTR2]] = { {{.*}}optsize{{.*}} }
37*0a6a1f1dSLionel Sambuc // OPTSIZE-NOT: optsize
38*0a6a1f1dSLionel Sambuc 
39*0a6a1f1dSLionel Sambuc // With -Oz, check that 'minsize' appears only on test2.
40*0a6a1f1dSLionel Sambuc // MINSIZE-NOT: minsize
41*0a6a1f1dSLionel Sambuc // MINSIZE: attributes [[ATTR2]] = { {{.*}}minsize{{.*}} }
42*0a6a1f1dSLionel Sambuc // MINSIZE-NOT: minsize
43