-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang][NewPM] Fixing remaining -O0 tests that are broken under new PM
- 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 llvm-svn: 363846
- Loading branch information
Showing
10 changed files
with
148 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
85 changes: 85 additions & 0 deletions
85
clang/test/Frontend/optimization-remark-with-hotness-new-pm.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters