Paul Robinson | f067435 | 2014-03-31 22:29:15 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm < %s > %t |
| 2 | // RUN: FileCheck %s --check-prefix=PRESENT < %t |
| 3 | // RUN: FileCheck %s --check-prefix=ABSENT < %t |
Paul Robinson | 4ece682 | 2014-11-24 20:51:42 +0000 | [diff] [blame] | 4 | // 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 Robinson | 0855695 | 2014-12-11 20:14:04 +0000 | [diff] [blame] | 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 |
Paul Robinson | f067435 | 2014-03-31 22:29:15 +0000 | [diff] [blame] | 10 | |
| 11 | __attribute__((always_inline)) |
| 12 | int test2() { return 0; } |
Paul Robinson | 4ece682 | 2014-11-24 20:51:42 +0000 | [diff] [blame] | 13 | // OPTSIZE: @test2{{.*}}[[ATTR2:#[0-9]+]] |
Paul Robinson | 0855695 | 2014-12-11 20:14:04 +0000 | [diff] [blame] | 14 | // MINSIZE: @test2{{.*}}[[ATTR2:#[0-9]+]] |
Paul Robinson | f067435 | 2014-03-31 22:29:15 +0000 | [diff] [blame] | 15 | |
Paul Robinson | aae2fba | 2014-12-10 23:34:36 +0000 | [diff] [blame] | 16 | __attribute__((optnone)) |
Paul Robinson | f067435 | 2014-03-31 22:29:15 +0000 | [diff] [blame] | 17 | int test3() { return 0; } |
| 18 | // PRESENT-DAG: @test3{{.*}}[[ATTR3:#[0-9]+]] |
| 19 | |
| 20 | __attribute__((optnone)) __attribute__((cold)) |
| 21 | int test4() { return test2(); } |
| 22 | // PRESENT-DAG: @test4{{.*}}[[ATTR4:#[0-9]+]] |
| 23 | // Also check that test2 is inlined into test4 (always_inline still works). |
Nico Rieck | 4da7deb | 2014-05-23 19:07:25 +0000 | [diff] [blame] | 24 | // PRESENT-NOT: call i32 @test2 |
Paul Robinson | f067435 | 2014-03-31 22:29:15 +0000 | [diff] [blame] | 25 | |
| 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 |
Paul Robinson | 4ece682 | 2014-11-24 20:51:42 +0000 | [diff] [blame] | 33 | |
| 34 | // With -Os, check that 'optsize' appears only on test2. |
| 35 | // OPTSIZE-NOT: optsize |
| 36 | // OPTSIZE: attributes [[ATTR2]] = { {{.*}}optsize{{.*}} } |
| 37 | // OPTSIZE-NOT: optsize |
Paul Robinson | 0855695 | 2014-12-11 20:14:04 +0000 | [diff] [blame] | 38 | |
| 39 | // With -Oz, check that 'minsize' appears only on test2. |
| 40 | // MINSIZE-NOT: minsize |
| 41 | // MINSIZE: attributes [[ATTR2]] = { {{.*}}minsize{{.*}} } |
| 42 | // MINSIZE-NOT: minsize |