From e7247f1010b546ca4d98a6ee40414d2d1cae0381 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Sat, 30 Sep 2023 16:59:37 -0700 Subject: [PATCH] [profiling] Move option declarations into headers This will make it possible to add visibility attributes to these variables. This also fixes some type mismatches between the declaration and the definition. Reviewed By: bogner, huangjd Differential Revision: https://reviews.llvm.org/D156599 --- clang/lib/CodeGen/BackendUtil.cpp | 2 +- llvm/include/llvm/ProfileData/ProfileCommon.h | 8 ++++++++ llvm/include/llvm/Transforms/IPO/SampleProfile.h | 8 ++++++++ .../llvm/Transforms/Instrumentation/PGOInstrumentation.h | 3 +++ llvm/lib/Analysis/ProfileSummaryInfo.cpp | 10 ---------- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp | 1 + llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp | 1 - llvm/tools/llvm-profgen/CSPreInliner.cpp | 8 +------- 8 files changed, 22 insertions(+), 19 deletions(-) diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index ccaf1e97e8e1..b0fe8e03aa0f 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -70,6 +70,7 @@ #include "llvm/Transforms/Instrumentation/KCFI.h" #include "llvm/Transforms/Instrumentation/MemProfiler.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" +#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" #include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h" #include "llvm/Transforms/Instrumentation/SanitizerCoverage.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" @@ -90,7 +91,6 @@ using namespace llvm; #include "llvm/Support/Extension.def" namespace llvm { -extern cl::opt DebugInfoCorrelate; extern cl::opt PrintPipelinePasses; // Experiment to move sanitizers earlier. diff --git a/llvm/include/llvm/ProfileData/ProfileCommon.h b/llvm/include/llvm/ProfileData/ProfileCommon.h index 4fe92cef4d72..eaab59484c94 100644 --- a/llvm/include/llvm/ProfileData/ProfileCommon.h +++ b/llvm/include/llvm/ProfileData/ProfileCommon.h @@ -28,6 +28,14 @@ namespace llvm { +extern cl::opt UseContextLessSummary; +extern cl::opt ProfileSummaryCutoffHot; +extern cl::opt ProfileSummaryCutoffCold; +extern cl::opt ProfileSummaryHugeWorkingSetSizeThreshold; +extern cl::opt ProfileSummaryLargeWorkingSetSizeThreshold; +extern cl::opt ProfileSummaryHotCount; +extern cl::opt ProfileSummaryColdCount; + namespace sampleprof { class FunctionSamples; diff --git a/llvm/include/llvm/Transforms/IPO/SampleProfile.h b/llvm/include/llvm/Transforms/IPO/SampleProfile.h index 2ef55949e236..e94f6ba55cd0 100644 --- a/llvm/include/llvm/Transforms/IPO/SampleProfile.h +++ b/llvm/include/llvm/Transforms/IPO/SampleProfile.h @@ -17,12 +17,20 @@ #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/IR/PassManager.h" #include "llvm/Pass.h" +#include "llvm/Support/CommandLine.h" #include namespace llvm { class Module; +extern cl::opt SampleHotCallSiteThreshold; +extern cl::opt SampleColdCallSiteThreshold; +extern cl::opt ProfileInlineGrowthLimit; +extern cl::opt ProfileInlineLimitMin; +extern cl::opt ProfileInlineLimitMax; +extern cl::opt SortProfiledSCC; + namespace vfs { class FileSystem; } // namespace vfs diff --git a/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h b/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h index c77d3214ed01..5b1977b7de9a 100644 --- a/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h +++ b/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h @@ -18,11 +18,14 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/IR/PassManager.h" +#include "llvm/Support/CommandLine.h" #include #include namespace llvm { +extern cl::opt DebugInfoCorrelate; + class Function; class Instruction; class Module; diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp index 203f1e42733f..fdad14571dfe 100644 --- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp +++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp @@ -23,16 +23,6 @@ #include using namespace llvm; -// Knobs for profile summary based thresholds. -namespace llvm { -extern cl::opt ProfileSummaryCutoffHot; -extern cl::opt ProfileSummaryCutoffCold; -extern cl::opt ProfileSummaryHugeWorkingSetSizeThreshold; -extern cl::opt ProfileSummaryLargeWorkingSetSizeThreshold; -extern cl::opt ProfileSummaryHotCount; -extern cl::opt ProfileSummaryColdCount; -} // namespace llvm - static cl::opt PartialProfile( "partial-profile", cl::Hidden, cl::init(false), cl::desc("Specify the current profile is used as a partial profile.")); diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp index 4464f5399382..57fcfd538369 100644 --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -47,6 +47,7 @@ #include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/TargetParser/Triple.h" +#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" #include "llvm/Transforms/Utils/ModuleUtils.h" #include "llvm/Transforms/Utils/SSAUpdater.h" #include diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 1fe9c57e550a..7ad1c9bc54f3 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -327,7 +327,6 @@ extern cl::opt PGOViewCounts; // Defined in Analysis/BlockFrequencyInfo.cpp: -view-bfi-func-name= extern cl::opt ViewBlockFreqFuncName; -extern cl::opt DebugInfoCorrelate; } // namespace llvm static cl::opt diff --git a/llvm/tools/llvm-profgen/CSPreInliner.cpp b/llvm/tools/llvm-profgen/CSPreInliner.cpp index 9421118a3bb1..e891ea8df490 100644 --- a/llvm/tools/llvm-profgen/CSPreInliner.cpp +++ b/llvm/tools/llvm-profgen/CSPreInliner.cpp @@ -11,6 +11,7 @@ #include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/Statistic.h" #include "llvm/DebugInfo/Symbolize/SymbolizableModule.h" +#include "llvm/Transforms/IPO/SampleProfile.h" #include #include @@ -35,13 +36,6 @@ STATISTIC( // TODO: the actual threshold to be tuned here because the size here is based // on machine code not LLVM IR. namespace llvm { -extern cl::opt SampleHotCallSiteThreshold; -extern cl::opt SampleColdCallSiteThreshold; -extern cl::opt ProfileInlineGrowthLimit; -extern cl::opt ProfileInlineLimitMin; -extern cl::opt ProfileInlineLimitMax; -extern cl::opt SortProfiledSCC; - cl::opt EnableCSPreInliner( "csspgo-preinliner", cl::Hidden, cl::init(true), cl::desc("Run a global pre-inliner to merge context profile based on " -- 2.11.4.GIT