r306764 - [PM] Add support for sample PGO in the new pass manager (clang-side)

Dehao Chen via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 29 16:33:13 PDT 2017


Author: dehao
Date: Thu Jun 29 16:33:13 2017
New Revision: 306764

URL: http://llvm.org/viewvc/llvm-project?rev=306764&view=rev
Log:
[PM] Add support for sample PGO in the new pass manager (clang-side)

Summary: This implements the clang bits of https://reviews.llvm.org/D34720, and add corresponding test to verify if it worked.

Reviewers: chandlerc, davidxl, davide, tejohnson

Reviewed By: chandlerc, tejohnson

Subscribers: tejohnson, sanjoy, mehdi_amini, eraman, cfe-commits

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

Modified:
    cfe/trunk/lib/CodeGen/BackendUtil.cpp
    cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=306764&r1=306763&r2=306764&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 29 16:33:13 2017
@@ -857,11 +857,15 @@ void EmitAssemblyHelper::EmitAssemblyWit
   if (CodeGenOpts.hasProfileIRUse())
     PGOOpt.ProfileUseFile = CodeGenOpts.ProfileInstrumentUsePath;
 
+  if (!CodeGenOpts.SampleProfileFile.empty())
+    PGOOpt.SampleProfileFile = CodeGenOpts.SampleProfileFile;
+
   // Only pass a PGO options struct if -fprofile-generate or
   // -fprofile-use were passed on the cmdline.
   PassBuilder PB(TM.get(),
     (PGOOpt.RunProfileGen ||
-      !PGOOpt.ProfileUseFile.empty()) ?
+      !PGOOpt.ProfileUseFile.empty() ||
+      !PGOOpt.SampleProfileFile.empty()) ?
         Optional<PGOOptions>(PGOOpt) : None);
 
   LoopAnalysisManager LAM;

Modified: cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c?rev=306764&r1=306763&r2=306764&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c (original)
+++ cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c Thu Jun 29 16:33:13 2017
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
 // RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
+// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// FIXME: Run the following command once LTOPreLinkDefaultPipeline is
+//        customized.
+// %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 // Checks if hot call is inlined by normal compile, but not inlined by
 // thinlto compile.
 
@@ -36,7 +40,9 @@ void unroll() {
 // SAMPLEPGO-LABEL: define void @icp
 // THINLTO-LABEL: define void @icp
 // SAMPLEPGO: if.true.direct_targ
-// ThinLTO-NOT: if.true.direct_targ
+// FIXME: the following condition needs to be reversed once
+//        LTOPreLinkDefaultPipeline is customized.
+// THINLTO-NOT: if.true.direct_targ
 void icp(void (*p)()) {
   p();
 }




More information about the cfe-commits mailing list