From b77436047a7650d2208443bd2b1d013b04646ffe Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Thu, 19 Nov 2020 14:40:33 -0800 Subject: [PATCH] [PGO] Make -disable-preinline work with NPM Fixes cspgo_profile_summary.ll under NPM. Reviewed By: xur Differential Revision: https://reviews.llvm.org/D91826 --- llvm/lib/Passes/PassBuilder.cpp | 4 +++- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp | 2 +- llvm/test/Transforms/PGOProfile/cspgo_profile_summary.ll | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index c3f4879d65f4..de8108f7d65b 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -322,6 +322,8 @@ extern cl::opt EnableKnowledgeRetention; extern cl::opt EnableMatrix; +extern cl::opt DisablePreInliner; + const PassBuilder::OptimizationLevel PassBuilder::OptimizationLevel::O0 = { /*SpeedLevel*/ 0, /*SizeLevel*/ 0}; @@ -822,7 +824,7 @@ void PassBuilder::addPGOInstrPasses(ModulePassManager &MPM, // the size grows, so let's be conservative here and skip this simplification // at -Os/Oz. We will not do this inline for context sensistive PGO (when // IsCS is true). - if (!Level.isOptimizingForSize() && !IsCS) { + if (!Level.isOptimizingForSize() && !IsCS && !DisablePreInliner) { InlineParams IP; IP.DefaultThreshold = PreInlineThreshold; diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index accf81def14c..e5ff26810179 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -111,7 +111,7 @@ static cl::opt UseLoopVersioningLICM( "enable-loop-versioning-licm", cl::init(false), cl::Hidden, cl::desc("Enable the experimental Loop Versioning LICM pass")); -static cl::opt +cl::opt DisablePreInliner("disable-preinline", cl::init(false), cl::Hidden, cl::desc("Disable pre-instrumentation inliner")); diff --git a/llvm/test/Transforms/PGOProfile/cspgo_profile_summary.ll b/llvm/test/Transforms/PGOProfile/cspgo_profile_summary.ll index 23096d02f00b..8a21b1bef86c 100644 --- a/llvm/test/Transforms/PGOProfile/cspgo_profile_summary.ll +++ b/llvm/test/Transforms/PGOProfile/cspgo_profile_summary.ll @@ -1,6 +1,7 @@ ; Test the profile summary for context sensitive PGO (CSPGO) ; RUN: llvm-profdata merge %S/Inputs/cspgo.proftext -o %t.profdata +; RUN: opt < %s -passes='default' -disable-preinline -pgo-instrument-entry=false -pgo-kind=pgo-instr-use-pipeline -profile-file=%t.profdata -S | FileCheck %s --check-prefix=PGOSUMMARY ; RUN: opt < %s -O2 -disable-preinline -pgo-instrument-entry=false -pgo-kind=pgo-instr-use-pipeline -profile-file=%t.profdata -S | FileCheck %s --check-prefix=PGOSUMMARY ; RUN: opt < %s -O2 -disable-preinline -pgo-instrument-entry=false -pgo-kind=pgo-instr-use-pipeline -profile-file=%t.profdata -S -cspgo-kind=cspgo-instr-use-pipeline| FileCheck %s --check-prefix=CSPGOSUMMARY