]> granicus.if.org Git - clang/commitdiff
[clang][NewPM] Fixing remaining -O0 tests that are broken under new PM
authorLeonard Chan <leonardchan@google.com>
Wed, 19 Jun 2019 17:41:30 +0000 (17:41 +0000)
committerLeonard Chan <leonardchan@google.com>
Wed, 19 Jun 2019 17:41:30 +0000 (17:41 +0000)
- CodeGen/flatten.c will fail under new PM becausec the new PM AlwaysInliner
  seems to intentionally inline functions but not call sites marked with
  alwaysinline (D23299)
- Tests that check remarks happen to check them for the inliner which is not
  turned on at O0. These tests just check that remarks work, but we can make
  separate tests for the new PM with -O1 so we can turn on the inliner and
  check the remarks with minimal changes.

Differential Revision: https://reviews.llvm.org/D62225

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@363846 91177308-0d34-0410-b5e6-96231b3b80d8

test/CMakeLists.txt
test/CodeGen/flatten.c
test/CodeGenCXX/flatten.cpp
test/Frontend/optimization-remark-line-directive.c
test/Frontend/optimization-remark-new-pm.c [new file with mode: 0644]
test/Frontend/optimization-remark-with-hotness-new-pm.c [new file with mode: 0644]
test/Frontend/optimization-remark-with-hotness.c
test/Frontend/optimization-remark.c
test/lit.cfg.py
test/lit.site.cfg.py.in

index bcff4ba7e944bd892caf403ef3b1a022095793b7..6005e7318a30a3eb6dfb167f21fac49b468f00ee 100644 (file)
@@ -23,6 +23,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_ENABLE_ARCMT
   CLANG_ENABLE_STATIC_ANALYZER
   ENABLE_BACKTRACES
+  ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
   HAVE_LIBZ
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
   LLVM_ENABLE_PLUGINS)
index d766d543e01d655a89866477f49c6a7b52da1a94..410128a0bcdec7b273234f5a584d29d752264a63 100644 (file)
@@ -1,3 +1,9 @@
+// UNSUPPORTED: experimental-new-pass-manager
+// Currently, different code seems to be intentionally generated under the new
+// PM since we alwaysinline functions and not callsites under new PM.
+// Under new PM, f() will not be inlined from g() since f is not marked as
+// alwaysinline.
+
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu %s -emit-llvm -o - | FileCheck %s
 
 void f(void) {}
index 9e0f67f78984c02e78a46102c08a5aa61fdfcd19..b36c8ed6cee9dc4c908ab25119e95c1e95dc2b5b 100644 (file)
@@ -1,3 +1,7 @@
+// UNSUPPORTED: experimental-new-pass-manager
+// See the comment for CodeGen/flatten.c on why this is unsupported with the new
+// PM.
+
 // RUN: %clang_cc1 -triple=x86_64-linux-gnu -std=c++11 %s -emit-llvm -o - | FileCheck %s
 
 void f(void) {}
index 8e95e33fe6dafca21e4c41ff0bbe52718f842f83..516555ff45503d66893689af9c9b325eb7849620 100644 (file)
@@ -2,7 +2,11 @@
 // directives. We cannot map #line directives back to
 // a SourceLocation.
 
-// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only -dwarf-column-info -emit-llvm-only -verify
+// RUN: %clang_cc1 %s -Rpass=inline -debug-info-kind=line-tables-only -dwarf-column-info -emit-llvm-only -verify -fno-experimental-new-pass-manager
+
+// The new PM inliner is not added to the default pipeline at O0, so we add
+// some optimizations to trigger it.
+// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -O1 -debug-info-kind=line-tables-only -dwarf-column-info -emit-llvm-only -verify
 
 int foo(int x, int y) __attribute__((always_inline));
 int foo(int x, int y) { return x + y; }
