Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 1 | // 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 | |
| 10 | int test1() { |
| 11 | return 42; |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 12 | // Oz: @{{.*}}test1{{.*}}#0 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 13 | // Oz: ret |
| 14 | // OTHER: @{{.*}}test1 |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 15 | // OTHER-NOT: #1 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 16 | // OTHER: ret |
| 17 | } |
| 18 | |
| 19 | int test2() { |
| 20 | return 42; |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 21 | // Oz: @{{.*}}test2{{.*}}#0 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 22 | // Oz: ret |
| 23 | // OTHER: @{{.*}}test2 |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 24 | // OTHER-NOT: #1 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 25 | // OTHER: ret |
| 26 | } |
| 27 | |
| 28 | __attribute__((minsize)) |
| 29 | int test3() { |
| 30 | return 42; |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 31 | // Oz: @{{.*}}test3{{.*}}#0 |
| 32 | // OTHER: @{{.*}}test3{{.*}}#1 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | // Check that the minsize attribute is well propagated through |
| 36 | // template instantiation |
| 37 | |
| 38 | template<typename T> |
| 39 | __attribute__((minsize)) |
| 40 | void test4(T arg) { |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | template |
| 45 | void test4<int>(int arg); |
| 46 | // Oz: define{{.*}}void @{{.*}}test4 |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 47 | // Oz: #0 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 48 | // OTHER: define{{.*}}void @{{.*}}test4 |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 49 | // OTHER: #1 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 50 | |
| 51 | template |
| 52 | void test4<float>(float arg); |
| 53 | // Oz: define{{.*}}void @{{.*}}test4 |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 54 | // Oz: #0 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 55 | // OTHER: define{{.*}}void @{{.*}}test4 |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 56 | // OTHER: #1 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 57 | |
| 58 | template<typename T> |
| 59 | void test5(T arg) { |
| 60 | return; |
| 61 | } |
| 62 | |
| 63 | template |
| 64 | void test5<int>(int arg); |
| 65 | // Oz: define{{.*}}void @{{.*}}test5 |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 66 | // Oz: #0 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 67 | // OTHER: define{{.*}}void @{{.*}}test5 |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 68 | // OTHER-NOT: define{{.*}}void @{{.*}}test5{{.*}}#1 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 69 | |
| 70 | template |
| 71 | void test5<float>(float arg); |
| 72 | // Oz: define{{.*}}void @{{.*}}test5 |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 73 | // Oz: #0 |
Quentin Colombet | aee56fa | 2012-11-01 23:55:47 +0000 | [diff] [blame] | 74 | // OTHER: define{{.*}}void @{{.*}}test5 |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame^] | 75 | // 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"={{.*}} } |