aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp52
1 files changed, 42 insertions, 10 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp b/contrib/llvm-project/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
index 15b6f63e8632..79e42d9304df 100644
--- a/contrib/llvm-project/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
+++ b/contrib/llvm-project/llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp
@@ -30,8 +30,9 @@
using namespace llvm;
-char BasicBlockSectionsProfileReader::ID = 0;
-INITIALIZE_PASS(BasicBlockSectionsProfileReader, "bbsections-profile-reader",
+char BasicBlockSectionsProfileReaderWrapperPass::ID = 0;
+INITIALIZE_PASS(BasicBlockSectionsProfileReaderWrapperPass,
+ "bbsections-profile-reader",
"Reads and parses a basic block sections profile.", false,
false)
@@ -395,11 +396,11 @@ Error BasicBlockSectionsProfileReader::ReadProfile() {
}
}
-bool BasicBlockSectionsProfileReader::doInitialization(Module &M) {
- if (!MBuf)
+bool BasicBlockSectionsProfileReaderWrapperPass::doInitialization(Module &M) {
+ if (!BBSPR.MBuf)
return false;
// Get the function name to debug info filename mapping.
- FunctionNameToDIFilename.clear();
+ BBSPR.FunctionNameToDIFilename.clear();
for (const Function &F : M) {
SmallString<128> DIFilename;
if (F.isDeclaration())
@@ -411,15 +412,46 @@ bool BasicBlockSectionsProfileReader::doInitialization(Module &M) {
DIFilename = sys::path::remove_leading_dotslash(CU->getFilename());
}
[[maybe_unused]] bool inserted =
- FunctionNameToDIFilename.try_emplace(F.getName(), DIFilename).second;
+ BBSPR.FunctionNameToDIFilename.try_emplace(F.getName(), DIFilename)
+ .second;
assert(inserted);
}
- if (auto Err = ReadProfile())
+ if (auto Err = BBSPR.ReadProfile())
report_fatal_error(std::move(Err));
return false;
}
-ImmutablePass *
-llvm::createBasicBlockSectionsProfileReaderPass(const MemoryBuffer *Buf) {
- return new BasicBlockSectionsProfileReader(Buf);
+AnalysisKey BasicBlockSectionsProfileReaderAnalysis::Key;
+
+BasicBlockSectionsProfileReader
+BasicBlockSectionsProfileReaderAnalysis::run(Function &F,
+ FunctionAnalysisManager &AM) {
+ return BasicBlockSectionsProfileReader(TM->getBBSectionsFuncListBuf());
+}
+
+bool BasicBlockSectionsProfileReaderWrapperPass::isFunctionHot(
+ StringRef FuncName) const {
+ return BBSPR.isFunctionHot(FuncName);
+}
+
+std::pair<bool, SmallVector<BBClusterInfo>>
+BasicBlockSectionsProfileReaderWrapperPass::getClusterInfoForFunction(
+ StringRef FuncName) const {
+ return BBSPR.getClusterInfoForFunction(FuncName);
+}
+
+SmallVector<SmallVector<unsigned>>
+BasicBlockSectionsProfileReaderWrapperPass::getClonePathsForFunction(
+ StringRef FuncName) const {
+ return BBSPR.getClonePathsForFunction(FuncName);
+}
+
+BasicBlockSectionsProfileReader &
+BasicBlockSectionsProfileReaderWrapperPass::getBBSPR() {
+ return BBSPR;
+}
+
+ImmutablePass *llvm::createBasicBlockSectionsProfileReaderWrapperPass(
+ const MemoryBuffer *Buf) {
+ return new BasicBlockSectionsProfileReaderWrapperPass(Buf);
}