diff --git a/test/Frontend/optimization-remark-new-pm.c b/test/Frontend/optimization-remark-new-pm.c
new file mode 100644 (file)
index 0000000..885dc68
--- /dev/null
@@ -0,0 +1,20 @@
+// Verify that remarks for the inliner appear. The remarks under the new PM will
+// be slightly different than those emitted by the legacy PM. The new PM inliner
+// also doesnot appear to be added at O0, so we test at O1.
+// RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O1 -fexperimental-new-pass-manager -emit-llvm-only -verify
+// RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O1 -fexperimental-new-pass-manager -emit-llvm-only -debug-info-kind=line-tables-only -verify
+
+int foo(int x, int y) __attribute__((always_inline));
+int foo(int x, int y) { return x + y; }
+
+float foz(int x, int y) __attribute__((noinline));
+float foz(int x, int y) { return x * y; }
+
+// The negative diagnostics are emitted twice because the inliner runs
+// twice.
+//
+int bar(int j) {
+  // expected-remark@+2 {{foz not inlined into bar because it should never be inlined (cost=never)}}
+  // expected-remark@+1 {{foo inlined into bar}}
+  return foo(j, j - 2) * foz(j - 2, j);
+}
diff --git a/test/Frontend/optimization-remark-with-hotness-new-pm.c b/test/Frontend/optimization-remark-with-hotness-new-pm.c
new file mode 100644 (file)
index 0000000..24da092
--- /dev/null
@@ -0,0 +1,85 @@
+// This test is similar to Frontend/optimization-remark-with-hotness.c but
+// testing the output under the new pass manager. The inliner is not added to
+// the default new PM pipeline at O0, so we compile with optimizations here. As
+// a result, some of the remarks will be different since we turn on inlining,
+// but the test is meant to show that remarks get dumped. The remarks are also
+// slightly different in text.
+
+// Generate instrumentation and sampling profile data.
+// RUN: llvm-profdata merge \
+// RUN:     %S/Inputs/optimization-remark-with-hotness.proftext \
+// RUN:     -o %t.profdata
+// RUN: llvm-profdata merge -sample \
+// RUN:     %S/Inputs/optimization-remark-with-hotness-sample.proftext \
+// RUN:     -o %t-sample.profdata
+//
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN:     -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN:     -fexperimental-new-pass-manager -O1 \
+// RUN:     -Rpass-analysis=inline -Rpass-missed=inline \
+// RUN:     -fdiagnostics-show-hotness -verify
+// The clang version of the previous test.
+// RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
+// RUN:     -fprofile-instr-use=%t.profdata -Rpass=inline \
+// RUN:     -fexperimental-new-pass-manager -O1 \
+// RUN:     -Rpass-analysis=inline -Rpass-missed=inline \
+// RUN:     -fdiagnostics-show-hotness -Xclang -verify
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN:     -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
+// RUN:     -fexperimental-new-pass-manager -O1 \
+// RUN:     -Rpass-analysis=inline -Rpass-missed=inline \
+// RUN:     -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
+// RUN:     -verify
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN:     -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN:     -fexperimental-new-pass-manager -O1 \
+// RUN:     -Rpass-analysis=inline -Rpass-missed=inline \
+// RUN:     -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 -verify
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN:     -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN:     -fexperimental-new-pass-manager -O1 \
+// RUN:     -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN:     -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN:     -fexperimental-new-pass-manager -O1 \
+// RUN:     -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \
+// RUN:     -check-prefix=HOTNESS_OFF %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN:     -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN:     -Rpass-analysis=inline -fdiagnostics-show-hotness \
+// RUN:     -fdiagnostics-hotness-threshold=100 2>&1 \
+// RUN:     | FileCheck -allow-empty -check-prefix=THRESHOLD %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
+// RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
+// RUN:     -Rpass=inline -Rpass-analysis=inline \
+// RUN:     -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 2>&1 \
+// RUN:     | FileCheck -check-prefix=NO_PGO %s
+
+int foo(int x, int y) __attribute__((always_inline));
+int foo(int x, int y) { return x + y; }
+
+int sum = 0;
+
+void bar(int x) {
+  // HOTNESS_OFF: foo inlined into bar
+  // HOTNESS_OFF-NOT: hotness:
+  // THRESHOLD-NOT: inlined
+  // THRESHOLD-NOT: hotness
+  // NO_PGO: '-fdiagnostics-show-hotness' requires profile-guided optimization information
+  // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided optimization information
+  // expected-remark@+1 {{foo inlined into bar with (cost=always): always inline attribute (hotness:}}
+  sum += foo(x, x - 2);
+}
+
+int main(int argc, const char *argv[]) {
+  for (int i = 0; i < 30; i++)
+    // expected-remark@+1 {{bar inlined into main with}}
+    bar(argc);
+  return sum;
+}
index 5f4c83b46c853cf1ef8b25dea2f2fe3a7f6f2fc0..0f3a4e9d1d6b44b403563714b775e7adeffd084b 100644 (file)
@@ -9,31 +9,37 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN:     -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN:     -fno-experimental-new-pass-manager \
 // RUN:     -Rpass-analysis=inline -Rpass-missed=inline \
 // RUN:     -fdiagnostics-show-hotness -verify
 // The clang version of the previous test.
 // RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \
 // RUN:     -fprofile-instr-use=%t.profdata -Rpass=inline \
