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

2017-06-29 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.

LGTM too, but no need to wait for me to land this. =D


https://reviews.llvm.org/D34721



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-06-28 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

LGTM for when the dependent patches are in.


https://reviews.llvm.org/D34721



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-06-27 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh added inline comments.



Comment at: test/CodeGen/pgo-sample-thinlto-summary.c:4
+// 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
+// RUN: %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

This test will currently fail because PrepareForLLVM has not been passed down 
so that we do not know if it's in the thinlto compile phase.

Related discussion: 
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20170626/464868.html

This patch needs to commit after that issue is fixed.


https://reviews.llvm.org/D34721



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-06-27 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh created this revision.
Herald added subscribers: eraman, mehdi_amini, sanjoy.

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


https://reviews.llvm.org/D34721

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/pgo-sample-thinlto-summary.c


Index: test/CodeGen/pgo-sample-thinlto-summary.c
===
--- test/CodeGen/pgo-sample-thinlto-summary.c
+++ test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,5 +1,7 @@
 // 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
+// RUN: %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.
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -856,11 +856,15 @@
   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(PGOOpt) : None);
 
   LoopAnalysisManager LAM;


Index: test/CodeGen/pgo-sample-thinlto-summary.c
===
--- test/CodeGen/pgo-sample-thinlto-summary.c
+++ test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,5 +1,7 @@
 // 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
+// RUN: %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.
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -856,11 +856,15 @@
   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(PGOOpt) : None);
 
   LoopAnalysisManager LAM;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits