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