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/LTO/LTOBackend.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/LTO/LTOBackend.cpp')
-rw-r--r-- | llvm/lib/LTO/LTOBackend.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index ccc4276..7b3a759 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -243,19 +243,23 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, if (!Conf.SampleProfile.empty()) PGOOpt = PGOOptions(Conf.SampleProfile, "", Conf.ProfileRemapping, /*MemoryProfile=*/"", FS, PGOOptions::SampleUse, - PGOOptions::NoCSAction, true); + PGOOptions::NoCSAction, + PGOOptions::ColdFuncOpt::Default, true); else if (Conf.RunCSIRInstr) { PGOOpt = PGOOptions("", Conf.CSIRProfile, Conf.ProfileRemapping, /*MemoryProfile=*/"", FS, PGOOptions::IRUse, - PGOOptions::CSIRInstr, Conf.AddFSDiscriminator); + PGOOptions::CSIRInstr, PGOOptions::ColdFuncOpt::Default, + Conf.AddFSDiscriminator); } else if (!Conf.CSIRProfile.empty()) { PGOOpt = PGOOptions(Conf.CSIRProfile, "", Conf.ProfileRemapping, /*MemoryProfile=*/"", FS, PGOOptions::IRUse, - PGOOptions::CSIRUse, Conf.AddFSDiscriminator); + PGOOptions::CSIRUse, PGOOptions::ColdFuncOpt::Default, + Conf.AddFSDiscriminator); NoPGOWarnMismatch = !Conf.PGOWarnMismatch; } else if (Conf.AddFSDiscriminator) { PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr, - PGOOptions::NoAction, PGOOptions::NoCSAction, true); + PGOOptions::NoAction, PGOOptions::NoCSAction, + PGOOptions::ColdFuncOpt::Default, true); } TM->setPGOOption(PGOOpt); |