+// RUN:     -fno-experimental-new-pass-manager \
 // RUN:     -Rpass-analysis=inline -Rpass-missed=inline \
 // RUN:     -fdiagnostics-show-hotness -Xclang -verify
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN:     -fprofile-sample-use=%t-sample.profdata -Rpass=inline \
+// RUN:     -fno-experimental-new-pass-manager \
 // RUN:     -Rpass-analysis=inline -Rpass-missed=inline \
 // RUN:     -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 \
 // RUN:     -verify
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN:     -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN:     -fno-experimental-new-pass-manager \
 // RUN:     -Rpass-analysis=inline -Rpass-missed=inline \
 // RUN:     -fdiagnostics-show-hotness -fdiagnostics-hotness-threshold=10 -verify
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN:     -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN:     -fno-experimental-new-pass-manager \
 // RUN:     -Rpass-analysis=inline 2>&1 | FileCheck -check-prefix=HOTNESS_OFF %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
 // RUN:     optimization-remark-with-hotness.c %s -emit-llvm-only \
 // RUN:     -fprofile-instrument-use-path=%t.profdata -Rpass=inline \
+// RUN:     -fno-experimental-new-pass-manager \
 // RUN:     -Rpass-analysis=inline -Rno-pass-with-hotness 2>&1 | FileCheck \
 // RUN:     -check-prefix=HOTNESS_OFF %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \
index 234958d9eaaa420e79d0d9b72ef75ca1c35c5da7..0b5e9a15f9cc1e87fb030471e1cc5378001c8b7e 100644 (file)
@@ -1,20 +1,30 @@
 // This file tests the -Rpass family of flags (-Rpass, -Rpass-missed
 // and -Rpass-analysis) with the inliner. The test is designed to
 // always trigger the inliner, so it should be independent of the
-// optimization level.
+// optimization level (under the legacy PM). The inliner is not added to the new
+// PM pipeline unless optimizations are present.
 
-// RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -verify
-// RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -emit-llvm-only -debug-info-kind=line-tables-only -verify
+// The inliner for the new PM does not seem to be enabled at O0, but we still
+// get the same remarks with at least O1. The remarks are also slightly
+// different and located in another test file.
+// RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -fno-experimental-new-pass-manager -emit-llvm-only -verify
+// RUN: %clang_cc1 %s -Rpass=inline -Rpass-analysis=inline -Rpass-missed=inline -O0 -fno-experimental-new-pass-manager -emit-llvm-only -debug-info-kind=line-tables-only -verify
 // RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>/dev/null | FileCheck %s
 //
 // Check that we can override -Rpass= with -Rno-pass.
-// RUN: %clang_cc1 %s -Rpass=inline -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -fno-experimental-new-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
 // RUN: %clang_cc1 %s -Rpass=inline -Rno-pass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
 // RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
-// RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -fno-experimental-new-pass-manager -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+//
+// The inliner for the new PM does not seem to be enabled at O0, but we still
+// get the same remarks with at least O1.
+// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -O1 -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -O1 -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
 //
 // Check that -w doesn't disable remarks.
-// RUN: %clang_cc1 %s -Rpass=inline -w -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -fno-experimental-new-pass-manager -w -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+// RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -O1 -w -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
 //
 // FIXME: -Reverything should imply -Rpass=.*.
 // RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS
index 465b227d0916f73f0e3478b58ecfad2b33253a20..4fd8eb32f80b5d2e937ca97afc567c1541ab38e0 100644 (file)
@@ -97,6 +97,10 @@ if config.clang_default_cxx_stdlib != '':
 if platform.system() not in ['FreeBSD']:
     config.available_features.add('crash-recovery')
 
+# Support for new pass manager.
+if config.enable_experimental_new_pass_manager:
+    config.available_features.add('experimental-new-pass-manager')
+
 # ANSI escape sequences in non-dumb terminal
 if platform.system() not in ['Windows']:
     config.available_features.add('ansi-escape-sequences')
index 06633b227c1ec99a18923f37224fd6eb2c60b3de..2be5a97f8fe0cd8677eed8b2dad55a5c9be01d95 100644 (file)
@@ -24,6 +24,7 @@ config.clang_staticanalyzer_z3 = "@LLVM_WITH_Z3@"
 config.clang_examples = @CLANG_BUILD_EXAMPLES@
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@
+config.enable_experimental_new_pass_manager = @ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER@
 config.host_arch = "@HOST_ARCH@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")