blob: 997194df7f909f1f32c2f2dfb593ddaebede651a [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
Bill Wendling3bba3ef2013-02-20 19:30:01 +000010__attribute__((minsize))
Quentin Colombetaee56fa2012-11-01 23:55:47 +000011int test1() {
12 return 42;
Bill Wendling3bba3ef2013-02-20 19:30:01 +000013// Oz: @{{.*}}test1{{.*}}[[MINSIZE:#[0-9]+]]
14// OTHER: @{{.*}}test1{{.*}}[[MS:#[0-9]+]]
Quentin Colombetaee56fa2012-11-01 23:55:47 +000015}
16
17int test2() {
18 return 42;
Bill Wendling3bba3ef2013-02-20 19:30:01 +000019// Oz: @{{.*}}test2{{.*}}[[MINSIZE]]
Quentin Colombetaee56fa2012-11-01 23:55:47 +000020// Oz: ret
21// OTHER: @{{.*}}test2
Bill Wendling3bba3ef2013-02-20 19:30:01 +000022// OTHER-NOT: [[MS]]
Quentin Colombetaee56fa2012-11-01 23:55:47 +000023// OTHER: ret
24}
25
Quentin Colombetaee56fa2012-11-01 23:55:47 +000026int test3() {
27 return 42;
Bill Wendling3bba3ef2013-02-20 19:30:01 +000028// Oz: @{{.*}}test3{{.*}}[[MINSIZE]]
29// Oz: ret
30// OTHER: @{{.*}}test3
31// OTHER-NOT: [[MS]]
32// OTHER: ret
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 Wendling3bba3ef2013-02-20 19:30:01 +000047// Oz: [[MINSIZE]]
Quentin Colombetaee56fa2012-11-01 23:55:47 +000048// OTHER: define{{.*}}void @{{.*}}test4
Bill Wendling3bba3ef2013-02-20 19:30:01 +000049// OTHER: [[MS]]
Quentin Colombetaee56fa2012-11-01 23:55:47 +000050
51template
52void test4<float>(float arg);
53// Oz: define{{.*}}void @{{.*}}test4
Bill Wendling3bba3ef2013-02-20 19:30:01 +000054// Oz: [[MINSIZE]]
Quentin Colombetaee56fa2012-11-01 23:55:47 +000055// OTHER: define{{.*}}void @{{.*}}test4
Bill Wendling3bba3ef2013-02-20 19:30:01 +000056// OTHER: [[MS]]
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 Wendling3bba3ef2013-02-20 19:30:01 +000066// Oz: [[MINSIZE]]
Quentin Colombetaee56fa2012-11-01 23:55:47 +000067// OTHER: define{{.*}}void @{{.*}}test5
Bill Wendling3bba3ef2013-02-20 19:30:01 +000068// OTHER-NOT: define{{.*}}void @{{.*}}test5{{.*}}[[MS]]
Quentin Colombetaee56fa2012-11-01 23:55:47 +000069
70template
71void test5<float>(float arg);
72// Oz: define{{.*}}void @{{.*}}test5
Bill Wendling3bba3ef2013-02-20 19:30:01 +000073// Oz: [[MINSIZE]]
Quentin Colombetaee56fa2012-11-01 23:55:47 +000074// OTHER: define{{.*}}void @{{.*}}test5
Bill Wendling3bba3ef2013-02-20 19:30:01 +000075// OTHER-NOT: define{{.*}}void @{{.*}}test5{{.*}}[[MS]]
Bill Wendlingf7a9da02013-02-20 07:22:19 +000076
Bill Wendling3bba3ef2013-02-20 19:30:01 +000077// Oz: attributes [[MINSIZE]] = { minsize{{.*}} }
Bill Wendlingf7a9da02013-02-20 07:22:19 +000078
Bill Wendling3bba3ef2013-02-20 19:30:01 +000079// OTHER: attributes [[MS]] = { minsize nounwind{{.*}} }