[pkg-d-commits] [ldc] 74/74: Add indirect call promotion pass when PGO info is available. (#2156)

Matthias Klumpp mak at moszumanska.debian.org
Thu Jul 13 20:54:20 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.3.0-beta2
in repository ldc.

commit 058d574f6b5b1b43b6edc872f96407c59ca992f0
Author: Johan Engelen <jbc.engelen at gmail.com>
Date:   Tue Jun 6 10:28:23 2017 +0200

    Add indirect call promotion pass when PGO info is available. (#2156)
    
    This pass was apparently implicit in LLVM < 5.0. Fixes test PGO/indirect_calls.d with LLVM 5.0.
---
 gen/optimizer.cpp | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/gen/optimizer.cpp b/gen/optimizer.cpp
index 0a1ad15..9e334de 100644
--- a/gen/optimizer.cpp
+++ b/gen/optimizer.cpp
@@ -212,9 +212,11 @@ static void addThreadSanitizerPass(const PassManagerBuilder &Builder,
   PM.add(createThreadSanitizerPass());
 }
 
-static void addInstrProfilingPass(legacy::PassManagerBase &mpm) {
+// Adds PGO instrumentation generation and use passes.
+static void addPGOPasses(legacy::PassManagerBase &mpm, unsigned optLevel) {
 #if LDC_WITH_PGO
   if (global.params.genInstrProf) {
+    // We are generating PGO instrumented code.
     InstrProfOptions options;
     options.NoRedZone = global.params.disableRedZone;
     if (global.params.datafileInstrProf)
@@ -224,6 +226,14 @@ static void addInstrProfilingPass(legacy::PassManagerBase &mpm) {
 #else
     mpm.add(createInstrProfilingPass(options));
 #endif
+  } else if (global.params.datafileInstrProf) {
+// We are generating code with PGO profile information available.
+#if LDC_LLVM_VER >= 500
+    // Do indirect call promotion from -O1
+    if (optLevel > 0) {
+      mpm.add(createPGOIndirectCallPromotionLegacyPass());
+    }
+#endif
   }
 #endif
 }
@@ -325,7 +335,7 @@ static void addOptimizationPasses(PassManagerBase &mpm,
   builder.addExtension(PassManagerBuilder::EP_OptimizerLast,
                        addStripExternalsPass);
 
-  addInstrProfilingPass(mpm);
+  addPGOPasses(mpm, optLevel);
 
   builder.populateFunctionPassManager(fpm);
   builder.populateModulePassManager(mpm);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list