LLVM  14.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 
19 
20 #include <vector>
21 
22 namespace llvm {
23 
24 namespace orc {
25 
26 // Provides common code.
28 protected:
29  void findCalles(const BasicBlock *, DenseSet<StringRef> &);
30  bool isStraightLine(const Function &F);
31 
32 public:
34 };
35 
36 // Direct calls in high frequency basic blocks are extracted.
38  size_t numBBToGet(size_t);
39 
40 public:
41  // Find likely next executables based on IR Block Frequency
43 };
44 
45 // This Query generates a sequence of basic blocks which follows the order of
46 // execution.
47 // A handful of BB with higher block frequencies are taken, then path to entry
48 // and end BB are discovered by traversing up & down the CFG.
50  struct WalkDirection {
51  bool Upward = true, Downward = true;
52  // the block associated contain a call
53  bool CallerBlock = false;
54  };
55 
56 public:
59  using BackEdgesInfoTy =
61  using BlockFreqInfoTy =
63 
64 private:
65  std::size_t getHottestBlocks(std::size_t TotalBlocks);
66  BlockListTy rearrangeBB(const Function &, const BlockListTy &);
67  BlockListTy queryCFG(Function &, const BlockListTy &);
68  void traverseToEntryBlock(const BasicBlock *, const BlockListTy &,
69  const BackEdgesInfoTy &,
70  const BranchProbabilityInfo *,
72  void traverseToExitBlock(const BasicBlock *, const BlockListTy &,
73  const BackEdgesInfoTy &,
74  const BranchProbabilityInfo *,
76 
77 public:
79 };
80 
81 } // namespace orc
82 } // namespace llvm
83 
84 #endif // LLVM_EXECUTIONENGINE_ORC_SPECULATEANALYSES_H
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
Speculation.h
llvm::Function
Definition: Function.h:62
llvm::orc::BlockFreqQuery::operator()
ResultTy operator()(Function &F)
Definition: SpeculateAnalyses.cpp:88
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::orc::SequenceBBQuery
Definition: SpeculateAnalyses.h:49
llvm::Optional
Definition: APInt.h:33
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::orc::SpeculateQuery::findCalles
void findCalles(const BasicBlock *, DenseSet< StringRef > &)
Definition: SpeculateAnalyses.cpp:52
llvm::BranchProbabilityInfo
Analysis providing branch probability information.
Definition: BranchProbabilityInfo.h:115
llvm::orc::BlockFreqQuery
Definition: SpeculateAnalyses.h:37
llvm::orc::SpeculateQuery::isStraightLine
bool isStraightLine(const Function &F)
Definition: SpeculateAnalyses.cpp:69
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
BranchProbabilityInfo.h
llvm::DenseMap
Definition: DenseMap.h:714
llvm::orc::SpeculateQuery
Definition: SpeculateAnalyses.h:27
llvm::orc::SequenceBBQuery::operator()
ResultTy operator()(Function &F)
Definition: SpeculateAnalyses.cpp:282
Core.h