LLVM 22.0.0git
SpeculateAnalyses.h
Go to the documentation of this file.
1//===-- SpeculateAnalyses.h --*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9/// Contains the Analyses and Result Interpretation to select likely functions
10/// to Speculatively compile before they are called. [Purely Experimentation]
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_SPECULATEANALYSES_H
14#define LLVM_EXECUTIONENGINE_ORC_SPECULATEANALYSES_H
15
20
21namespace llvm {
22
23namespace orc {
24
25// Provides common code.
27protected:
29 LLVM_ABI bool isStraightLine(const Function &F);
30
31public:
32 using ResultTy = std::optional<DenseMap<StringRef, DenseSet<StringRef>>>;
33};
34
35// Direct calls in high frequency basic blocks are extracted.
37 size_t numBBToGet(size_t);
38
39public:
40 // Find likely next executables based on IR Block Frequency
42};
43
44// This Query generates a sequence of basic blocks which follows the order of
45// execution.
46// A handful of BB with higher block frequencies are taken, then path to entry
47// and end BB are discovered by traversing up & down the CFG.
49 struct WalkDirection {
50 bool Upward = true, Downward = true;
51 // the block associated contain a call
52 bool CallerBlock = false;
53 };
54
55public:
62
63private:
64 std::size_t getHottestBlocks(std::size_t TotalBlocks);
65 BlockListTy rearrangeBB(const Function &, const BlockListTy &);
66 BlockListTy queryCFG(Function &, const BlockListTy &);
67 void traverseToEntryBlock(const BasicBlock *, const BlockListTy &,
68 const BackEdgesInfoTy &,
71 void traverseToExitBlock(const BasicBlock *, const BlockListTy &,
72 const BackEdgesInfoTy &,
75
76public:
78};
79
80} // namespace orc
81} // namespace llvm
82
83#endif // LLVM_EXECUTIONENGINE_ORC_SPECULATEANALYSES_H
#define LLVM_ABI
Definition Compiler.h:213
#define F(x, y, z)
Definition MD5.cpp:55
LLVM Basic Block Representation.
Definition BasicBlock.h:62
Analysis providing branch probability information.
Implements a dense probed hash-table based set.
Definition DenseSet.h:261
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM_ABI ResultTy operator()(Function &F)
LLVM_ABI ResultTy operator()(Function &F)
SmallVector< std::pair< const BasicBlock *, uint64_t >, 8 > BlockFreqInfoTy
DenseMap< const BasicBlock *, WalkDirection > VisitedBlocksInfoTy
SmallVector< const BasicBlock *, 8 > BlockListTy
SmallVector< std::pair< const BasicBlock *, const BasicBlock * >, 8 > BackEdgesInfoTy
std::optional< DenseMap< StringRef, DenseSet< StringRef > > > ResultTy
LLVM_ABI bool isStraightLine(const Function &F)
LLVM_ABI void findCalles(const BasicBlock *, DenseSet< StringRef > &)
This is an optimization pass for GlobalISel generic memory operations.