aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h')
-rw-r--r--contrib/llvm-project/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h83
1 files changed, 62 insertions, 21 deletions
diff --git a/contrib/llvm-project/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h b/contrib/llvm-project/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
index dfb8d5d9f2f5..bba675f1d3eb 100644
--- a/contrib/llvm-project/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
+++ b/contrib/llvm-project/llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h
@@ -21,11 +21,14 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Target/TargetMachine.h"
+
using namespace llvm;
namespace llvm {
@@ -72,25 +75,13 @@ template <> struct DenseMapInfo<UniqueBBID> {
}
};
-class BasicBlockSectionsProfileReader : public ImmutablePass {
+class BasicBlockSectionsProfileReader {
public:
- static char ID;
-
+ friend class BasicBlockSectionsProfileReaderWrapperPass;
BasicBlockSectionsProfileReader(const MemoryBuffer *Buf)
- : ImmutablePass(ID), MBuf(Buf),
- LineIt(*Buf, /*SkipBlanks=*/true, /*CommentMarker=*/'#') {
- initializeBasicBlockSectionsProfileReaderPass(
- *PassRegistry::getPassRegistry());
- };
+ : MBuf(Buf), LineIt(*Buf, /*SkipBlanks=*/true, /*CommentMarker=*/'#'){};
- BasicBlockSectionsProfileReader() : ImmutablePass(ID) {
- initializeBasicBlockSectionsProfileReaderPass(
- *PassRegistry::getPassRegistry());
- }
-
- StringRef getPassName() const override {
- return "Basic Block Sections Profile Reader";
- }
+ BasicBlockSectionsProfileReader(){};
// Returns true if basic block sections profile exist for function \p
// FuncName.
@@ -109,10 +100,6 @@ public:
SmallVector<SmallVector<unsigned>>
getClonePathsForFunction(StringRef FuncName) const;
- // Initializes the FunctionNameToDIFilename map for the current module and
- // then reads the profile for the matching functions.
- bool doInitialization(Module &M) override;
-
private:
StringRef getAliasName(StringRef FuncName) const {
auto R = FuncAliasMap.find(FuncName);
@@ -170,7 +157,61 @@ private:
// sections profile. \p Buf is a memory buffer that contains the list of
// functions and basic block ids to selectively enable basic block sections.
ImmutablePass *
-createBasicBlockSectionsProfileReaderPass(const MemoryBuffer *Buf);
+createBasicBlockSectionsProfileReaderWrapperPass(const MemoryBuffer *Buf);
+
+/// Analysis pass providing the \c BasicBlockSectionsProfileReader.
+///
+/// Note that this pass's result cannot be invalidated, it is immutable for the
+/// life of the module.
+class BasicBlockSectionsProfileReaderAnalysis
+ : public AnalysisInfoMixin<BasicBlockSectionsProfileReaderAnalysis> {
+
+public:
+ static AnalysisKey Key;
+ typedef BasicBlockSectionsProfileReader Result;
+ BasicBlockSectionsProfileReaderAnalysis(const TargetMachine *TM) : TM(TM) {}
+
+ Result run(Function &F, FunctionAnalysisManager &AM);
+
+private:
+ const TargetMachine *TM;
+};
+
+class BasicBlockSectionsProfileReaderWrapperPass : public ImmutablePass {
+public:
+ static char ID;
+ BasicBlockSectionsProfileReader BBSPR;
+
+ BasicBlockSectionsProfileReaderWrapperPass(const MemoryBuffer *Buf)
+ : ImmutablePass(ID), BBSPR(BasicBlockSectionsProfileReader(Buf)) {
+ initializeBasicBlockSectionsProfileReaderWrapperPassPass(
+ *PassRegistry::getPassRegistry());
+ };
+
+ BasicBlockSectionsProfileReaderWrapperPass()
+ : ImmutablePass(ID), BBSPR(BasicBlockSectionsProfileReader()) {
+ initializeBasicBlockSectionsProfileReaderWrapperPassPass(
+ *PassRegistry::getPassRegistry());
+ }
+
+ StringRef getPassName() const override {
+ return "Basic Block Sections Profile Reader";
+ }
+
+ bool isFunctionHot(StringRef FuncName) const;
+
+ std::pair<bool, SmallVector<BBClusterInfo>>
+ getClusterInfoForFunction(StringRef FuncName) const;
+
+ SmallVector<SmallVector<unsigned>>
+ getClonePathsForFunction(StringRef FuncName) const;
+
+ // Initializes the FunctionNameToDIFilename map for the current module and
+ // then reads the profile for the matching functions.
+ bool doInitialization(Module &M) override;
+
+ BasicBlockSectionsProfileReader &getBBSPR();
+};
} // namespace llvm
#endif // LLVM_CODEGEN_BASICBLOCKSECTIONSPROFILEREADER_H