[clang] [lld] [llvm] Adding Matching and Inference Functionality to Propeller (PR #139008)
via cfe-commits
cfe-commits at lists.llvm.org
Tue May 20 22:41:00 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- llvm/include/llvm/CodeGen/FuncHotBBHashesProfileReader.h llvm/include/llvm/CodeGen/HotMachineBasicBlockInfoGenerator.h llvm/include/llvm/CodeGen/MachineBlockHashInfo.h llvm/lib/CodeGen/FuncHotBBHashesProfileReader.cpp llvm/lib/CodeGen/HotMachineBasicBlockInfoGenerator.cpp llvm/lib/CodeGen/MachineBlockHashInfo.cpp clang/include/clang/Basic/CodeGenOptions.h clang/lib/CodeGen/BackendUtil.cpp clang/lib/Driver/ToolChains/Clang.cpp lld/ELF/Config.h lld/ELF/Driver.cpp lld/ELF/LTO.cpp llvm/include/llvm/CodeGen/Passes.h llvm/include/llvm/InitializePasses.h llvm/include/llvm/LTO/Config.h llvm/include/llvm/Object/ELFTypes.h llvm/include/llvm/ObjectYAML/ELFYAML.h llvm/include/llvm/Support/PGOOptions.h llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/lib/CodeGen/BasicBlockSections.cpp llvm/lib/CodeGen/CodeGen.cpp llvm/lib/CodeGen/TargetPassConfig.cpp llvm/lib/LTO/LTOBackend.cpp llvm/lib/Object/ELF.cpp llvm/lib/ObjectYAML/ELFEmitter.cpp llvm/lib/ObjectYAML/ELFYAML.cpp llvm/lib/Support/PGOOptions.cpp llvm/tools/llvm-readobj/ELFDumper.cpp llvm/tools/obj2yaml/elf2yaml.cpp llvm/tools/opt/NewPMDriver.cpp llvm/unittests/Object/ELFObjectFileTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 4f5f5f677..401c16141 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -836,56 +836,52 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
if (CodeGenOpts.hasProfileIRInstr())
// -fprofile-generate.
- PGOOpt = PGOOptions(getProfileGenName(CodeGenOpts), "", "",
- CodeGenOpts.MemoryProfileUsePath,
- CodeGenOpts.PropellerProfileFile, nullptr,
- PGOOptions::IRInstr, PGOOptions::NoCSAction,
- ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling,
- /*PseudoProbeForProfiling=*/false,
- CodeGenOpts.AtomicProfileUpdate);
+ PGOOpt = PGOOptions(
+ getProfileGenName(CodeGenOpts), "", "",
+ CodeGenOpts.MemoryProfileUsePath, CodeGenOpts.PropellerProfileFile,
+ nullptr, PGOOptions::IRInstr, PGOOptions::NoCSAction, ClPGOColdFuncAttr,
+ CodeGenOpts.DebugInfoForProfiling,
+ /*PseudoProbeForProfiling=*/false, CodeGenOpts.AtomicProfileUpdate);
else if (CodeGenOpts.hasProfileIRUse()) {
// -fprofile-use.
auto CSAction = CodeGenOpts.hasProfileCSIRUse() ? PGOOptions::CSIRUse
: PGOOptions::NoCSAction;
- PGOOpt = PGOOptions(CodeGenOpts.ProfileInstrumentUsePath, "",
- CodeGenOpts.ProfileRemappingFile,
- CodeGenOpts.MemoryProfileUsePath,
- CodeGenOpts.PropellerProfileFile, VFS,
- PGOOptions::IRUse, CSAction, ClPGOColdFuncAttr,
- CodeGenOpts.DebugInfoForProfiling);
+ PGOOpt = PGOOptions(
+ CodeGenOpts.ProfileInstrumentUsePath, "",
+ CodeGenOpts.ProfileRemappingFile, CodeGenOpts.MemoryProfileUsePath,
+ CodeGenOpts.PropellerProfileFile, VFS, PGOOptions::IRUse, CSAction,
+ ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
} else if (!CodeGenOpts.SampleProfileFile.empty())
// -fprofile-sample-use
PGOOpt = PGOOptions(
CodeGenOpts.SampleProfileFile, "", CodeGenOpts.ProfileRemappingFile,
- CodeGenOpts.MemoryProfileUsePath,
- CodeGenOpts.PropellerProfileFile, VFS, PGOOptions::SampleUse,
- PGOOptions::NoCSAction, ClPGOColdFuncAttr,
+ CodeGenOpts.MemoryProfileUsePath, CodeGenOpts.PropellerProfileFile, VFS,
+ PGOOptions::SampleUse, PGOOptions::NoCSAction, ClPGOColdFuncAttr,
CodeGenOpts.DebugInfoForProfiling, CodeGenOpts.PseudoProbeForProfiling);
else if (!CodeGenOpts.MemoryProfileUsePath.empty())
// -fmemory-profile-use (without any of the above options)
- PGOOpt = PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath,
+ PGOOpt = PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath,
CodeGenOpts.PropellerProfileFile, VFS,
PGOOptions::NoAction, PGOOptions::NoCSAction,
ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
else if (!CodeGenOpts.PropellerProfileFile.empty())
// -fpropeller-profile-use (without any of the above options)
- PGOOpt = PGOOptions("", "", "", "",
- CodeGenOpts.PropellerProfileFile, VFS,
+ PGOOpt = PGOOptions("", "", "", "", CodeGenOpts.PropellerProfileFile, VFS,
PGOOptions::NoAction, PGOOptions::NoCSAction,
- ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
+ ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
else if (CodeGenOpts.PseudoProbeForProfiling)
// -fpseudo-probe-for-profiling
PGOOpt =
- PGOOptions("", "", "", /*MemoryProfile=*/"",
- /*PropellerProfileFile=*/"", nullptr,
- PGOOptions::NoAction, PGOOptions::NoCSAction,
- ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling, true);
+ PGOOptions("", "", "", /*MemoryProfile=*/"",
+ /*PropellerProfileFile=*/"", nullptr, PGOOptions::NoAction,
+ PGOOptions::NoCSAction, ClPGOColdFuncAttr,
+ CodeGenOpts.DebugInfoForProfiling, true);
else if (CodeGenOpts.DebugInfoForProfiling)
// -fdebug-info-for-profiling
- PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"",
- /*PropellerProfileFile=*/"", nullptr,
- PGOOptions::NoAction, PGOOptions::NoCSAction,
- ClPGOColdFuncAttr, true);
+ PGOOpt =
+ PGOOptions("", "", "", /*MemoryProfile=*/"",
+ /*PropellerProfileFile=*/"", nullptr, PGOOptions::NoAction,
+ PGOOptions::NoCSAction, ClPGOColdFuncAttr, true);
// Check to see if we want to generate a CS profile.
if (CodeGenOpts.hasProfileCSIRInstr()) {
@@ -901,10 +897,9 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
PGOOpt->CSAction = PGOOptions::CSIRInstr;
} else
PGOOpt = PGOOptions("", getProfileGenName(CodeGenOpts), "",
- /*MemoryProfile=*/"", /*PropellerProfileFile=*/"",
- nullptr, PGOOptions::NoAction,
- PGOOptions::CSIRInstr, ClPGOColdFuncAttr,
- CodeGenOpts.DebugInfoForProfiling);
+ /*MemoryProfile=*/"", /*PropellerProfileFile=*/"",
+ nullptr, PGOOptions::NoAction, PGOOptions::CSIRInstr,
+ ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
}
if (TM)
TM->setPGOOption(PGOOpt);
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 4ed102eb7..e0a5e0968 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6418,14 +6418,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-sample-profile-use-profi");
}
- if (auto *PropellerUseArg =
- Args.getLastArg(options::OPT_fpropeller_profile_use_EQ)) {
+ if (auto *PropellerUseArg =
+ Args.getLastArg(options::OPT_fpropeller_profile_use_EQ)) {
if (Arg *A = Args.getLastArg(options::OPT_fbasic_block_sections_EQ)) {
StringRef Val = A->getValue();
if (Val.starts_with("list="))
- D.Diag(diag::err_drv_argument_not_allowed_with)
- << PropellerUseArg->getAsString(Args)
- << "-fbasic-block-sections=list";
+ D.Diag(diag::err_drv_argument_not_allowed_with)
+ << PropellerUseArg->getAsString(Args)
+ << "-fbasic-block-sections=list";
}
PropellerUseArg->render(Args, CmdArgs);
}
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index eb7730da1..c506623fb 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1245,11 +1245,12 @@ static SmallVector<StringRef, 0> getSymbolOrderingFile(Ctx &ctx,
return names.takeVector();
}
-struct HotBBInfo{
+struct HotBBInfo {
uint32_t TotalBBSize = 0;
uint32_t HotBBSize = 0;
};
-static SmallVector<StringRef, 0> generateSymbolOrderingFromPropellerProfile(MemoryBufferRef mb) {
+static SmallVector<StringRef, 0>
+generateSymbolOrderingFromPropellerProfile(MemoryBufferRef mb) {
SmallVector<std::pair<StringRef, HotBBInfo>> names;
SmallVector<HotBBInfo *> hotBBInfos;
uint32_t line = 0;
@@ -1276,8 +1277,7 @@ static SmallVector<StringRef, 0> generateSymbolOrderingFromPropellerProfile(Memo
hotBBInfo->HotBBSize++;
}
}
- }
- else {
+ } else {
hotBBInfos.clear();
SmallVector<StringRef, 2> NamesWithTotalBBSize;
s.split(NamesWithTotalBBSize, ' ');
@@ -1915,13 +1915,16 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
ctx.arg.symbolOrderingFile = getSymbolOrderingFile(ctx, *buffer);
}
- if (auto *arg = args.getLastArg(OPT_propeller_profile_use)){
- if (args.hasArg(OPT_call_graph_ordering_file) || args.hasArg(OPT_symbol_ordering_file))
- error("--propeller-profile-use and --symbol-ordering-file and --call-graph-order-file "
+ if (auto *arg = args.getLastArg(OPT_propeller_profile_use)) {
+ if (args.hasArg(OPT_call_graph_ordering_file) ||
+ args.hasArg(OPT_symbol_ordering_file))
+ error("--propeller-profile-use and --symbol-ordering-file and "
+ "--call-graph-order-file "
"may not be used together");
if (auto buffer = readFile(ctx, arg->getValue())) {
ctx.arg.ltoPropellerProfile = arg->getValue();
- ctx.arg.symbolOrderingFile = generateSymbolOrderingFromPropellerProfile(*buffer);
+ ctx.arg.symbolOrderingFile =
+ generateSymbolOrderingFromPropellerProfile(*buffer);
}
}
diff --git a/llvm/include/llvm/CodeGen/FuncHotBBHashesProfileReader.h b/llvm/include/llvm/CodeGen/FuncHotBBHashesProfileReader.h
index 87ac37036..df39dc563 100644
--- a/llvm/include/llvm/CodeGen/FuncHotBBHashesProfileReader.h
+++ b/llvm/include/llvm/CodeGen/FuncHotBBHashesProfileReader.h
@@ -10,50 +10,51 @@
namespace llvm {
struct HotBBInfo {
- uint64_t BBHash;
- uint64_t Freq;
+ uint64_t BBHash;
+ uint64_t Freq;
};
class FuncHotBBHashesProfileReader : public ImmutablePass {
public:
- static char ID;
+ static char ID;
- FuncHotBBHashesProfileReader(const std::string PropellerProfile);
+ FuncHotBBHashesProfileReader(const std::string PropellerProfile);
- FuncHotBBHashesProfileReader();
+ FuncHotBBHashesProfileReader();
- StringRef getPassName() const override {
- return "Basic Block Frequency with Hash Profile Reader";
- }
+ StringRef getPassName() const override {
+ return "Basic Block Frequency with Hash Profile Reader";
+ }
- // return a vector of hit BB hashes for a function.
- std::pair<bool, SmallVector<HotBBInfo, 4>>
- getHotBBInfosForFunction(StringRef FuncName) const;
+ // return a vector of hit BB hashes for a function.
+ std::pair<bool, SmallVector<HotBBInfo, 4>>
+ getHotBBInfosForFunction(StringRef FuncName) const;
- // Reads the profile for matching functions.
- bool doInitialization(Module &M) override;
+ // Reads the profile for matching functions.
+ bool doInitialization(Module &M) override;
private:
- std::unique_ptr<MemoryBuffer> MBuf;
-
- StringRef getAliasName(StringRef FuncName) const {
- auto R = FuncAliasMap.find(FuncName);
- return R == FuncAliasMap.end() ? FuncName : R->second;
- }
-
- // Reads the basic block frequency with hash profile for functions in this module.
- Error ReadProfile();
-
- // Profile file path.
- std::string PropellerFilePath;
-
- // Some functions have alias names. We use this map to find the main alias
- // name for which we have mapping in ProgramBBClusterInfo.
- StringMap<StringRef> FuncAliasMap;
-
- // record the frequency of basic block,
- // the basic block is represented by its hash.
- StringMap<SmallVector<HotBBInfo, 4>> FuncToHotBBHashes;
+ std::unique_ptr<MemoryBuffer> MBuf;
+
+ StringRef getAliasName(StringRef FuncName) const {
+ auto R = FuncAliasMap.find(FuncName);
+ return R == FuncAliasMap.end() ? FuncName : R->second;
+ }
+
+ // Reads the basic block frequency with hash profile for functions in this
+ // module.
+ Error ReadProfile();
+
+ // Profile file path.
+ std::string PropellerFilePath;
+
+ // Some functions have alias names. We use this map to find the main alias
+ // name for which we have mapping in ProgramBBClusterInfo.
+ StringMap<StringRef> FuncAliasMap;
+
+ // record the frequency of basic block,
+ // the basic block is represented by its hash.
+ StringMap<SmallVector<HotBBInfo, 4>> FuncToHotBBHashes;
};
ImmutablePass *
diff --git a/llvm/include/llvm/CodeGen/HotMachineBasicBlockInfoGenerator.h b/llvm/include/llvm/CodeGen/HotMachineBasicBlockInfoGenerator.h
index d9f0c2110..e8a435822 100644
--- a/llvm/include/llvm/CodeGen/HotMachineBasicBlockInfoGenerator.h
+++ b/llvm/include/llvm/CodeGen/HotMachineBasicBlockInfoGenerator.h
@@ -1,9 +1,9 @@
#ifndef LLVM_CODEGEN_HotMachineBasicBlockInfoGenerator_H
#define LLVM_CODEGEN_HotMachineBasicBlockInfoGenerator_H
+#include "llvm/CodeGen/FuncHotBBHashesProfileReader.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Transforms/Utils/SampleProfileInference.h"
-#include "llvm/CodeGen/FuncHotBBHashesProfileReader.h"
namespace llvm {
@@ -20,30 +20,28 @@ public:
bool runOnMachineFunction(MachineFunction &F) override;
- std::optional<SmallVector<MachineBasicBlock *, 4>> getHotMBBs(StringRef FuncName) const;
+ std::optional<SmallVector<MachineBasicBlock *, 4>>
+ getHotMBBs(StringRef FuncName) const;
private:
using Edge = std::pair<const MachineBasicBlock *, const MachineBasicBlock *>;
using BlockWeightMap = DenseMap<const MachineBasicBlock *, uint64_t>;
using EdgeWeightMap = DenseMap<Edge, uint64_t>;
- using BlockEdgeMap =
- DenseMap<const MachineBasicBlock *, SmallVector<const MachineBasicBlock *, 8>>;
+ using BlockEdgeMap = DenseMap<const MachineBasicBlock *,
+ SmallVector<const MachineBasicBlock *, 8>>;
DenseMap<StringRef, SmallVector<MachineBasicBlock *, 4>> FuncToHotMBBs;
-
- void matchHotBBsByHashes(
- MachineFunction &MF,
- SmallVector<HotBBInfo, 4> &HotMBBInfos,
- BlockWeightMap &MBBToFreq,
- BlockEdgeMap &Successors,
- SmallVector<MachineBasicBlock *, 4> &HotBBs);
-
- void generateHotBBsforFunction(
- MachineFunction &MF,
- BlockWeightMap &OriBlockWeights,
- BlockWeightMap &BlockWeights,
- EdgeWeightMap &EdgeWeights,
- SmallVector<MachineBasicBlock *, 4> &HotBBs);
+
+ void matchHotBBsByHashes(MachineFunction &MF,
+ SmallVector<HotBBInfo, 4> &HotMBBInfos,
+ BlockWeightMap &MBBToFreq, BlockEdgeMap &Successors,
+ SmallVector<MachineBasicBlock *, 4> &HotBBs);
+
+ void generateHotBBsforFunction(MachineFunction &MF,
+ BlockWeightMap &OriBlockWeights,
+ BlockWeightMap &BlockWeights,
+ EdgeWeightMap &EdgeWeights,
+ SmallVector<MachineBasicBlock *, 4> &HotBBs);
};
} // end namespace llvm
diff --git a/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h b/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
index a943f7135..9ef7f1e91 100644
--- a/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineBlockHashInfo.h
@@ -92,9 +92,7 @@ public:
static char ID;
MachineBlockHashInfo();
- StringRef getPassName() const override {
- return "Basic Block Hash Compute";
- }
+ StringRef getPassName() const override { return "Basic Block Hash Compute"; }
void getAnalysisUsage(AnalysisUsage &AU) const override;
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index 558b6cbb1..966d58527 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -118,7 +118,7 @@ void initializeFinalizeMachineBundlesPass(PassRegistry &);
void initializeFixIrreduciblePass(PassRegistry &);
void initializeFixupStatepointCallerSavedLegacyPass(PassRegistry &);
void initializeFlattenCFGLegacyPassPass(PassRegistry &);
-void initializeFuncHotBBHashesProfileReaderPass(PassRegistry&);
+void initializeFuncHotBBHashesProfileReaderPass(PassRegistry &);
void initializeFuncletLayoutPass(PassRegistry &);
void initializeGCEmptyBasicBlocksPass(PassRegistry &);
void initializeGCMachineCodeAnalysisPass(PassRegistry &);
@@ -128,7 +128,7 @@ void initializeGlobalMergeFuncPassWrapperPass(PassRegistry &);
void initializeGlobalMergePass(PassRegistry &);
void initializeGlobalsAAWrapperPassPass(PassRegistry &);
void initializeHardwareLoopsLegacyPass(PassRegistry &);
-void initializeHotMachineBasicBlockInfoGeneratorPass(PassRegistry&);
+void initializeHotMachineBasicBlockInfoGeneratorPass(PassRegistry &);
void initializeMIRProfileLoaderPassPass(PassRegistry &);
void initializeIRSimilarityIdentifierWrapperPassPass(PassRegistry &);
void initializeIRTranslatorPass(PassRegistry &);
@@ -187,7 +187,7 @@ void initializeMIRCanonicalizerPass(PassRegistry &);
void initializeMIRNamerPass(PassRegistry &);
void initializeMIRPrintingPassPass(PassRegistry &);
void initializeMachineBlockFrequencyInfoWrapperPassPass(PassRegistry &);
-void initializeMachineBlockHashInfoPass(PassRegistry&);
+void initializeMachineBlockHashInfoPass(PassRegistry &);
void initializeMachineBlockPlacementLegacyPass(PassRegistry &);
void initializeMachineBlockPlacementStatsLegacyPass(PassRegistry &);
void initializeMachineBranchProbabilityInfoWrapperPassPass(PassRegistry &);
diff --git a/llvm/include/llvm/Object/ELFTypes.h b/llvm/include/llvm/Object/ELFTypes.h
index 40b7ec378..4a4fea0d1 100644
--- a/llvm/include/llvm/Object/ELFTypes.h
+++ b/llvm/include/llvm/Object/ELFTypes.h
@@ -916,8 +916,9 @@ struct BBAddrMap {
false}; // Metdata for this basic block.
uint64_t Hash = 0;
- BBEntry(uint32_t ID, uint32_t Offset, uint32_t Size, Metadata MD, uint64_t Hash)
- : ID(ID), Offset(Offset), Size(Size), MD(MD), Hash(Hash){};
+ BBEntry(uint32_t ID, uint32_t Offset, uint32_t Size, Metadata MD,
+ uint64_t Hash)
+ : ID(ID), Offset(Offset), Size(Size), MD(MD), Hash(Hash) {};
bool operator==(const BBEntry &Other) const {
return ID == Other.ID && Offset == Other.Offset && Size == Other.Size &&
diff --git a/llvm/lib/CodeGen/BasicBlockSections.cpp b/llvm/lib/CodeGen/BasicBlockSections.cpp
index 2b9091875..ac3fe3d22 100644
--- a/llvm/lib/CodeGen/BasicBlockSections.cpp
+++ b/llvm/lib/CodeGen/BasicBlockSections.cpp
@@ -179,21 +179,22 @@ updateBranches(MachineFunction &MF,
}
// This function generates the machine basic block clusters of "hot" blocks.
-static std::pair<bool, SmallVector<BBClusterInfo>>
+static std::pair<bool, SmallVector<BBClusterInfo>>
createBBClusterInfoForFunction(
- const MachineFunction &MF,
+ const MachineFunction &MF,
HotMachineBasicBlockInfoGenerator *HotBBGenerator) {
unsigned CurrentCluster = 0;
auto OptHotBBs = HotBBGenerator->getHotMBBs(MF.getName());
if (!OptHotBBs)
return std::pair(false, SmallVector<BBClusterInfo>{});
- auto& HotMBBs = *OptHotBBs;
- if(!HotMBBs.empty()) {
+ auto &HotMBBs = *OptHotBBs;
+ if (!HotMBBs.empty()) {
SmallVector<BBClusterInfo, 4> BBClusterInfos;
unsigned CurrentPosition = 0;
for (auto &MBB : HotMBBs) {
if (MBB->getBBID()) {
- BBClusterInfos.push_back({*(MBB->getBBID()), CurrentCluster, CurrentPosition++});
+ BBClusterInfos.push_back(
+ {*(MBB->getBBID()), CurrentCluster, CurrentPosition++});
}
}
return std::pair(true, std::move(BBClusterInfos));
@@ -201,7 +202,6 @@ createBBClusterInfoForFunction(
return std::pair(false, SmallVector<BBClusterInfo>{});
}
-
// This function sorts basic blocks according to the cluster's information.
// All explicitly specified clusters of basic blocks will be ordered
// accordingly. All non-specified BBs go into a separate "Cold" section.
@@ -353,7 +353,7 @@ bool BasicBlockSections::handleBBSections(MachineFunction &MF) {
auto HotBBGenerator = &getAnalysis<HotMachineBasicBlockInfoGenerator>();
ExpClusterInfo = createBBClusterInfoForFunction(MF, HotBBGenerator);
}
- if (!ExpClusterInfo.first)
+ if (!ExpClusterInfo.first)
return false;
for (auto &BBClusterInfo : ExpClusterInfo.second) {
FuncClusterInfo.try_emplace(BBClusterInfo.BBID, BBClusterInfo);
diff --git a/llvm/lib/CodeGen/FuncHotBBHashesProfileReader.cpp b/llvm/lib/CodeGen/FuncHotBBHashesProfileReader.cpp
index 1bbd046e5..4549ad9d6 100644
--- a/llvm/lib/CodeGen/FuncHotBBHashesProfileReader.cpp
+++ b/llvm/lib/CodeGen/FuncHotBBHashesProfileReader.cpp
@@ -1,46 +1,49 @@
#include "llvm/CodeGen/FuncHotBBHashesProfileReader.h"
#include "llvm/IR/DebugInfoMetadata.h"
-#include "llvm/Support/Path.h"
#include "llvm/Support/LineIterator.h"
+#include "llvm/Support/Path.h"
#include <fstream>
using namespace llvm;
char FuncHotBBHashesProfileReader::ID = 0;
INITIALIZE_PASS(FuncHotBBHashesProfileReader, "func-hotbb-hashes-reader",
- "Read and parse the hashes of hot basic blocks for function.", false,
- false)
+ "Read and parse the hashes of hot basic blocks for function.",
+ false, false)
-FuncHotBBHashesProfileReader::FuncHotBBHashesProfileReader(const std::string PropellerProfile)
+FuncHotBBHashesProfileReader::FuncHotBBHashesProfileReader(
+ const std::string PropellerProfile)
: ImmutablePass(ID), PropellerFilePath(PropellerProfile) {
- initializeFuncHotBBHashesProfileReaderPass(
- *PassRegistry::getPassRegistry());
+ initializeFuncHotBBHashesProfileReaderPass(*PassRegistry::getPassRegistry());
}
-FuncHotBBHashesProfileReader::FuncHotBBHashesProfileReader() : ImmutablePass(ID) {
- initializeFuncHotBBHashesProfileReaderPass(
- *PassRegistry::getPassRegistry());
+FuncHotBBHashesProfileReader::FuncHotBBHashesProfileReader()
+ : ImmutablePass(ID) {
+ initializeFuncHotBBHashesProfileReaderPass(*PassRegistry::getPassRegistry());
}
std::pair<bool, SmallVector<HotBBInfo, 4>>
-FuncHotBBHashesProfileReader::getHotBBInfosForFunction(StringRef FuncName) const {
- auto R = FuncToHotBBHashes.find(getAliasName(FuncName));
- return R != FuncToHotBBHashes.end()
- ? std::pair(true, R->second)
- : std::pair(false, SmallVector<HotBBInfo, 4>{});
+FuncHotBBHashesProfileReader::getHotBBInfosForFunction(
+ StringRef FuncName) const {
+ auto R = FuncToHotBBHashes.find(getAliasName(FuncName));
+ return R != FuncToHotBBHashes.end()
+ ? std::pair(true, R->second)
+ : std::pair(false, SmallVector<HotBBInfo, 4>{});
}
-// Reads the basic block frequency with hash profile for functions in this module.
-// The profile record the map from basic block hash to basic block frequency of
-// each function. The profile format looks like this:
+// Reads the basic block frequency with hash profile for functions in this
+// module. The profile record the map from basic block hash to basic block
+// frequency of each function. The profile format looks like this:
// ---------------------------------
// !foo
// !!0x123 156 0
// !!0x456 300 2
Error FuncHotBBHashesProfileReader::ReadProfile() {
- ErrorOr<std::unique_ptr<MemoryBuffer>> buffer = MemoryBuffer::getFile(PropellerFilePath);
+ ErrorOr<std::unique_ptr<MemoryBuffer>> buffer =
+ MemoryBuffer::getFile(PropellerFilePath);
if (!buffer) {
- return make_error<StringError>(Twine("Invalid propeller profile."), inconvertibleErrorCode());
+ return make_error<StringError>(Twine("Invalid propeller profile."),
+ inconvertibleErrorCode());
}
MBuf = std::move(*buffer);
line_iterator LineIt(*MBuf, /*SkipBlanks=*/true, /*CommentMarker=*/'#');
@@ -74,18 +77,19 @@ Error FuncHotBBHashesProfileReader::ReadProfile() {
BBHashes[0].consume_front("0x");
if (getAsUnsignedInteger(BBHashes[0], 16, Hash)) {
return invalidProfileError(Twine("Unsigned integer expected: '") +
- BBHashes[0] + "'.");
+ BBHashes[0] + "'.");
}
if (getAsUnsignedInteger(BBHashes[1], 10, Freq)) {
return invalidProfileError(Twine("Unsigned integer expected: '") +
- BBHashes[1] + "'.");
+ BBHashes[1] + "'.");
}
- auto It = std::find_if(FI->second.begin(), FI->second.end(),
+ auto It = std::find_if(
+ FI->second.begin(), FI->second.end(),
[Hash](HotBBInfo &BBInfo) { return BBInfo.BBHash == Hash; });
if (It == FI->second.end())
FI->second.push_back({Hash, Freq});
} else {
- // This is a function name specifier.
+ // This is a function name specifier.
auto [AliasesStr, TotalBBSize] = S.split(' ');
// Function aliases are separated using '/'. We use the first function
// name for the cluster info mapping and delegate all other aliases to
@@ -117,7 +121,7 @@ bool FuncHotBBHashesProfileReader::doInitialization(Module &M) {
return false;
}
-ImmutablePass *
-llvm::createFuncHotBBHashesProfileReaderPass(const std::string PropellerProfile) {
+ImmutablePass *llvm::createFuncHotBBHashesProfileReaderPass(
+ const std::string PropellerProfile) {
return new FuncHotBBHashesProfileReader(PropellerProfile);
}
\ No newline at end of file
diff --git a/llvm/lib/CodeGen/HotMachineBasicBlockInfoGenerator.cpp b/llvm/lib/CodeGen/HotMachineBasicBlockInfoGenerator.cpp
index 66f8fc4e3..31471d9ec 100644
--- a/llvm/lib/CodeGen/HotMachineBasicBlockInfoGenerator.cpp
+++ b/llvm/lib/CodeGen/HotMachineBasicBlockInfoGenerator.cpp
@@ -1,19 +1,23 @@
#include "llvm/CodeGen/HotMachineBasicBlockInfoGenerator.h"
-#include "llvm/InitializePasses.h"
#include "llvm/CodeGen/MachineBlockHashInfo.h"
#include "llvm/CodeGen/Passes.h"
-#include "llvm/Transforms/Utils/CodeLayout.h"
+#include "llvm/InitializePasses.h"
#include "llvm/Target/TargetMachine.h"
-#include <unordered_set>
+#include "llvm/Transforms/Utils/CodeLayout.h"
#include <llvm/Support/CommandLine.h>
+#include <unordered_set>
using namespace llvm;
-static cl::opt<bool> PropellerMatchInfer("propeller-match-infer",
- cl::desc("Use match&infer to evaluate stale profile"), cl::init(false), cl::Optional);
+static cl::opt<bool>
+ PropellerMatchInfer("propeller-match-infer",
+ cl::desc("Use match&infer to evaluate stale profile"),
+ cl::init(false), cl::Optional);
-static cl::opt<float> PropellerInferThreshold("propeller-infer-threshold",
- cl::desc("Threshold for infer stale profile"), cl::init(0.6), cl::Optional);
+static cl::opt<float>
+ PropellerInferThreshold("propeller-infer-threshold",
+ cl::desc("Threshold for infer stale profile"),
+ cl::init(0.6), cl::Optional);
/// The object is used to identify and match basic blocks given their hashes.
class StaleMatcher {
@@ -55,27 +59,33 @@ private:
std::unordered_map<uint16_t, std::vector<HashBlockPairType>> OpHashToBlocks;
};
-INITIALIZE_PASS_BEGIN(HotMachineBasicBlockInfoGenerator, "machine-block-match-infer",
- "Machine Block Matching and Inference Analysis", true, true)
+INITIALIZE_PASS_BEGIN(HotMachineBasicBlockInfoGenerator,
+ "machine-block-match-infer",
+ "Machine Block Matching and Inference Analysis", true,
+ true)
INITIALIZE_PASS_DEPENDENCY(MachineBlockHashInfo)
-INITIALIZE_PASS_DEPENDENCY(FuncHotBBHashesProfileReader)
-INITIALIZE_PASS_END(HotMachineBasicBlockInfoGenerator, "machine-block-match-infer",
+INITIALIZE_PASS_DEPENDENCY(FuncHotBBHashesProfileReader)
+INITIALIZE_PASS_END(HotMachineBasicBlockInfoGenerator,
+ "machine-block-match-infer",
"Machine Block Matching and Inference Analysis", true, true)
char HotMachineBasicBlockInfoGenerator::ID = 0;
-HotMachineBasicBlockInfoGenerator::HotMachineBasicBlockInfoGenerator() : MachineFunctionPass(ID) {
- initializeHotMachineBasicBlockInfoGeneratorPass(*PassRegistry::getPassRegistry());
+HotMachineBasicBlockInfoGenerator::HotMachineBasicBlockInfoGenerator()
+ : MachineFunctionPass(ID) {
+ initializeHotMachineBasicBlockInfoGeneratorPass(
+ *PassRegistry::getPassRegistry());
}
-void HotMachineBasicBlockInfoGenerator::getAnalysisUsage(AnalysisUsage &AU) const {
+void HotMachineBasicBlockInfoGenerator::getAnalysisUsage(
+ AnalysisUsage &AU) const {
AU.addRequired<MachineBlockHashInfo>();
AU.addRequired<FuncHotBBHashesProfileReader>();
AU.setPreservesAll();
MachineFunctionPass::getAnalysisUsage(AU);
}
-std::optional<SmallVector<MachineBasicBlock *, 4>>
+std::optional<SmallVector<MachineBasicBlock *, 4>>
HotMachineBasicBlockInfoGenerator::getHotMBBs(StringRef FuncName) const {
auto It = FuncToHotMBBs.find(FuncName);
if (It == FuncToHotMBBs.end()) {
@@ -83,12 +93,10 @@ HotMachineBasicBlockInfoGenerator::getHotMBBs(StringRef FuncName) const {
}
return It->second;
}
-
+
void HotMachineBasicBlockInfoGenerator::matchHotBBsByHashes(
- MachineFunction &MF,
- SmallVector<HotBBInfo, 4> &HotMBBInfos,
- BlockWeightMap &MBBToFreq,
- BlockEdgeMap &Successors,
+ MachineFunction &MF, SmallVector<HotBBInfo, 4> &HotMBBInfos,
+ BlockWeightMap &MBBToFreq, BlockEdgeMap &Successors,
SmallVector<MachineBasicBlock *, 4> &HotBBs) {
std::vector<MachineBasicBlock *> Blocks;
std::vector<BlendedBlockHash> Hashes;
@@ -103,8 +111,8 @@ void HotMachineBasicBlockInfoGenerator::matchHotBBsByHashes(
StaleMatcher Matcher;
Matcher.init(Blocks, Hashes);
for (auto &item : HotMBBInfos) {
- MachineBasicBlock *Block
- = Matcher.matchBlock(BlendedBlockHash(item.BBHash));
+ MachineBasicBlock *Block =
+ Matcher.matchBlock(BlendedBlockHash(item.BBHash));
if (Block != nullptr) {
HotBBs.push_back(Block);
MBBToFreq[Block] = item.Freq;
@@ -113,10 +121,8 @@ void HotMachineBasicBlockInfoGenerator::matchHotBBsByHashes(
}
void HotMachineBasicBlockInfoGenerator::generateHotBBsforFunction(
- MachineFunction &MF,
- BlockWeightMap &OriBlockWeights,
- BlockWeightMap &BlockWeights,
- EdgeWeightMap &EdgeWeights,
+ MachineFunction &MF, BlockWeightMap &OriBlockWeights,
+ BlockWeightMap &BlockWeights, EdgeWeightMap &EdgeWeights,
SmallVector<MachineBasicBlock *, 4> &HotBBs) {
if (!PropellerMatchInfer) {
for (auto MBB : HotBBs) {
@@ -126,7 +132,7 @@ void HotMachineBasicBlockInfoGenerator::generateHotBBsforFunction(
}
return;
}
-
+
if (MF.size() <= 2) {
for (auto &MBB : MF) {
if (MBB.isEntryBlock() || BlockWeights[&MBB] > 0) {
@@ -153,15 +159,17 @@ void HotMachineBasicBlockInfoGenerator::generateHotBBsforFunction(
BlockCounts[MBB.getNumber()] = BlockWeights[&MBB];
OrigOrder.push_back(&MBB);
}
-
+
// Init the edge count.
for (auto &MBB : MF) {
for (auto *Succ : MBB.successors()) {
auto EdgeWeight = EdgeWeights[std::make_pair(&MBB, Succ)];
- JumpCounts.push_back({static_cast<uint64_t>(MBB.getNumber()), static_cast<uint64_t>(Succ->getNumber()), EdgeWeight});
+ JumpCounts.push_back({static_cast<uint64_t>(MBB.getNumber()),
+ static_cast<uint64_t>(Succ->getNumber()),
+ EdgeWeight});
}
}
-
+
// Run the layout algorithm
auto Result = computeExtTspLayout(BlockSizes, BlockCounts, JumpCounts);
for (uint64_t R : Result) {
@@ -171,10 +179,11 @@ void HotMachineBasicBlockInfoGenerator::generateHotBBsforFunction(
}
}
-bool HotMachineBasicBlockInfoGenerator::runOnMachineFunction(MachineFunction &MF) {
- auto [FindFlag, HotMBBInfos] =
- getAnalysis<FuncHotBBHashesProfileReader>()
- .getHotBBInfosForFunction(MF.getName());
+bool HotMachineBasicBlockInfoGenerator::runOnMachineFunction(
+ MachineFunction &MF) {
+ auto [FindFlag, HotMBBInfos] =
+ getAnalysis<FuncHotBBHashesProfileReader>().getHotBBInfosForFunction(
+ MF.getName());
if (!FindFlag) {
return false;
}
@@ -183,8 +192,9 @@ bool HotMachineBasicBlockInfoGenerator::runOnMachineFunction(MachineFunction &MF
SmallVector<MachineBasicBlock *, 4> HotBBs;
matchHotBBsByHashes(MF, HotMBBInfos, MBBToFreq, Successors, HotBBs);
- // If the ratio of the number of MBBs in matching to the total number of MBBs in the
- // function is less than the threshold value, the processing should be abandoned.
+ // If the ratio of the number of MBBs in matching to the total number of MBBs
+ // in the function is less than the threshold value, the processing should be
+ // abandoned.
if (static_cast<float>(HotBBs.size()) / MF.size() < PropellerInferThreshold) {
return false;
}
diff --git a/llvm/lib/CodeGen/MachineBlockHashInfo.cpp b/llvm/lib/CodeGen/MachineBlockHashInfo.cpp
index 1bf5466fa..17dec6531 100644
--- a/llvm/lib/CodeGen/MachineBlockHashInfo.cpp
+++ b/llvm/lib/CodeGen/MachineBlockHashInfo.cpp
@@ -1,13 +1,15 @@
#include "llvm/CodeGen/MachineBlockHashInfo.h"
#include "llvm/CodeGen/Passes.h"
-#include "llvm/Target/TargetMachine.h"
#include "llvm/InitializePasses.h"
+#include "llvm/Target/TargetMachine.h"
using namespace llvm;
-using OperandHashFuncTy = function_ref<uint64_t(uint64_t &, const MachineOperand &)>;
+using OperandHashFuncTy =
+ function_ref<uint64_t(uint64_t &, const MachineOperand &)>;
-uint64_t hashBlock(const MachineBasicBlock &MBB, OperandHashFuncTy OperandHashFunc) {
+uint64_t hashBlock(const MachineBasicBlock &MBB,
+ OperandHashFuncTy OperandHashFunc) {
uint64_t Hash = 0;
for (const MachineInstr &MI : MBB) {
if (MI.isPseudo())
@@ -37,7 +39,7 @@ uint64_t hashInstOperand(uint64_t &Hash, const MachineOperand &Operand) {
}
INITIALIZE_PASS(MachineBlockHashInfo, "machine-block-hash",
- "Machine Block Hash Analysis", true, true)
+ "Machine Block Hash Analysis", true, true)
char MachineBlockHashInfo::ID = 0;
@@ -61,7 +63,8 @@ bool MachineBlockHashInfo::runOnMachineFunction(MachineFunction &F) {
BlendedHash.Offset = Offset;
Offset += MBB.size();
// Hashing opcodes
- uint64_t OpcodeHash = hashBlock(MBB, [](uint64_t &Hash, const MachineOperand &Op) { return Hash; });
+ uint64_t OpcodeHash = hashBlock(
+ MBB, [](uint64_t &Hash, const MachineOperand &Op) { return Hash; });
OpcodeHashes[&MBB] = OpcodeHash;
BlendedHash.OpcodeHash = hash_64_to_16(OpcodeHash);
// Hash complete instructions
diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp
index 23ac0475d..89bfc09f6 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -1276,7 +1276,8 @@ void TargetPassConfig::addMachinePasses() {
auto PGOOpt = TM->getPGOOption();
bool HavePropellerProfile = PGOOpt && !PGOOpt->PropellerProfileFile.empty();
if (HavePropellerProfile) {
- addPass(llvm::createFuncHotBBHashesProfileReaderPass((*PGOOpt).PropellerProfileFile));
+ addPass(llvm::createFuncHotBBHashesProfileReaderPass(
+ (*PGOOpt).PropellerProfileFile));
}
// We run the BasicBlockSections pass if either we need BB sections or BB
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index f6d00c0db..823b304ab 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -246,29 +246,32 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
std::optional<PGOOptions> PGOOpt;
if (!Conf.SampleProfile.empty())
PGOOpt = PGOOptions(Conf.SampleProfile, "", Conf.ProfileRemapping,
- /*MemoryProfile=*/"", Conf.PropellerProfile,
- FS, PGOOptions::SampleUse, PGOOptions::NoCSAction,
+ /*MemoryProfile=*/"", Conf.PropellerProfile, FS,
+ PGOOptions::SampleUse, PGOOptions::NoCSAction,
PGOOptions::ColdFuncOpt::Default, true);
else if (Conf.RunCSIRInstr) {
- PGOOpt = PGOOptions("", Conf.CSIRProfile, Conf.ProfileRemapping,
- /*MemoryProfile=*/"", Conf.PropellerProfile,
- FS, PGOOptions::IRUse, PGOOptions::CSIRInstr,
- PGOOptions::ColdFuncOpt::Default, Conf.AddFSDiscriminator);
+ PGOOpt =
+ PGOOptions("", Conf.CSIRProfile, Conf.ProfileRemapping,
+ /*MemoryProfile=*/"", Conf.PropellerProfile, FS,
+ PGOOptions::IRUse, PGOOptions::CSIRInstr,
+ PGOOptions::ColdFuncOpt::Default, Conf.AddFSDiscriminator);
} else if (!Conf.CSIRProfile.empty()) {
- PGOOpt = PGOOptions(Conf.CSIRProfile, "", Conf.ProfileRemapping,
- /*MemoryProfile=*/"", Conf.PropellerProfile,
- FS, PGOOptions::IRUse, PGOOptions::CSIRUse,
- PGOOptions::ColdFuncOpt::Default, Conf.AddFSDiscriminator);
+ PGOOpt =
+ PGOOptions(Conf.CSIRProfile, "", Conf.ProfileRemapping,
+ /*MemoryProfile=*/"", Conf.PropellerProfile, FS,
+ PGOOptions::IRUse, PGOOptions::CSIRUse,
+ PGOOptions::ColdFuncOpt::Default, Conf.AddFSDiscriminator);
NoPGOWarnMismatch = !Conf.PGOWarnMismatch;
} else if (!Conf.PropellerProfile.empty()) {
- PGOOpt = PGOOptions("", "", Conf.ProfileRemapping,
- /*MemoryProfile=*/"", Conf.PropellerProfile,
- FS, PGOOptions::NoAction, PGOOptions::NoCSAction,
- PGOOptions::ColdFuncOpt::Default, Conf.AddFSDiscriminator);
+ PGOOpt =
+ PGOOptions("", "", Conf.ProfileRemapping,
+ /*MemoryProfile=*/"", Conf.PropellerProfile, FS,
+ PGOOptions::NoAction, PGOOptions::NoCSAction,
+ PGOOptions::ColdFuncOpt::Default, Conf.AddFSDiscriminator);
} else if (Conf.AddFSDiscriminator) {
- PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"",
- /*PropellerProfile=*/"", nullptr,
- PGOOptions::NoAction, PGOOptions::NoCSAction,
+ PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"",
+ /*PropellerProfile=*/"", nullptr, PGOOptions::NoAction,
+ PGOOptions::NoCSAction,
PGOOptions::ColdFuncOpt::Default, true);
}
TM->setPGOOption(PGOOpt);
diff --git a/llvm/lib/Support/PGOOptions.cpp b/llvm/lib/Support/PGOOptions.cpp
index 040b1b18e..16839cfdd 100644
--- a/llvm/lib/Support/PGOOptions.cpp
+++ b/llvm/lib/Support/PGOOptions.cpp
@@ -13,15 +13,14 @@ using namespace llvm;
PGOOptions::PGOOptions(std::string ProfileFile, std::string CSProfileGenFile,
std::string ProfileRemappingFile,
- std::string MemoryProfile,
- std::string PropellerProfile,
+ std::string MemoryProfile, std::string PropellerProfile,
IntrusiveRefCntPtr<vfs::FileSystem> FS, PGOAction Action,
CSPGOAction CSAction, ColdFuncOpt ColdType,
bool DebugInfoForProfiling, bool PseudoProbeForProfiling,
bool AtomicCounterUpdate)
: ProfileFile(ProfileFile), CSProfileGenFile(CSProfileGenFile),
ProfileRemappingFile(ProfileRemappingFile), MemoryProfile(MemoryProfile),
- PropellerProfileFile(PropellerProfile), Action(Action),
+ PropellerProfileFile(PropellerProfile), Action(Action),
CSAction(CSAction), ColdOptType(ColdType),
DebugInfoForProfiling(DebugInfoForProfiling ||
(Action == SampleUse && !PseudoProbeForProfiling)),
@@ -47,12 +46,13 @@ PGOOptions::PGOOptions(std::string ProfileFile, std::string CSProfileGenFile,
// If neither Action nor CSAction nor MemoryProfile are set,
// DebugInfoForProfiling or PseudoProbeForProfiling needs to be true.
assert(this->Action != NoAction || this->CSAction != NoCSAction ||
- !this->MemoryProfile.empty() || !this->PropellerProfileFile.empty() ||
+ !this->MemoryProfile.empty() || !this->PropellerProfileFile.empty() ||
this->DebugInfoForProfiling || this->PseudoProbeForProfiling);
// If we need to use the profile, the VFS cannot be nullptr.
assert(this->FS || !(this->Action == IRUse || this->CSAction == CSIRUse ||
- !this->MemoryProfile.empty() || !this->PropellerProfileFile.empty()));
+ !this->MemoryProfile.empty() ||
+ !this->PropellerProfileFile.empty()));
}
PGOOptions::PGOOptions(const PGOOptions &) = default;
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 67ab08e0f..ac7f5d35a 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -189,7 +189,8 @@ static cl::opt<std::string>
static cl::opt<std::string>
PropellerProfileFile("propeller-profile-file",
- cl::desc("Path to the propeller profile."), cl::Hidden);
+ cl::desc("Path to the propeller profile."),
+ cl::Hidden);
static cl::opt<CSPGOKind> CSPGOKindFlag(
"cspgo-kind", cl::init(NoCSPGO), cl::Hidden,
@@ -365,28 +366,27 @@ bool llvm::runPassPipeline(
std::optional<PGOOptions> P;
switch (PGOKindFlag) {
case InstrGen:
- P = PGOOptions(ProfileFile, "", "", MemoryProfileFile,
- PropellerProfileFile, FS,
- PGOOptions::IRInstr, PGOOptions::NoCSAction,
+ P = PGOOptions(ProfileFile, "", "", MemoryProfileFile, PropellerProfileFile,
+ FS, PGOOptions::IRInstr, PGOOptions::NoCSAction,
PGOColdFuncAttr);
break;
case InstrUse:
- P = PGOOptions(ProfileFile, "", ProfileRemappingFile,
- MemoryProfileFile, PropellerProfileFile, FS,
- PGOOptions::IRUse, PGOOptions::NoCSAction, PGOColdFuncAttr);
+ P = PGOOptions(ProfileFile, "", ProfileRemappingFile, MemoryProfileFile,
+ PropellerProfileFile, FS, PGOOptions::IRUse,
+ PGOOptions::NoCSAction, PGOColdFuncAttr);
break;
case SampleUse:
- P = PGOOptions(ProfileFile, "", ProfileRemappingFile,
- MemoryProfileFile, PropellerProfileFile, FS,
- PGOOptions::SampleUse, PGOOptions::NoCSAction, PGOColdFuncAttr);
+ P = PGOOptions(ProfileFile, "", ProfileRemappingFile, MemoryProfileFile,
+ PropellerProfileFile, FS, PGOOptions::SampleUse,
+ PGOOptions::NoCSAction, PGOColdFuncAttr);
break;
case NoPGO:
if (DebugInfoForProfiling || PseudoProbeForProfiling ||
!MemoryProfileFile.empty())
- P = PGOOptions("", "", "", MemoryProfileFile,
- PropellerProfileFile, FS, PGOOptions::NoAction,
- PGOOptions::NoCSAction, PGOColdFuncAttr,
- DebugInfoForProfiling, PseudoProbeForProfiling);
+ P = PGOOptions("", "", "", MemoryProfileFile, PropellerProfileFile, FS,
+ PGOOptions::NoAction, PGOOptions::NoCSAction,
+ PGOColdFuncAttr, DebugInfoForProfiling,
+ PseudoProbeForProfiling);
else
P = std::nullopt;
}
@@ -406,8 +406,8 @@ bool llvm::runPassPipeline(
P->CSProfileGenFile = CSProfileGenFile;
} else
P = PGOOptions("", CSProfileGenFile, ProfileRemappingFile,
- /*MemoryProfile=*/"", /*PropellerProfile=*/"",
- FS, PGOOptions::NoAction, PGOOptions::CSIRInstr);
+ /*MemoryProfile=*/"", /*PropellerProfile=*/"", FS,
+ PGOOptions::NoAction, PGOOptions::CSIRInstr);
} else /* CSPGOKindFlag == CSInstrUse */ {
if (!P) {
errs() << "CSInstrUse needs to be together with InstrUse";
diff --git a/llvm/unittests/Object/ELFObjectFileTest.cpp b/llvm/unittests/Object/ELFObjectFileTest.cpp
index fa5611ed4..54bb40bb4 100644
--- a/llvm/unittests/Object/ELFObjectFileTest.cpp
+++ b/llvm/unittests/Object/ELFObjectFileTest.cpp
@@ -1183,10 +1183,11 @@ Sections:
{{0x22222, {{2, 0x0, 0x2, {false, false, true, false, false}, 0x2}}}}};
PGOAnalysisMap P2 = {
{}, {{BlockFrequency(343), {}}}, {false, true, false, false, false}};
- BBAddrMap E3 = {{{0x33333,
- {{0, 0x0, 0x3, {false, true, true, false, false}, 0x3},
- {1, 0x3, 0x3, {false, false, true, false, false}, 0x4},
- {2, 0x6, 0x3, {false, false, false, false, false}, 0x5}}}}};
+ BBAddrMap E3 = {
+ {{0x33333,
+ {{0, 0x0, 0x3, {false, true, true, false, false}, 0x3},
+ {1, 0x3, 0x3, {false, false, true, false, false}, 0x4},
+ {2, 0x6, 0x3, {false, false, false, false, false}, 0x5}}}}};
PGOAnalysisMap P3 = {{},
{{{},
{{1, BranchProbability::getRaw(0x1111'1111)},
@@ -1194,11 +1195,12 @@ Sections:
{{}, {{2, BranchProbability::getRaw(0xffff'ffff)}}},
{{}, {}}},
{false, false, true, false, false}};
- BBAddrMap E4 = {{{0x44444,
- {{0, 0x0, 0x4, {false, false, false, true, true}, 0x6},
- {1, 0x4, 0x4, {false, false, false, false, false}, 0x7},
- {2, 0x8, 0x4, {false, false, false, false, false}, 0x8},
- {3, 0xc, 0x4, {false, false, false, false, false}, 0x9}}}}};
+ BBAddrMap E4 = {
+ {{0x44444,
+ {{0, 0x0, 0x4, {false, false, false, true, true}, 0x6},
+ {1, 0x4, 0x4, {false, false, false, false, false}, 0x7},
+ {2, 0x8, 0x4, {false, false, false, false, false}, 0x8},
+ {3, 0xc, 0x4, {false, false, false, false, false}, 0x9}}}}};
PGOAnalysisMap P4 = {
1000,
{{BlockFrequency(1000),
``````````
</details>
https://github.com/llvm/llvm-project/pull/139008
More information about the cfe-commits
mailing list