blob: 96493bfe3613221d93dc17a8b534f7e350848c0c [file] [log] [blame]
Stephen Hines651f13c2014-04-23 16:59:28 -07001// RUN: %clang_cc1 -emit-llvm < %s > %t
2// RUN: FileCheck %s --check-prefix=PRESENT < %t
3// RUN: FileCheck %s --check-prefix=ABSENT < %t
Stephen Hines0e2c34f2015-03-23 12:09:02 -07004// RUN: %clang_cc1 -emit-llvm -Os < %s > %t
5// RUN: FileCheck %s --check-prefix=PRESENT < %t
6// RUN: FileCheck %s --check-prefix=OPTSIZE < %t
7// RUN: %clang_cc1 -emit-llvm -Oz < %s > %t
8// RUN: FileCheck %s --check-prefix=PRESENT < %t
9// RUN: FileCheck %s --check-prefix=MINSIZE < %t
Stephen Hines651f13c2014-04-23 16:59:28 -070010
11__attribute__((always_inline))
12int test2() { return 0; }
Stephen Hines0e2c34f2015-03-23 12:09:02 -070013// OPTSIZE: @test2{{.*}}[[ATTR2:#[0-9]+]]
14// MINSIZE: @test2{{.*}}[[ATTR2:#[0-9]+]]
Stephen Hines651f13c2014-04-23 16:59:28 -070015
Stephen Hines0e2c34f2015-03-23 12:09:02 -070016__attribute__((optnone))
Stephen Hines651f13c2014-04-23 16:59:28 -070017int test3() { return 0; }
18// PRESENT-DAG: @test3{{.*}}[[ATTR3:#[0-9]+]]
19
20__attribute__((optnone)) __attribute__((cold))
21int test4() { return test2(); }
22// PRESENT-DAG: @test4{{.*}}[[ATTR4:#[0-9]+]]
23// Also check that test2 is inlined into test4 (always_inline still works).
Stephen Hines6bcf27b2014-05-29 04:14:42 -070024// PRESENT-NOT: call i32 @test2
Stephen Hines651f13c2014-04-23 16:59:28 -070025
26// Check for both noinline and optnone on each optnone function.
27// PRESENT-DAG: attributes [[ATTR3]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
28// PRESENT-DAG: attributes [[ATTR4]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
29
30// Check that no 'optsize' or 'minsize' attributes appear.
31// ABSENT-NOT: optsize
32// ABSENT-NOT: minsize
Stephen Hines0e2c34f2015-03-23 12:09:02 -070033
34// With -Os, check that 'optsize' appears only on test2.
35// OPTSIZE-NOT: optsize
36// OPTSIZE: attributes [[ATTR2]] = { {{.*}}optsize{{.*}} }
37// OPTSIZE-NOT: optsize
38
39// With -Oz, check that 'minsize' appears only on test2.
40// MINSIZE-NOT: minsize
41// MINSIZE: attributes [[ATTR2]] = { {{.*}}minsize{{.*}} }
42// MINSIZE-NOT: minsize