Diego Novillo | d23ec94 | 2014-05-29 19:55:06 +0000 | [diff] [blame] | 1 | // This file tests the -Rpass family of flags (-Rpass, -Rpass-missed |
| 2 | // and -Rpass-analysis) with the inliner. The test is designed to |
| 3 | // always trigger the inliner, so it should be independent of the |
| 4 | // optimization level. |
Diego Novillo | 829b170 | 2014-04-16 16:54:24 +0000 | [diff] [blame] | 5 | |
Diego Novillo | 913690c | 2014-06-24 17:02:17 +0000 | [diff] [blame] | 6 | // RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -verify |
Douglas Katzman | 3459ce2 | 2015-10-08 04:24:12 +0000 | [diff] [blame] | 7 | // RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -debug-info-kind=line-tables-only -verify |
David Blaikie | bcc6004 | 2014-06-24 17:31:05 +0000 | [diff] [blame] | 8 | // RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>/dev/null | FileCheck %s |
Richard Smith | 3be1cb2 | 2014-08-07 00:24:21 +0000 | [diff] [blame] | 9 | // |
| 10 | // Check that we can override -Rpass= with -Rno-pass. |
| 11 | // RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
| 12 | // RUN: %clang_cc1 %s -Rpass=inline -Rno-pass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS |
| 13 | // RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS |
| 14 | // RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS |
| 15 | // |
| 16 | // FIXME: -Reverything should imply -Rpass=.*. |
| 17 | // RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS |
| 18 | // |
| 19 | // FIXME: -Rpass should either imply -Rpass=.* or should be rejected. |
| 20 | // RUN: %clang_cc1 %s -Rpass -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS |
| 21 | |
| 22 | // CHECK-REMARKS: remark: |
| 23 | // CHECK-NO-REMARKS-NOT: remark: |
Diego Novillo | 913690c | 2014-06-24 17:02:17 +0000 | [diff] [blame] | 24 | |
| 25 | // -Rpass should produce source location annotations, exclusively (just |
| 26 | // like -gmlt). |
| 27 | // CHECK: , !dbg ! |
| 28 | // CHECK-NOT: DW_TAG_base_type |
| 29 | |
Adrian Prantl | 826824e | 2016-04-08 22:43:06 +0000 | [diff] [blame] | 30 | // The CU should be marked NoDebug (to prevent writing debug info to |
Diego Novillo | 913690c | 2014-06-24 17:02:17 +0000 | [diff] [blame] | 31 | // the final output). |
Adrian Prantl | 826824e | 2016-04-08 22:43:06 +0000 | [diff] [blame] | 32 | // CHECK: !llvm.dbg.cu = !{![[CU:.*]]} |
| 33 | // CHECK: ![[CU]] = distinct !DICompileUnit({{.*}}emissionKind: NoDebug |
Diego Novillo | 829b170 | 2014-04-16 16:54:24 +0000 | [diff] [blame] | 34 | |
| 35 | int foo(int x, int y) __attribute__((always_inline)); |
Diego Novillo | 829b170 | 2014-04-16 16:54:24 +0000 | [diff] [blame] | 36 | int foo(int x, int y) { return x + y; } |
Diego Novillo | 829b170 | 2014-04-16 16:54:24 +0000 | [diff] [blame] | 37 | |
Diego Novillo | d23ec94 | 2014-05-29 19:55:06 +0000 | [diff] [blame] | 38 | float foz(int x, int y) __attribute__((noinline)); |
| 39 | float foz(int x, int y) { return x * y; } |
| 40 | |
| 41 | // The negative diagnostics are emitted twice because the inliner runs |
| 42 | // twice. |
| 43 | // |
Alp Toker | 2750627 | 2014-06-05 22:11:12 +0000 | [diff] [blame] | 44 | int bar(int j) { |
Adam Nemet | 820086a2 | 2017-01-30 16:22:50 +0000 | [diff] [blame] | 45 | // expected-remark@+3 {{foz not inlined into bar because it should never be inlined (cost=never)}} |
Sam Elliott | 2307905 | 2017-08-21 16:40:35 +0000 | [diff] [blame] | 46 | // expected-remark@+2 {{foz not inlined into bar because it should never be inlined (cost=never)}} |
Evgeniy Stepanov | 6b2a61d | 2015-09-14 21:35:16 +0000 | [diff] [blame] | 47 | // expected-remark@+1 {{foo inlined into bar}} |
Alp Toker | 2750627 | 2014-06-05 22:11:12 +0000 | [diff] [blame] | 48 | return foo(j, j - 2) * foz(j - 2, j); |
| 49 | } |