Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [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. |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 5 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 6 | // RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -verify |
| 7 | // RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -gline-tables-only -verify |
| 8 | // RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>/dev/null | FileCheck %s |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [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: |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 24 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 25 | // -Rpass should produce source location annotations, exclusively (just |
| 26 | // like -gmlt). |
| 27 | // CHECK: , !dbg ! |
| 28 | // CHECK-NOT: DW_TAG_base_type |
| 29 | |
| 30 | // But llvm.dbg.cu should be missing (to prevent writing debug info to |
| 31 | // the final output). |
| 32 | // CHECK-NOT: !llvm.dbg.cu = !{ |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 33 | |
| 34 | int foo(int x, int y) __attribute__((always_inline)); |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 35 | int foo(int x, int y) { return x + y; } |
| 36 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 37 | float foz(int x, int y) __attribute__((noinline)); |
| 38 | float foz(int x, int y) { return x * y; } |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 39 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 40 | // The negative diagnostics are emitted twice because the inliner runs |
| 41 | // twice. |
| 42 | // |
| 43 | int bar(int j) { |
| 44 | // expected-remark@+6 {{foz should never be inlined (cost=never)}} |
| 45 | // expected-remark@+5 {{foz will not be inlined into bar}} |
| 46 | // expected-remark@+4 {{foz should never be inlined}} |
| 47 | // expected-remark@+3 {{foz will not be inlined into bar}} |
| 48 | // expected-remark@+2 {{foo should always be inlined}} |
| 49 | // expected-remark@+1 {{foo inlined into bar}} |
| 50 | return foo(j, j - 2) * foz(j - 2, j); |
| 51 | } |