diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index 3364628be841e..6ae89a49b6b9a 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -174,9 +174,7 @@ static cl::opt WorkloadDefinitions( "}"), cl::Hidden); -static cl::opt - ContextualProfile("thinlto-pgo-ctx-prof", - cl::desc("Path to a contextual profile."), cl::Hidden); +extern cl::opt UseCtxProfile; namespace llvm { extern cl::opt EnableMemProfContextDisambiguation; @@ -671,7 +669,7 @@ class WorkloadImportsManager : public ModuleImportsManager { void loadFromCtxProf() { std::error_code EC; - auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(ContextualProfile); + auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(UseCtxProfile); if (std::error_code EC = BufferOrErr.getError()) { report_fatal_error("Failed to open contextual profile file"); return; @@ -722,12 +720,12 @@ class WorkloadImportsManager : public ModuleImportsManager { const ModuleSummaryIndex &Index, DenseMap *ExportLists) : ModuleImportsManager(IsPrevailing, Index, ExportLists) { - if (ContextualProfile.empty() == WorkloadDefinitions.empty()) { + if (UseCtxProfile.empty() == WorkloadDefinitions.empty()) { report_fatal_error( "Pass only one of: -thinlto-pgo-ctx-prof or -thinlto-workload-def"); return; } - if (!ContextualProfile.empty()) + if (!UseCtxProfile.empty()) loadFromCtxProf(); else loadFromJson(); @@ -749,7 +747,7 @@ std::unique_ptr ModuleImportsManager::create( IsPrevailing, const ModuleSummaryIndex &Index, DenseMap *ExportLists) { - if (WorkloadDefinitions.empty() && ContextualProfile.empty()) { + if (WorkloadDefinitions.empty() && UseCtxProfile.empty()) { LLVM_DEBUG(dbgs() << "[Workload] Using the regular imports manager.\n"); return std::unique_ptr( new ModuleImportsManager(IsPrevailing, Index, ExportLists)); diff --git a/llvm/test/ThinLTO/X86/ctxprof.ll b/llvm/test/ThinLTO/X86/ctxprof.ll index 4c86ec9f4c479..5c1f5f99daa16 100644 --- a/llvm/test/ThinLTO/X86/ctxprof.ll +++ b/llvm/test/ThinLTO/X86/ctxprof.ll @@ -46,7 +46,7 @@ ; RUN: llvm-ctxprof-util fromJSON --input %t_exp/ctxprof.json --output %t_exp/ctxprof.bitstream ; RUN: llvm-lto2 run %t/m1.bc %t/m2.bc \ ; RUN: -o %t_exp/result.o -save-temps \ -; RUN: -thinlto-pgo-ctx-prof=%t_exp/ctxprof.bitstream \ +; RUN: -use-ctx-profile=%t_exp/ctxprof.bitstream \ ; RUN: -r %t/m1.bc,m1_f1,plx \ ; RUN: -r %t/m2.bc,m2_f1,plx ; RUN: llvm-dis %t_exp/result.o.1.3.import.bc -o - | FileCheck %s --check-prefix=FIRST