62 lines · c
1// This file tests the -Rpass family of flags (-Rpass, -Rpass-missed2// and -Rpass-analysis) with the inliner. The test is designed to3// always trigger the inliner, so it should be independent of the4// optimization level (under the legacy PM). The inliner is not added to the new5// PM pipeline unless optimizations are present.6 7// The inliner for the new PM does not seem to be enabled at O0, but we still8// get the same remarks with at least O1. The remarks are also slightly9// different and located in another test file.10// RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>/dev/null | FileCheck %s11//12// Check that we can override -Rpass= with -Rno-pass.13// RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS14// RUN: %clang_cc1 %s -Rpass=inline -Rno-pass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS15// RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS16// RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS17// RUN: %clang_cc1 %s -Rpass -Rno-pass -round-trip-args -mllvm -mandatory-inlining-first=false -O1 -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS18//19// The inliner for the new PM does not seem to be enabled at O0, but we still20// get the same remarks with at least O1.21// RUN: %clang_cc1 %s -Rpass=inline -O1 -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS22// RUN: %clang_cc1 %s -Rpass=inline -O1 -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS23//24// Check that -w doesn't disable remarks.25// RUN: %clang_cc1 %s -Rpass=inline -w -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS26// RUN: %clang_cc1 %s -Rpass=inline -O1 -w -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS27//28// -Reverything implies -Rpass=.*.29// RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS30//31// -Rpass implies -Rpass=.*32// RUN: %clang_cc1 %s -Rpass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS33 34// CHECK-REMARKS: remark:35// CHECK-NO-REMARKS-NOT: remark:36 37// -Rpass should produce source location annotations, exclusively (just38// like -gmlt).39// CHECK: , !dbg !40// CHECK-NOT: DW_TAG_base_type41 42// The CU should be marked NoDebug (to prevent writing debug info to43// the final output).44// CHECK: !llvm.dbg.cu = !{![[CU:.*]]}45// CHECK: ![[CU]] = distinct !DICompileUnit({{.*}}emissionKind: NoDebug46 47int foo(int x, int y) __attribute__((always_inline));48int foo(int x, int y) { return x + y; }49 50float foz(int x, int y) __attribute__((noinline));51float foz(int x, int y) { return x * y; }52 53// The negative diagnostics are emitted twice because the inliner runs54// twice.55//56int bar(int j) {57// expected-remark@+3 {{'foz' not inlined into 'bar' because it should never be inlined (cost=never)}}58// expected-remark@+2 {{'foz' not inlined into 'bar' because it should never be inlined (cost=never)}}59// expected-remark@+1 {{'foo' inlined into 'bar'}}60 return foo(j, j - 2) * foz(j - 2, j);61}62