[PATCH] D63626: [clang][NewPM] Remove exception handling before loading pgo sample profile data
Leonard Chan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 20 14:50:44 PDT 2019
leonardchan created this revision.
leonardchan added reviewers: chandlerc, phosek, serge-sans-paille, echristo.
leonardchan added a project: clang.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
leonardchan added a parent revision: D63156: [clang][NewPM] Add -fno-experimental-new-pass-manager to tests.
This patch ensures that SimplifyCFGPass and PostOrderFunctionAttrsPass come before SampleProfileLoaderPass on PGO runs in the new PM and fixes `clang/test/CodeGen/pgo-sample.c`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D63626
Files:
clang/test/CodeGen/pgo-sample.c
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Other/new-pm-pgo.ll
Index: llvm/test/Other/new-pm-pgo.ll
===================================================================
--- llvm/test/Other/new-pm-pgo.ll
+++ llvm/test/Other/new-pm-pgo.ll
@@ -16,11 +16,13 @@
; USE: Running pass: PGOMemOPSizeOpt
; SAMPLE_USE_O: Running pass: ModuleToFunctionPassAdaptor<{{.*}}AddDiscriminatorsPass{{.*}}>
; SAMPLE_USE_PRE_LINK: Running pass: ModuleToFunctionPassAdaptor<{{.*}}AddDiscriminatorsPass{{.*}}>
+; SAMPLE_USE_POST_LINK: Running pass: ModuleToPostOrderCGSCCPassAdaptor<llvm::PostOrderFunctionAttrsPass>
; SAMPLE_USE: Running pass: SimplifyCFGPass
; SAMPLE_USE: Running pass: SROA
; SAMPLE_USE: Running pass: EarlyCSEPass
; SAMPLE_USE: Running pass: LowerExpectIntrinsicPass
; SAMPLE_USE_POST_LINK: Running pass: InstCombinePass
+; SAMPLE_USE_POST_LINK: Running pass: SimplifyCFGPass
; SAMPLE_USE: Running pass: SampleProfileLoaderPass
; SAMPLE_USE_O: Running pass: PGOIndirectCallPromotion
; SAMPLE_USE_POST_LINK-NOT: Running pass: GlobalOptPass
Index: llvm/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -659,8 +659,15 @@
// More details about SamplePGO design can be found in:
// https://research.google.com/pubs/pub45290.html
// FIXME: revisit how SampleProfileLoad/Inliner/ICP is structured.
- if (LoadSampleProfile)
+ if (LoadSampleProfile) {
EarlyFPM.addPass(InstCombinePass());
+
+ // We must also remove exception handling before attaching sample profile
+ // data.
+ MPM.addPass(
+ createModuleToPostOrderCGSCCPassAdaptor(PostOrderFunctionAttrsPass()));
+ EarlyFPM.addPass(SimplifyCFGPass());
+ }
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(EarlyFPM)));
if (LoadSampleProfile) {
Index: clang/test/CodeGen/pgo-sample.c
===================================================================
--- clang/test/CodeGen/pgo-sample.c
+++ clang/test/CodeGen/pgo-sample.c
@@ -1,6 +1,16 @@
// Test if PGO sample use passes are invoked.
//
// Ensure Pass PGOInstrumentationGenPass is invoked.
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s
-// CHECK: Remove unused exception handling info
-// CHECK: Sample profile pass
+// RUN: %clang_cc1 -O2 -fno-experimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=LEGACY
+// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=NEWPM
+
+// LEGACY: Remove unused exception handling info
+// LEGACY: Sample profile pass
+
+// The new pass manager analog to PruneEH is a combination of 'function-attrs'
+// and 'function(simplify-cgf)'.
+// NEWPM-DAG: PostOrderFunctionAttrsPass
+// NEWPM-DAG: SimplifyCFGPass
+// NEWPM: SampleProfileLoaderPass
+
+int func(int a) { return a; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63626.205904.patch
Type: text/x-patch
Size: 3046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190620/29883279/attachment.bin>
More information about the llvm-commits
mailing list