Skip to content

Commit 6807ca8

Browse files
authored
[nfc][ctx_prof] Use one flag for the "use" scenario (#103377)
No need to have two flags, one for the thinlink and one for compilation.
1 parent 494eec0 commit 6807ca8

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

llvm/lib/Transforms/IPO/FunctionImport.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ static cl::opt<std::string> WorkloadDefinitions(
174174
"}"),
175175
cl::Hidden);
176176

177-
static cl::opt<std::string>
178-
ContextualProfile("thinlto-pgo-ctx-prof",
179-
cl::desc("Path to a contextual profile."), cl::Hidden);
177+
extern cl::opt<std::string> UseCtxProfile;
180178

181179
namespace llvm {
182180
extern cl::opt<bool> EnableMemProfContextDisambiguation;
@@ -671,7 +669,7 @@ class WorkloadImportsManager : public ModuleImportsManager {
671669

672670
void loadFromCtxProf() {
673671
std::error_code EC;
674-
auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(ContextualProfile);
672+
auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(UseCtxProfile);
675673
if (std::error_code EC = BufferOrErr.getError()) {
676674
report_fatal_error("Failed to open contextual profile file");
677675
return;
@@ -722,12 +720,12 @@ class WorkloadImportsManager : public ModuleImportsManager {
722720
const ModuleSummaryIndex &Index,
723721
DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists)
724722
: ModuleImportsManager(IsPrevailing, Index, ExportLists) {
725-
if (ContextualProfile.empty() == WorkloadDefinitions.empty()) {
723+
if (UseCtxProfile.empty() == WorkloadDefinitions.empty()) {
726724
report_fatal_error(
727725
"Pass only one of: -thinlto-pgo-ctx-prof or -thinlto-workload-def");
728726
return;
729727
}
730-
if (!ContextualProfile.empty())
728+
if (!UseCtxProfile.empty())
731729
loadFromCtxProf();
732730
else
733731
loadFromJson();
@@ -749,7 +747,7 @@ std::unique_ptr<ModuleImportsManager> ModuleImportsManager::create(
749747
IsPrevailing,
750748
const ModuleSummaryIndex &Index,
751749
DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists) {
752-
if (WorkloadDefinitions.empty() && ContextualProfile.empty()) {
750+
if (WorkloadDefinitions.empty() && UseCtxProfile.empty()) {
753751
LLVM_DEBUG(dbgs() << "[Workload] Using the regular imports manager.\n");
754752
return std::unique_ptr<ModuleImportsManager>(
755753
new ModuleImportsManager(IsPrevailing, Index, ExportLists));

llvm/test/ThinLTO/X86/ctxprof.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
; RUN: llvm-ctxprof-util fromJSON --input %t_exp/ctxprof.json --output %t_exp/ctxprof.bitstream
4747
; RUN: llvm-lto2 run %t/m1.bc %t/m2.bc \
4848
; RUN: -o %t_exp/result.o -save-temps \
49-
; RUN: -thinlto-pgo-ctx-prof=%t_exp/ctxprof.bitstream \
49+
; RUN: -use-ctx-profile=%t_exp/ctxprof.bitstream \
5050
; RUN: -r %t/m1.bc,m1_f1,plx \
5151
; RUN: -r %t/m2.bc,m2_f1,plx
5252
; RUN: llvm-dis %t_exp/result.o.1.3.import.bc -o - | FileCheck %s --check-prefix=FIRST

0 commit comments

Comments
 (0)