diff options
author | Arthur Eubanks <aeubanks@google.com> | 2024-02-12 15:52:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-12 14:52:08 -0800 |
commit | 93cdd1b5cfa3735c599949b77e24dbfbe570441a (patch) | |
tree | 857248ba9ec00353b68ba375031402ab3bd4f864 /llvm/lib/Passes/PassBuilderPipelines.cpp | |
parent | 13d60ce2f262ef9055389908b63824e53b3054a1 (diff) | |
download | llvm-93cdd1b5cfa3735c599949b77e24dbfbe570441a.zip llvm-93cdd1b5cfa3735c599949b77e24dbfbe570441a.tar.gz llvm-93cdd1b5cfa3735c599949b77e24dbfbe570441a.tar.bz2 |
[PGO] Add ability to mark cold functions as optsize/minsize/optnone (#69030)
The performance of cold functions shouldn't matter too much, so if we
care about binary sizes, add an option to mark cold functions as
optsize/minsize for binary size, or optnone for compile times [1]. Clang
patch will be in a future patch.
This is intended to replace `shouldOptimizeForSize(Function&, ...)`.
We've seen multiple cases where calls to this expensive function, if not
careful, can blow up compile times. I will clean up users of that
function in a followup patch.
Initial version: https://reviews.llvm.org/D149800
[1]
https://discourse.llvm.org/t/rfc-new-feature-proposal-de-optimizing-cold-functions-using-pgo-info/56388
Diffstat (limited to 'llvm/lib/Passes/PassBuilderPipelines.cpp')
-rw-r--r-- | llvm/lib/Passes/PassBuilderPipelines.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index 4e233d9..142bd50 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -74,6 +74,7 @@ #include "llvm/Transforms/Instrumentation/InstrOrderFile.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/MemProfiler.h" +#include "llvm/Transforms/Instrumentation/PGOForceFunctionAttrs.h" #include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" #include "llvm/Transforms/Scalar/ADCE.h" #include "llvm/Transforms/Scalar/AlignmentFromAssumptions.h" @@ -213,6 +214,12 @@ static cl::opt<bool> cl::desc("Enable DFA jump threading"), cl::init(false), cl::Hidden); +// TODO: turn on and remove flag +static cl::opt<bool> EnablePGOForceFunctionAttrs( + "enable-pgo-force-function-attrs", + cl::desc("Enable pass to set function attributes based on PGO profiles"), + cl::init(false)); + static cl::opt<bool> EnableHotColdSplit("hot-cold-split", cl::desc("Enable hot-cold splitting pass")); @@ -1146,6 +1153,9 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level, if (EnableSyntheticCounts && !PGOOpt) MPM.addPass(SyntheticCountsPropagation()); + if (EnablePGOForceFunctionAttrs) + MPM.addPass(PGOForceFunctionAttrsPass(PGOOpt->ColdOptType)); + MPM.addPass(AlwaysInlinerPass(/*InsertLifetimeIntrinsics=*/true)); if (EnableModuleInliner) |