blob: 5611916f59dec759357fcdf62c9d45ea754abd55 [file] [log] [blame]
Quentin Colombetaee56fa2012-11-01 23:55:47 +00001// 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;
Bill Wendlingf7a9da02013-02-20 07:22:19 +000012// Oz: @{{.*}}test1{{.*}}#0
Quentin Colombetaee56fa2012-11-01 23:55:47 +000013// Oz: ret
14// OTHER: @{{.*}}test1
Bill Wendlingf7a9da02013-02-20 07:22:19 +000015// OTHER-NOT: #1
Quentin Colombetaee56fa2012-11-01 23:55:47 +000016// OTHER: ret
17}
18
19int test2() {
20 return 42;
Bill Wendlingf7a9da02013-02-20 07:22:19 +000021// Oz: @{{.*}}test2{{.*}}#0
Quentin Colombetaee56fa2012-11-01 23:55:47 +000022// Oz: ret
23// OTHER: @{{.*}}test2
Bill Wendlingf7a9da02013-02-20 07:22:19 +000024// OTHER-NOT: #1
Quentin Colombetaee56fa2012-11-01 23:55:47 +000025// OTHER: ret
26}
27
28__attribute__((minsize))
29int test3() {
30 return 42;
Bill Wendlingf7a9da02013-02-20 07:22:19 +000031// Oz: @{{.*}}test3{{.*}}#0
32// OTHER: @{{.*}}test3{{.*}}#1
Quentin Colombetaee56fa2012-11-01 23:55:47 +000033}
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
Bill Wendlingf7a9da02013-02-20 07:22:19 +000047// Oz: #0
Quentin Colombetaee56fa2012-11-01 23:55:47 +000048// OTHER: define{{.*}}void @{{.*}}test4
Bill Wendlingf7a9da02013-02-20 07:22:19 +000049// OTHER: #1
Quentin Colombetaee56fa2012-11-01 23:55:47 +000050
51template
52void test4<float>(float arg);
53// Oz: define{{.*}}void @{{.*}}test4
Bill Wendlingf7a9da02013-02-20 07:22:19 +000054// Oz: #0
Quentin Colombetaee56fa2012-11-01 23:55:47 +000055// OTHER: define{{.*}}void @{{.*}}test4
Bill Wendlingf7a9da02013-02-20 07:22:19 +000056// OTHER: #1
Quentin Colombetaee56fa2012-11-01 23:55:47 +000057
58template<typename T>
59void test5(T arg) {
60 return;
61}
62
63template
64void test5<int>(int arg);
65// Oz: define{{.*}}void @{{.*}}test5
Bill Wendlingf7a9da02013-02-20 07:22:19 +000066// Oz: #0
Quentin Colombetaee56fa2012-11-01 23:55:47 +000067// OTHER: define{{.*}}void @{{.*}}test5
Bill Wendlingf7a9da02013-02-20 07:22:19 +000068// OTHER-NOT: define{{.*}}void @{{.*}}test5{{.*}}#1
Quentin Colombetaee56fa2012-11-01 23:55:47 +000069
70template
71void test5<float>(float arg);
72// Oz: define{{.*}}void @{{.*}}test5
Bill Wendlingf7a9da02013-02-20 07:22:19 +000073// Oz: #0
Quentin Colombetaee56fa2012-11-01 23:55:47 +000074// OTHER: define{{.*}}void @{{.*}}test5
Bill Wendlingf7a9da02013-02-20 07:22:19 +000075// OTHER-NOT: define{{.*}}void @{{.*}}test5{{.*}}#1
76
77// Oz: attributes #0 = { minsize nounwind optsize readnone "target-features"={{.*}} }
78
79// OTHER: attributes #0 = { nounwind {{.*}}"target-features"={{.*}} }
80// OTHER: attributes #1 = { minsize nounwind {{.*}}"target-features"={{.*}} }