xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/attr-minsize.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -Oz -emit-llvm %s -o - | FileCheck %s -check-prefix=Oz
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1     -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
3*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -O1 -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
4*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -O2 -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
5*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -O3 -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
6*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -Os -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
7*f4a2713aSLionel Sambuc // Check that we set the minsize attribute on each function
8*f4a2713aSLionel Sambuc // when Oz optimization level is set.
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc __attribute__((minsize))
test1()11*f4a2713aSLionel Sambuc int test1() {
12*f4a2713aSLionel Sambuc   return 42;
13*f4a2713aSLionel Sambuc // Oz: @{{.*}}test1{{.*}}[[MINSIZE:#[0-9]+]]
14*f4a2713aSLionel Sambuc // OTHER: @{{.*}}test1{{.*}}[[MS:#[0-9]+]]
15*f4a2713aSLionel Sambuc }
16*f4a2713aSLionel Sambuc 
test2()17*f4a2713aSLionel Sambuc int test2() {
18*f4a2713aSLionel Sambuc   return 42;
19*f4a2713aSLionel Sambuc // Oz: @{{.*}}test2{{.*}}[[MINSIZE]]
20*f4a2713aSLionel Sambuc // Oz: ret
21*f4a2713aSLionel Sambuc // OTHER: @{{.*}}test2
22*f4a2713aSLionel Sambuc // OTHER-NOT: [[MS]]
23*f4a2713aSLionel Sambuc // OTHER: ret
24*f4a2713aSLionel Sambuc }
25*f4a2713aSLionel Sambuc 
test3()26*f4a2713aSLionel Sambuc int test3() {
27*f4a2713aSLionel Sambuc   return 42;
28*f4a2713aSLionel Sambuc // Oz: @{{.*}}test3{{.*}}[[MINSIZE]]
29*f4a2713aSLionel Sambuc // Oz: ret
30*f4a2713aSLionel Sambuc // OTHER: @{{.*}}test3
31*f4a2713aSLionel Sambuc // OTHER-NOT: [[MS]]
32*f4a2713aSLionel Sambuc // OTHER: ret
33*f4a2713aSLionel Sambuc }
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc // Check that the minsize attribute is well propagated through
36*f4a2713aSLionel Sambuc // template instantiation
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc template<typename T>
39*f4a2713aSLionel Sambuc __attribute__((minsize))
test4(T arg)40*f4a2713aSLionel Sambuc void test4(T arg) {
41*f4a2713aSLionel Sambuc   return;
42*f4a2713aSLionel Sambuc }
43*f4a2713aSLionel Sambuc 
44*f4a2713aSLionel Sambuc template
45*f4a2713aSLionel Sambuc void test4<int>(int arg);
46*f4a2713aSLionel Sambuc // Oz: define{{.*}}void @{{.*}}test4
47*f4a2713aSLionel Sambuc // Oz: [[MINSIZE]]
48*f4a2713aSLionel Sambuc // OTHER: define{{.*}}void @{{.*}}test4
49*f4a2713aSLionel Sambuc // OTHER: [[MS]]
50*f4a2713aSLionel Sambuc 
51*f4a2713aSLionel Sambuc template
52*f4a2713aSLionel Sambuc void test4<float>(float arg);
53*f4a2713aSLionel Sambuc // Oz: define{{.*}}void @{{.*}}test4
54*f4a2713aSLionel Sambuc // Oz: [[MINSIZE]]
55*f4a2713aSLionel Sambuc // OTHER: define{{.*}}void @{{.*}}test4
56*f4a2713aSLionel Sambuc // OTHER: [[MS]]
57*f4a2713aSLionel Sambuc 
58*f4a2713aSLionel Sambuc template<typename T>
test5(T arg)59*f4a2713aSLionel Sambuc void test5(T arg) {
60*f4a2713aSLionel Sambuc   return;
61*f4a2713aSLionel Sambuc }
62*f4a2713aSLionel Sambuc 
63*f4a2713aSLionel Sambuc template
64*f4a2713aSLionel Sambuc void test5<int>(int arg);
65*f4a2713aSLionel Sambuc // Oz: define{{.*}}void @{{.*}}test5
66*f4a2713aSLionel Sambuc // Oz: [[MINSIZE]]
67*f4a2713aSLionel Sambuc // OTHER: define{{.*}}void @{{.*}}test5
68*f4a2713aSLionel Sambuc // OTHER-NOT: define{{.*}}void @{{.*}}test5{{.*}}[[MS]]
69*f4a2713aSLionel Sambuc 
70*f4a2713aSLionel Sambuc template
71*f4a2713aSLionel Sambuc void test5<float>(float arg);
72*f4a2713aSLionel Sambuc // Oz: define{{.*}}void @{{.*}}test5
73*f4a2713aSLionel Sambuc // Oz: [[MINSIZE]]
74*f4a2713aSLionel Sambuc // OTHER: define{{.*}}void @{{.*}}test5
75*f4a2713aSLionel Sambuc // OTHER-NOT: define{{.*}}void @{{.*}}test5{{.*}}[[MS]]
76*f4a2713aSLionel Sambuc 
77*f4a2713aSLionel Sambuc // Oz: attributes [[MINSIZE]] = { minsize{{.*}} }
78*f4a2713aSLionel Sambuc 
79*f4a2713aSLionel Sambuc // OTHER: attributes [[MS]] = { minsize nounwind{{.*}} }
80