diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index d066819871dfde..f0c9b9d4daf08b 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -770,7 +770,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline( CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName() : CodeGenOpts.InstrProfileOutput, "", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr, - PGOOptions::NoCSAction, CodeGenOpts.DebugInfoForProfiling, + PGOOptions::NoCSAction, PGOOptions::ColdFuncAttr::None, + CodeGenOpts.DebugInfoForProfiling, /*PseudoProbeForProfiling=*/false, CodeGenOpts.AtomicProfileUpdate); else if (CodeGenOpts.hasProfileIRUse()) { // -fprofile-use. @@ -779,28 +780,32 @@ void EmitAssemblyHelper::RunOptimizationPipeline( PGOOpt = PGOOptions( CodeGenOpts.ProfileInstrumentUsePath, "", CodeGenOpts.ProfileRemappingFile, CodeGenOpts.MemoryProfileUsePath, VFS, - PGOOptions::IRUse, CSAction, CodeGenOpts.DebugInfoForProfiling); + PGOOptions::IRUse, CSAction, PGOOptions::ColdFuncAttr::None, + CodeGenOpts.DebugInfoForProfiling); } else if (!CodeGenOpts.SampleProfileFile.empty()) // -fprofile-sample-use PGOOpt = PGOOptions( CodeGenOpts.SampleProfileFile, "", CodeGenOpts.ProfileRemappingFile, CodeGenOpts.MemoryProfileUsePath, VFS, PGOOptions::SampleUse, - PGOOptions::NoCSAction, CodeGenOpts.DebugInfoForProfiling, - CodeGenOpts.PseudoProbeForProfiling); + PGOOptions::NoCSAction, PGOOptions::ColdFuncAttr::None, + CodeGenOpts.DebugInfoForProfiling, CodeGenOpts.PseudoProbeForProfiling); else if (!CodeGenOpts.MemoryProfileUsePath.empty()) // -fmemory-profile-use (without any of the above options) PGOOpt = PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath, VFS, PGOOptions::NoAction, PGOOptions::NoCSAction, + PGOOptions::ColdFuncAttr::None, CodeGenOpts.DebugInfoForProfiling); else if (CodeGenOpts.PseudoProbeForProfiling) // -fpseudo-probe-for-profiling PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr, PGOOptions::NoAction, PGOOptions::NoCSAction, + PGOOptions::ColdFuncAttr::None, CodeGenOpts.DebugInfoForProfiling, true); else if (CodeGenOpts.DebugInfoForProfiling) // -fdebug-info-for-profiling PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr, - PGOOptions::NoAction, PGOOptions::NoCSAction, true); + PGOOptions::NoAction, PGOOptions::NoCSAction, + PGOOptions::ColdFuncAttr::None, true); // Check to see if we want to generate a CS profile. if (CodeGenOpts.hasProfileCSIRInstr()) { @@ -823,7 +828,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline( ? getDefaultProfileGenName() : CodeGenOpts.InstrProfileOutput, "", /*MemoryProfile=*/"", nullptr, PGOOptions::NoAction, - PGOOptions::CSIRInstr, CodeGenOpts.DebugInfoForProfiling); + PGOOptions::CSIRInstr, PGOOptions::ColdFuncAttr::None, + CodeGenOpts.DebugInfoForProfiling); } if (TM) TM->setPGOOption(PGOOpt); diff --git a/llvm/include/llvm/Support/PGOOptions.h b/llvm/include/llvm/Support/PGOOptions.h index 87eb29a8de48a0..fe21169a137016 100644 --- a/llvm/include/llvm/Support/PGOOptions.h +++ b/llvm/include/llvm/Support/PGOOptions.h @@ -27,10 +27,12 @@ class FileSystem; struct PGOOptions { enum PGOAction { NoAction, IRInstr, IRUse, SampleUse }; enum CSPGOAction { NoCSAction, CSIRInstr, CSIRUse }; + enum class ColdFuncAttr { None, OptSize, MinSize, OptNone }; PGOOptions(std::string ProfileFile, std::string CSProfileGenFile, std::string ProfileRemappingFile, std::string MemoryProfile, IntrusiveRefCntPtr FS, PGOAction Action = NoAction, CSPGOAction CSAction = NoCSAction, + ColdFuncAttr ColdType = ColdFuncAttr::None, bool DebugInfoForProfiling = false, bool PseudoProbeForProfiling = false, bool AtomicCounterUpdate = false); @@ -44,6 +46,7 @@ struct PGOOptions { std::string MemoryProfile; PGOAction Action; CSPGOAction CSAction; + ColdFuncAttr ColdType; bool DebugInfoForProfiling; bool PseudoProbeForProfiling; bool AtomicCounterUpdate; diff --git a/llvm/include/llvm/Transforms/Instrumentation/MarkColdFunctions.h b/llvm/include/llvm/Transforms/Instrumentation/MarkColdFunctions.h new file mode 100644 index 00000000000000..06aecc911d8827 --- /dev/null +++ b/llvm/include/llvm/Transforms/Instrumentation/MarkColdFunctions.h @@ -0,0 +1,28 @@ +//===- MarkColdFunctions.h - ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_MARKCOLDFUNCTIONS_H +#define LLVM_TRANSFORMS_INSTRUMENTATION_MARKCOLDFUNCTIONS_H + +#include "llvm/IR/PassManager.h" +#include "llvm/Support/PGOOptions.h" + +namespace llvm { + +struct MarkColdFunctionsPass : public PassInfoMixin { + MarkColdFunctionsPass(PGOOptions::ColdFuncAttr ColdType) + : ColdType(ColdType) {} + PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + +private: + PGOOptions::ColdFuncAttr ColdType; +}; + +} // namespace llvm + +#endif // LLVM_TRANSFORMS_INSTRUMENTATION_MARKCOLDFUNCTIONS_H diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index ccc4276e36dacf..8126b3563e077d 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::ColdFuncAttr::None, + true); else if (Conf.RunCSIRInstr) { PGOOpt = PGOOptions("", Conf.CSIRProfile, Conf.ProfileRemapping, /*MemoryProfile=*/"", FS, PGOOptions::IRUse, - PGOOptions::CSIRInstr, Conf.AddFSDiscriminator); + PGOOptions::CSIRInstr, PGOOptions::ColdFuncAttr::None, + Conf.AddFSDiscriminator); } else if (!Conf.CSIRProfile.empty()) { PGOOpt = PGOOptions(Conf.CSIRProfile, "", Conf.ProfileRemapping, /*MemoryProfile=*/"", FS, PGOOptions::IRUse, - PGOOptions::CSIRUse, Conf.AddFSDiscriminator); + PGOOptions::CSIRUse, PGOOptions::ColdFuncAttr::None, + Conf.AddFSDiscriminator); NoPGOWarnMismatch = !Conf.PGOWarnMismatch; } else if (Conf.AddFSDiscriminator) { PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr, - PGOOptions::NoAction, PGOOptions::NoCSAction, true); + PGOOptions::NoAction, PGOOptions::NoCSAction, + PGOOptions::ColdFuncAttr::None, true); } TM->setPGOOption(PGOOpt); diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index fde759026e5d78..451037fd38482f 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -143,6 +143,7 @@ #include "llvm/Transforms/Instrumentation/InstrOrderFile.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/KCFI.h" +#include "llvm/Transforms/Instrumentation/MarkColdFunctions.h" #include "llvm/Transforms/Instrumentation/MemProfiler.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" #include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" @@ -234,8 +235,8 @@ #include "llvm/Transforms/Utils/CanonicalizeAliases.h" #include "llvm/Transforms/Utils/CanonicalizeFreezeInLoops.h" #include "llvm/Transforms/Utils/CountVisits.h" -#include "llvm/Transforms/Utils/Debugify.h" #include "llvm/Transforms/Utils/DXILUpgrade.h" +#include "llvm/Transforms/Utils/Debugify.h" #include "llvm/Transforms/Utils/EntryExitInstrumenter.h" #include "llvm/Transforms/Utils/FixIrreducible.h" #include "llvm/Transforms/Utils/HelloWorld.h" diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index 600f8d43caaf21..3770edad56ff8c 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -73,6 +73,7 @@ #include "llvm/Transforms/Instrumentation/ControlHeightReduction.h" #include "llvm/Transforms/Instrumentation/InstrOrderFile.h" #include "llvm/Transforms/Instrumentation/InstrProfiling.h" +#include "llvm/Transforms/Instrumentation/MarkColdFunctions.h" #include "llvm/Transforms/Instrumentation/MemProfiler.h" #include "llvm/Transforms/Instrumentation/PGOInstrumentation.h" #include "llvm/Transforms/Scalar/ADCE.h" @@ -212,6 +213,12 @@ static cl::opt cl::desc("Enable DFA jump threading"), cl::init(false), cl::Hidden); +// TODO: turn on and remove flag +static cl::opt + EnableMarkColdFunctions("enable-mark-cold-functions", + cl::desc("Enable pass to mark cold functions"), + cl::init(false)); + static cl::opt EnableHotColdSplit("hot-cold-split", cl::desc("Enable hot-cold splitting pass")); @@ -1127,6 +1134,11 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level, if (EnableSyntheticCounts && !PGOOpt) MPM.addPass(SyntheticCountsPropagation()); + if (EnableMarkColdFunctions && PGOOpt && + (PGOOpt->Action == PGOOptions::SampleUse || + PGOOpt->Action == PGOOptions::IRUse)) + MPM.addPass(MarkColdFunctionsPass(PGOOpt->ColdType)); + if (EnableModuleInliner) MPM.addPass(buildModuleInlinerPipeline(Level, Phase)); else diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def index 91782d661ddd7b..adeaee070116bb 100644 --- a/llvm/lib/Passes/PassRegistry.def +++ b/llvm/lib/Passes/PassRegistry.def @@ -85,6 +85,7 @@ MODULE_PASS("print-ir-similarity", IRSimilarityAnalysisPrinterPass(dbgs())) MODULE_PASS("lower-global-dtors", LowerGlobalDtorsPass()) MODULE_PASS("lower-ifunc", LowerIFuncPass()) MODULE_PASS("lowertypetests", LowerTypeTestsPass()) +MODULE_PASS("mark-cold-functions", MarkColdFunctionsPass(PGOOpt ? PGOOpt->ColdType : PGOOptions::ColdFuncAttr::None)) MODULE_PASS("metarenamer", MetaRenamerPass()) MODULE_PASS("mergefunc", MergeFunctionsPass()) MODULE_PASS("name-anon-globals", NameAnonGlobalPass()) diff --git a/llvm/lib/Support/PGOOptions.cpp b/llvm/lib/Support/PGOOptions.cpp index 7e57b52e4ba2f5..5dfeafa188980e 100644 --- a/llvm/lib/Support/PGOOptions.cpp +++ b/llvm/lib/Support/PGOOptions.cpp @@ -15,11 +15,12 @@ PGOOptions::PGOOptions(std::string ProfileFile, std::string CSProfileGenFile, std::string ProfileRemappingFile, std::string MemoryProfile, IntrusiveRefCntPtr FS, PGOAction Action, - CSPGOAction CSAction, bool DebugInfoForProfiling, - bool PseudoProbeForProfiling, bool AtomicCounterUpdate) + CSPGOAction CSAction, ColdFuncAttr ColdType, + bool DebugInfoForProfiling, bool PseudoProbeForProfiling, + bool AtomicCounterUpdate) : ProfileFile(ProfileFile), CSProfileGenFile(CSProfileGenFile), ProfileRemappingFile(ProfileRemappingFile), MemoryProfile(MemoryProfile), - Action(Action), CSAction(CSAction), + Action(Action), CSAction(CSAction), ColdType(ColdType), DebugInfoForProfiling(DebugInfoForProfiling || (Action == SampleUse && !PseudoProbeForProfiling)), PseudoProbeForProfiling(PseudoProbeForProfiling), diff --git a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt index 424f1d43360677..b704726dd78037 100644 --- a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt +++ b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt @@ -6,6 +6,7 @@ add_llvm_component_library(LLVMInstrumentation DataFlowSanitizer.cpp GCOVProfiling.cpp BlockCoverageInference.cpp + MarkColdFunctions.cpp MemProfiler.cpp MemorySanitizer.cpp IndirectCallPromotion.cpp diff --git a/llvm/lib/Transforms/Instrumentation/MarkColdFunctions.cpp b/llvm/lib/Transforms/Instrumentation/MarkColdFunctions.cpp new file mode 100644 index 00000000000000..9037607132ef41 --- /dev/null +++ b/llvm/lib/Transforms/Instrumentation/MarkColdFunctions.cpp @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "llvm/Transforms/Instrumentation/MarkColdFunctions.h" +#include "llvm/Analysis/BlockFrequencyInfo.h" +#include "llvm/Analysis/ProfileSummaryInfo.h" +#include "llvm/IR/PassManager.h" + +using namespace llvm; + +PreservedAnalyses MarkColdFunctionsPass::run(Module &M, + ModuleAnalysisManager &AM) { + if (ColdType == PGOOptions::ColdFuncAttr::None) + return PreservedAnalyses::all(); + ProfileSummaryInfo &PSI = AM.getResult(M); + if (!PSI.hasProfileSummary()) + return PreservedAnalyses::all(); + FunctionAnalysisManager &FAM = + AM.getResult(M).getManager(); + bool MadeChange = false; + for (Function &F : M) { + if (F.isDeclaration()) + continue; + BlockFrequencyInfo &BFI = FAM.getResult(F); + if (!PSI.isFunctionColdInCallGraph(&F, BFI)) + continue; + // Add optsize/minsize/optnone if requested. + switch (ColdType) { + case PGOOptions::ColdFuncAttr::None: + assert(false); + break; + case PGOOptions::ColdFuncAttr::OptSize: + if (!F.hasFnAttribute(Attribute::OptimizeNone) && + !F.hasFnAttribute(Attribute::OptimizeForSize) && + !F.hasFnAttribute(Attribute::MinSize)) { + F.addFnAttr(Attribute::OptimizeForSize); + MadeChange = true; + } + break; + case PGOOptions::ColdFuncAttr::MinSize: + // Change optsize to minsize. + if (!F.hasFnAttribute(Attribute::OptimizeNone) && + !F.hasFnAttribute(Attribute::MinSize)) { + F.removeFnAttr(Attribute::OptimizeForSize); + F.addFnAttr(Attribute::MinSize); + MadeChange = true; + } + break; + case PGOOptions::ColdFuncAttr::OptNone: + // Strip optsize/minsize. + F.removeFnAttr(Attribute::OptimizeForSize); + F.removeFnAttr(Attribute::MinSize); + F.addFnAttr(Attribute::OptimizeNone); + F.addFnAttr(Attribute::NoInline); + MadeChange = true; + break; + } + } + return MadeChange ? PreservedAnalyses::none() : PreservedAnalyses::all(); +} diff --git a/llvm/test/Transforms/MarkColdFunctions/basic.ll b/llvm/test/Transforms/MarkColdFunctions/basic.ll new file mode 100644 index 00000000000000..f79e3a8f1dda7d --- /dev/null +++ b/llvm/test/Transforms/MarkColdFunctions/basic.ll @@ -0,0 +1,97 @@ +; RUN: opt < %s -passes=mark-cold-functions -pgo-kind=pgo-instr-use-pipeline -S -pgo-cold-func-attr=none | FileCheck %s --check-prefixes=NONE,CHECK +; RUN: opt < %s -passes=mark-cold-functions -pgo-kind=pgo-instr-use-pipeline -S -pgo-cold-func-attr=optsize | FileCheck %s --check-prefixes=OPTSIZE,CHECK +; RUN: opt < %s -passes=mark-cold-functions -pgo-kind=pgo-instr-use-pipeline -S -pgo-cold-func-attr=minsize | FileCheck %s --check-prefixes=MINSIZE,CHECK +; RUN: opt < %s -passes=mark-cold-functions -pgo-kind=pgo-instr-use-pipeline -S -pgo-cold-func-attr=optnone | FileCheck %s --check-prefixes=OPTNONE,CHECK + +; Should be no changes without profile data +; RUN: opt < %s -passes=mark-cold-functions -S -pgo-cold-func-attr=minsize | FileCheck %s --check-prefixes=NONE,CHECK + +; NONE-NOT: Function Attrs: +; OPTSIZE: Function Attrs: optsize{{$}} +; MINSIZE: Function Attrs: minsize{{$}} +; OPTNONE: Function Attrs: noinline optnone{{$}} +; CHECK: define void @cold() + +; NONE: Function Attrs: optsize{{$}} +; OPTSIZE: Function Attrs: optsize{{$}} +; MINSIZE: Function Attrs: minsize{{$}} +; OPTNONE: Function Attrs: noinline optnone{{$}} +; CHECK-NEXT: define void @cold1() + +; NONE: Function Attrs: minsize{{$}} +; OPTSIZE: Function Attrs: minsize{{$}} +; MINSIZE: Function Attrs: minsize{{$}} +; OPTNONE: Function Attrs: noinline optnone{{$}} +; CHECK-NEXT: define void @cold2() + +; CHECK: Function Attrs: noinline optnone{{$}} +; CHECK-NEXT: define void @cold3() + +; CHECK-NOT: Function Attrs: {{.*}}optsize +; CHECK-NOT: Function Attrs: {{.*}}minsize +; CHECK-NOT: Function Attrs: {{.*}}optnone + +@s = global i32 0 + +define void @cold() !prof !27 { + store i32 1, ptr @s, align 4 + ret void +} + +define void @cold1() optsize !prof !27 { + store i32 1, ptr @s, align 4 + ret void +} + +define void @cold2() minsize !prof !27 { + store i32 1, ptr @s, align 4 + ret void +} + +define void @cold3() noinline optnone !prof !27 { + store i32 1, ptr @s, align 4 + ret void +} + +define void @hot() !prof !28 { + %l = load i32, ptr @s, align 4 + %add = add nsw i32 %l, 4 + store i32 %add, ptr @s, align 4 + ret void +} + +attributes #0 = { optsize } +attributes #1 = { minsize } +attributes #2 = { noinline optnone } + +!llvm.module.flags = !{!0} + +!0 = !{i32 1, !"ProfileSummary", !1} +!1 = !{!2, !3, !4, !5, !6, !7, !8, !9} +!2 = !{!"ProfileFormat", !"InstrProf"} +!3 = !{!"TotalCount", i64 9040} +!4 = !{!"MaxCount", i64 9000} +!5 = !{!"MaxInternalCount", i64 0} +!6 = !{!"MaxFunctionCount", i64 9000} +!7 = !{!"NumCounts", i64 5} +!8 = !{!"NumFunctions", i64 5} +!9 = !{!"DetailedSummary", !10} +!10 = !{!11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26} +!11 = !{i32 10000, i64 9000, i32 1} +!12 = !{i32 100000, i64 9000, i32 1} +!13 = !{i32 200000, i64 9000, i32 1} +!14 = !{i32 300000, i64 9000, i32 1} +!15 = !{i32 400000, i64 9000, i32 1} +!16 = !{i32 500000, i64 9000, i32 1} +!17 = !{i32 600000, i64 9000, i32 1} +!18 = !{i32 700000, i64 9000, i32 1} +!19 = !{i32 800000, i64 9000, i32 1} +!20 = !{i32 900000, i64 9000, i32 1} +!21 = !{i32 950000, i64 9000, i32 1} +!22 = !{i32 990000, i64 9000, i32 1} +!23 = !{i32 999000, i64 10, i32 5} +!24 = !{i32 999900, i64 10, i32 5} +!25 = !{i32 999990, i64 10, i32 5} +!26 = !{i32 999999, i64 10, i32 5} +!27 = !{!"function_entry_count", i64 10} +!28 = !{!"function_entry_count", i64 9000} diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp index 6ae3f87099afd6..228eda8c3e0665 100644 --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -202,6 +202,18 @@ static cl::opt cl::desc("Path to the profile remapping file."), cl::Hidden); +static cl::opt PGOColdFuncAttr( + "pgo-cold-func-attr", cl::init(PGOOptions::ColdFuncAttr::None), cl::Hidden, + cl::desc( + "Function attribute to apply to cold functions as determined by PGO"), + cl::values(clEnumValN(PGOOptions::ColdFuncAttr::None, "none", "None"), + clEnumValN(PGOOptions::ColdFuncAttr::OptSize, "optsize", + "Mark cold functions with optsize."), + clEnumValN(PGOOptions::ColdFuncAttr::MinSize, "minsize", + "Mark cold functions with minsize."), + clEnumValN(PGOOptions::ColdFuncAttr::OptNone, "optnone", + "Mark cold functions with optnone."))); + static cl::opt DebugInfoForProfiling( "debug-info-for-profiling", cl::init(false), cl::Hidden, cl::desc("Emit special debug info to enable PGO profile generation.")); @@ -340,22 +352,24 @@ bool llvm::runPassPipeline( switch (PGOKindFlag) { case InstrGen: P = PGOOptions(ProfileFile, "", "", MemoryProfileFile, FS, - PGOOptions::IRInstr); + PGOOptions::IRInstr, PGOOptions::NoCSAction, + PGOColdFuncAttr); break; case InstrUse: P = PGOOptions(ProfileFile, "", ProfileRemappingFile, MemoryProfileFile, FS, - PGOOptions::IRUse); + PGOOptions::IRUse, PGOOptions::NoCSAction, PGOColdFuncAttr); break; case SampleUse: P = PGOOptions(ProfileFile, "", ProfileRemappingFile, MemoryProfileFile, FS, - PGOOptions::SampleUse); + PGOOptions::SampleUse, PGOOptions::NoCSAction, + PGOColdFuncAttr); break; case NoPGO: if (DebugInfoForProfiling || PseudoProbeForProfiling || !MemoryProfileFile.empty()) P = PGOOptions("", "", "", MemoryProfileFile, FS, PGOOptions::NoAction, - PGOOptions::NoCSAction, DebugInfoForProfiling, - PseudoProbeForProfiling); + PGOOptions::NoCSAction, PGOColdFuncAttr, + DebugInfoForProfiling, PseudoProbeForProfiling); else P = std::nullopt; } diff --git a/llvm/utils/gn/secondary/llvm/lib/Transforms/Instrumentation/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Transforms/Instrumentation/BUILD.gn index 0cce6558e0093c..42112878c93a61 100644 --- a/llvm/utils/gn/secondary/llvm/lib/Transforms/Instrumentation/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/lib/Transforms/Instrumentation/BUILD.gn @@ -23,6 +23,7 @@ static_library("Instrumentation") { "InstrProfiling.cpp", "Instrumentation.cpp", "KCFI.cpp", + "MarkColdFunctions.cpp", "MemProfiler.cpp", "MemorySanitizer.cpp", "PGOInstrumentation.cpp",