blob: 2a6e0d1d96f828773ebbc1264f172db6c572c6e2 [file] [log] [blame]
Paul Robinsonf0674352014-03-31 22:29:15 +00001// RUN: %clang_cc1 -emit-llvm < %s > %t
2// RUN: FileCheck %s --check-prefix=PRESENT < %t
3// RUN: FileCheck %s --check-prefix=ABSENT < %t
Paul Robinson4ece6822014-11-24 20:51:42 +00004// RUN: %clang_cc1 -emit-llvm -Os < %s > %t
5// RUN: FileCheck %s --check-prefix=PRESENT < %t
6// RUN: FileCheck %s --check-prefix=OPTSIZE < %t
Paul Robinsonf0674352014-03-31 22:29:15 +00007
8__attribute__((always_inline))
9int test2() { return 0; }
Paul Robinson4ece6822014-11-24 20:51:42 +000010// OPTSIZE: @test2{{.*}}[[ATTR2:#[0-9]+]]
Paul Robinsonf0674352014-03-31 22:29:15 +000011
12__attribute__((optnone)) __attribute__((minsize))
13int test3() { return 0; }
14// PRESENT-DAG: @test3{{.*}}[[ATTR3:#[0-9]+]]
15
16__attribute__((optnone)) __attribute__((cold))
17int test4() { return test2(); }
18// PRESENT-DAG: @test4{{.*}}[[ATTR4:#[0-9]+]]
19// Also check that test2 is inlined into test4 (always_inline still works).
Nico Rieck4da7deb2014-05-23 19:07:25 +000020// PRESENT-NOT: call i32 @test2
Paul Robinsonf0674352014-03-31 22:29:15 +000021
22// Check for both noinline and optnone on each optnone function.
23// PRESENT-DAG: attributes [[ATTR3]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
24// PRESENT-DAG: attributes [[ATTR4]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
25
26// Check that no 'optsize' or 'minsize' attributes appear.
27// ABSENT-NOT: optsize
28// ABSENT-NOT: minsize
Paul Robinson4ece6822014-11-24 20:51:42 +000029
30// With -Os, check that 'optsize' appears only on test2.
31// OPTSIZE-NOT: optsize
32// OPTSIZE: attributes [[ATTR2]] = { {{.*}}optsize{{.*}} }
33// OPTSIZE-NOT: optsize