LLVM  17.0.0git
BasicBlockSections.cpp
Go to the documentation of this file.
1 //===-- BasicBlockSections.cpp ---=========--------------------------------===//
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 //
9 // BasicBlockSections implementation.
10 //
11 // The purpose of this pass is to assign sections to basic blocks when
12 // -fbasic-block-sections= option is used. Further, with profile information
13 // only the subset of basic blocks with profiles are placed in separate sections
14 // and the rest are grouped in a cold section. The exception handling blocks are
15 // treated specially to ensure they are all in one seciton.
16 //
17 // Basic Block Sections
18 // ====================
19 //
20 // With option, -fbasic-block-sections=list, every function may be split into
21 // clusters of basic blocks. Every cluster will be emitted into a separate
22 // section with its basic blocks sequenced in the given order. To get the
23 // optimized performance, the clusters must form an optimal BB layout for the
24 // function. We insert a symbol at the beginning of every cluster's section to
25 // allow the linker to reorder the sections in any arbitrary sequence. A global
26 // order of these sections would encapsulate the function layout.
27 // For example, consider the following clusters for a function foo (consisting
28 // of 6 basic blocks 0, 1, ..., 5).
29 //
30 // 0 2
31 // 1 3 5
32 //
33 // * Basic blocks 0 and 2 are placed in one section with symbol `foo`
34 // referencing the beginning of this section.
35 // * Basic blocks 1, 3, 5 are placed in a separate section. A new symbol
36 // `foo.__part.1` will reference the beginning of this section.
37 // * Basic block 4 (note that it is not referenced in the list) is placed in
38 // one section, and a new symbol `foo.cold` will point to it.
39 //
40 // There are a couple of challenges to be addressed:
41 //
42 // 1. The last basic block of every cluster should not have any implicit
43 // fallthrough to its next basic block, as it can be reordered by the linker.
44 // The compiler should make these fallthroughs explicit by adding
45 // unconditional jumps..
46 //
47 // 2. All inter-cluster branch targets would now need to be resolved by the
48 // linker as they cannot be calculated during compile time. This is done
49 // using static relocations. Further, the compiler tries to use short branch
50 // instructions on some ISAs for small branch offsets. This is not possible
51 // for inter-cluster branches as the offset is not determined at compile
52 // time, and therefore, long branch instructions have to be used for those.
53 //
54 // 3. Debug Information (DebugInfo) and Call Frame Information (CFI) emission
55 // needs special handling with basic block sections. DebugInfo needs to be
56 // emitted with more relocations as basic block sections can break a
57 // function into potentially several disjoint pieces, and CFI needs to be
58 // emitted per cluster. This also bloats the object file and binary sizes.
59 //
60 // Basic Block Labels
61 // ==================
62 //
63 // With -fbasic-block-sections=labels, we encode the offsets of BB addresses of
64 // every function into the .llvm_bb_addr_map section. Along with the function
65 // symbols, this allows for mapping of virtual addresses in PMU profiles back to
66 // the corresponding basic blocks. This logic is implemented in AsmPrinter. This
67 // pass only assigns the BBSectionType of every function to ``labels``.
68 //
69 //===----------------------------------------------------------------------===//
70 
71 #include "llvm/ADT/SmallVector.h"
72 #include "llvm/ADT/StringRef.h"
77 #include "llvm/CodeGen/Passes.h"
79 #include "llvm/InitializePasses.h"
81 #include <optional>
82 
83 using namespace llvm;
84 
85 // Placing the cold clusters in a separate section mitigates against poor
86 // profiles and allows optimizations such as hugepage mapping to be applied at a
87 // section granularity. Defaults to ".text.split." which is recognized by lld
88 // via the `-z keep-text-section-prefix` flag.
90  "bbsections-cold-text-prefix",
91  cl::desc("The text prefix to use for cold basic block clusters"),
92  cl::init(".text.split."), cl::Hidden);
93 
95  "bbsections-detect-source-drift",
96  cl::desc("This checks if there is a fdo instr. profile hash "
97  "mismatch for this function"),
98  cl::init(true), cl::Hidden);
99 
100 namespace {
101 
102 class BasicBlockSections : public MachineFunctionPass {
103 public:
104  static char ID;
105 
106  BasicBlockSectionsProfileReader *BBSectionsProfileReader = nullptr;
107 
108  BasicBlockSections() : MachineFunctionPass(ID) {
110  }
111 
112  StringRef getPassName() const override {
113  return "Basic Block Sections Analysis";
114  }
115 
116  void getAnalysisUsage(AnalysisUsage &AU) const override;
117 
118  /// Identify basic blocks that need separate sections and prepare to emit them
119  /// accordingly.
120  bool runOnMachineFunction(MachineFunction &MF) override;
121 };
122 
123 } // end anonymous namespace
124 
125 char BasicBlockSections::ID = 0;
126 INITIALIZE_PASS(BasicBlockSections, "bbsections-prepare",
127  "Prepares for basic block sections, by splitting functions "
128  "into clusters of basic blocks.",
129  false, false)
130 
131 // This function updates and optimizes the branching instructions of every basic
132 // block in a given function to account for changes in the layout.
133 static void
134 updateBranches(MachineFunction &MF,
136  const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
138  for (auto &MBB : MF) {
139  auto NextMBBI = std::next(MBB.getIterator());
140  auto *FTMBB = PreLayoutFallThroughs[MBB.getNumber()];
141  // If this block had a fallthrough before we need an explicit unconditional
142  // branch to that block if either
143  // 1- the block ends a section, which means its next block may be
144  // reorderd by the linker, or
145  // 2- the fallthrough block is not adjacent to the block in the new
146  // order.
147  if (FTMBB && (MBB.isEndSection() || &*NextMBBI != FTMBB))
148  TII->insertUnconditionalBranch(MBB, FTMBB, MBB.findBranchDebugLoc());
149 
150  // We do not optimize branches for machine basic blocks ending sections, as
151  // their adjacent block might be reordered by the linker.
152  if (MBB.isEndSection())
153  continue;
154 
155  // It might be possible to optimize branches by flipping the branch
156  // condition.
157  Cond.clear();
158  MachineBasicBlock *TBB = nullptr, *FBB = nullptr; // For analyzeBranch.
159  if (TII->analyzeBranch(MBB, TBB, FBB, Cond))
160  continue;
161  MBB.updateTerminator(FTMBB);
162  }
163 }
164 
165 // This function provides the BBCluster information associated with a function.
166 // Returns true if a valid association exists and false otherwise.
168  const MachineFunction &MF,
169  BasicBlockSectionsProfileReader *BBSectionsProfileReader,
171 
172  // Find the assoicated cluster information.
173  std::pair<bool, SmallVector<BBClusterInfo, 4>> P =
174  BBSectionsProfileReader->getBBClusterInfoForFunction(MF.getName());
175  if (!P.first)
176  return false;
177 
178  if (P.second.empty()) {
179  // This indicates that sections are desired for all basic blocks of this
180  // function. We clear the BBClusterInfo vector to denote this.
181  V.clear();
182  return true;
183  }
184 
185  for (const BBClusterInfo &BBCI : P.second)
186  V[BBCI.BBID] = BBCI;
187  return true;
188 }
189 
190 // This function sorts basic blocks according to the cluster's information.
191 // All explicitly specified clusters of basic blocks will be ordered
192 // accordingly. All non-specified BBs go into a separate "Cold" section.
193 // Additionally, if exception handling landing pads end up in more than one
194 // clusters, they are moved into a single "Exception" section. Eventually,
195 // clusters are ordered in increasing order of their IDs, with the "Exception"
196 // and "Cold" succeeding all other clusters.
197 // FuncBBClusterInfo represent the cluster information for basic blocks. It
198 // maps from BBID of basic blocks to their cluster information. If this is
199 // empty, it means unique sections for all basic blocks in the function.
200 static void
202  const DenseMap<unsigned, BBClusterInfo> &FuncBBClusterInfo) {
203  assert(MF.hasBBSections() && "BB Sections is not set for function.");
204  // This variable stores the section ID of the cluster containing eh_pads (if
205  // all eh_pads are one cluster). If more than one cluster contain eh_pads, we
206  // set it equal to ExceptionSectionID.
207  std::optional<MBBSectionID> EHPadsSectionID;
208 
209  for (auto &MBB : MF) {
210  // With the 'all' option, every basic block is placed in a unique section.
211  // With the 'list' option, every basic block is placed in a section
212  // associated with its cluster, unless we want individual unique sections
213  // for every basic block in this function (if FuncBBClusterInfo is empty).
214  if (MF.getTarget().getBBSectionsType() == llvm::BasicBlockSection::All ||
215  FuncBBClusterInfo.empty()) {
216  // If unique sections are desired for all basic blocks of the function, we
217  // set every basic block's section ID equal to its original position in
218  // the layout (which is equal to its number). This ensures that basic
219  // blocks are ordered canonically.
221  } else {
222  // TODO: Replace `getBBIDOrNumber` with `getBBID` once version 1 is
223  // deprecated.
224  auto I = FuncBBClusterInfo.find(MBB.getBBIDOrNumber());
225  if (I != FuncBBClusterInfo.end()) {
226  MBB.setSectionID(I->second.ClusterID);
227  } else {
228  // BB goes into the special cold section if it is not specified in the
229  // cluster info map.
231  }
232  }
233 
234  if (MBB.isEHPad() && EHPadsSectionID != MBB.getSectionID() &&
235  EHPadsSectionID != MBBSectionID::ExceptionSectionID) {
236  // If we already have one cluster containing eh_pads, this must be updated
237  // to ExceptionSectionID. Otherwise, we set it equal to the current
238  // section ID.
239  EHPadsSectionID = EHPadsSectionID ? MBBSectionID::ExceptionSectionID
240  : MBB.getSectionID();
241  }
242  }
243 
244  // If EHPads are in more than one section, this places all of them in the
245  // special exception section.
246  if (EHPadsSectionID == MBBSectionID::ExceptionSectionID)
247  for (auto &MBB : MF)
248  if (MBB.isEHPad())
249  MBB.setSectionID(*EHPadsSectionID);
250 }
251 
254  [[maybe_unused]] const MachineBasicBlock *EntryBlock = &MF.front();
256  for (auto &MBB : MF)
258 
259  MF.sort(MBBCmp);
260  assert(&MF.front() == EntryBlock &&
261  "Entry block should not be displaced by basic block sections");
262 
263  // Set IsBeginSection and IsEndSection according to the assigned section IDs.
264  MF.assignBeginEndSections();
265 
266  // After reordering basic blocks, we must update basic block branches to
267  // insert explicit fallthrough branches when required and optimize branches
268  // when possible.
269  updateBranches(MF, PreLayoutFallThroughs);
270 }
271 
272 // If the exception section begins with a landing pad, that landing pad will
273 // assume a zero offset (relative to @LPStart) in the LSDA. However, a value of
274 // zero implies "no landing pad." This function inserts a NOP just before the EH
275 // pad label to ensure a nonzero offset.
277  for (auto &MBB : MF) {
278  if (MBB.isBeginSection() && MBB.isEHPad()) {
280  while (!MI->isEHLabel())
281  ++MI;
282  MCInst Nop = MF.getSubtarget().getInstrInfo()->getNop();
283  BuildMI(MBB, MI, DebugLoc(),
284  MF.getSubtarget().getInstrInfo()->get(Nop.getOpcode()));
285  }
286  }
287 }
288 
289 // This checks if the source of this function has drifted since this binary was
290 // profiled previously. For now, we are piggy backing on what PGO does to
291 // detect this with instrumented profiles. PGO emits an hash of the IR and
292 // checks if the hash has changed. Advanced basic block layout is usually done
293 // on top of PGO optimized binaries and hence this check works well in practice.
296  return false;
297 
298  const char MetadataName[] = "instr_prof_hash_mismatch";
299  auto *Existing = MF.getFunction().getMetadata(LLVMContext::MD_annotation);
300  if (Existing) {
301  MDTuple *Tuple = cast<MDTuple>(Existing);
302  for (const auto &N : Tuple->operands())
303  if (cast<MDString>(N.get())->getString() == MetadataName)
304  return true;
305  }
306 
307  return false;
308 }
309 
310 bool BasicBlockSections::runOnMachineFunction(MachineFunction &MF) {
311  auto BBSectionsType = MF.getTarget().getBBSectionsType();
312  assert(BBSectionsType != BasicBlockSection::None &&
313  "BB Sections not enabled!");
314 
315  // Check for source drift. If the source has changed since the profiles
316  // were obtained, optimizing basic blocks might be sub-optimal.
317  // This only applies to BasicBlockSection::List as it creates
318  // clusters of basic blocks using basic block ids. Source drift can
319  // invalidate these groupings leading to sub-optimal code generation with
320  // regards to performance.
321  if (BBSectionsType == BasicBlockSection::List &&
323  return true;
324  // Renumber blocks before sorting them. This is useful during sorting,
325  // basic blocks in the same section will retain the default order.
326  // This renumbering should also be done for basic block labels to match the
327  // profiles with the correct blocks.
328  // For LLVM_BB_ADDR_MAP versions 2 and higher, this renumbering serves
329  // the different purpose of accessing the original layout positions and
330  // finding the original fallthroughs.
331  // TODO: Change the above comment accordingly when version 1 is deprecated.
332  MF.RenumberBlocks();
333 
334  if (BBSectionsType == BasicBlockSection::Labels) {
335  MF.setBBSectionsType(BBSectionsType);
336  return true;
337  }
338 
339  BBSectionsProfileReader = &getAnalysis<BasicBlockSectionsProfileReader>();
340 
341  // Map from BBID of blocks to their cluster information.
342  DenseMap<unsigned, BBClusterInfo> FuncBBClusterInfo;
343  if (BBSectionsType == BasicBlockSection::List &&
344  !getBBClusterInfoForFunction(MF, BBSectionsProfileReader,
345  FuncBBClusterInfo))
346  return true;
347  MF.setBBSectionsType(BBSectionsType);
348  assignSections(MF, FuncBBClusterInfo);
349 
350  // We make sure that the cluster including the entry basic block precedes all
351  // other clusters.
352  auto EntryBBSectionID = MF.front().getSectionID();
353 
354  // Helper function for ordering BB sections as follows:
355  // * Entry section (section including the entry block).
356  // * Regular sections (in increasing order of their Number).
357  // ...
358  // * Exception section
359  // * Cold section
360  auto MBBSectionOrder = [EntryBBSectionID](const MBBSectionID &LHS,
361  const MBBSectionID &RHS) {
362  // We make sure that the section containing the entry block precedes all the
363  // other sections.
364  if (LHS == EntryBBSectionID || RHS == EntryBBSectionID)
365  return LHS == EntryBBSectionID;
366  return LHS.Type == RHS.Type ? LHS.Number < RHS.Number : LHS.Type < RHS.Type;
367  };
368 
369  // We sort all basic blocks to make sure the basic blocks of every cluster are
370  // contiguous and ordered accordingly. Furthermore, clusters are ordered in
371  // increasing order of their section IDs, with the exception and the
372  // cold section placed at the end of the function.
373  auto Comparator = [&](const MachineBasicBlock &X,
374  const MachineBasicBlock &Y) {
375  auto XSectionID = X.getSectionID();
376  auto YSectionID = Y.getSectionID();
377  if (XSectionID != YSectionID)
378  return MBBSectionOrder(XSectionID, YSectionID);
379  // If the two basic block are in the same section, the order is decided by
380  // their position within the section.
381  if (XSectionID.Type == MBBSectionID::SectionType::Default)
382  return FuncBBClusterInfo.lookup(X.getBBIDOrNumber()).PositionInCluster <
383  FuncBBClusterInfo.lookup(Y.getBBIDOrNumber()).PositionInCluster;
384  return X.getNumber() < Y.getNumber();
385  };
386 
387  sortBasicBlocksAndUpdateBranches(MF, Comparator);
389  return true;
390 }
391 
392 void BasicBlockSections::getAnalysisUsage(AnalysisUsage &AU) const {
393  AU.setPreservesAll();
396 }
397 
399  return new BasicBlockSections();
400 }
getBBClusterInfoForFunction
bool getBBClusterInfoForFunction(const MachineFunction &MF, BasicBlockSectionsProfileReader *BBSectionsProfileReader, DenseMap< unsigned, BBClusterInfo > &V)
Definition: BasicBlockSections.cpp:167
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:109
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::sortBasicBlocksAndUpdateBranches
void sortBasicBlocksAndUpdateBranches(MachineFunction &MF, MachineBasicBlockComparator MBBCmp)
Definition: BasicBlockSections.cpp:252
assignSections
static void assignSections(MachineFunction &MF, const DenseMap< unsigned, BBClusterInfo > &FuncBBClusterInfo)
Definition: BasicBlockSections.cpp:201
llvm::AArch64PACKey::ID
ID
Definition: AArch64BaseInfo.h:824
llvm::WebAssembly::Nop
static const unsigned Nop
Instruction opcodes emitted via means other than CodeGen.
Definition: WebAssemblyMCTargetDesc.h:134
llvm::BBSectionsColdTextPrefix
cl::opt< std::string > BBSectionsColdTextPrefix
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::lookup
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:197
StringRef.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::HexagonInstrInfo::analyzeBranch
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e....
Definition: HexagonInstrInfo.cpp:434
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
llvm::GlobalObject::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1288
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition: MachineFunctionPass.h:30
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:138
llvm::MachineFunction::getNumBlockIDs
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
Definition: MachineFunction.h:815
TargetInstrInfo.h
llvm::BBClusterInfo::BBID
unsigned BBID
Definition: BasicBlockSectionsProfileReader.h:35
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::MBBSectionID
Definition: MachineBasicBlock.h:51
llvm::BasicBlockSection::List
@ List
llvm::BasicBlockSection::None
@ None
llvm::MachineFunctionPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition: MachineFunctionPass.cpp:167
llvm::avoidZeroOffsetLandingPad
void avoidZeroOffsetLandingPad(MachineFunction &MF)
Definition: BasicBlockSections.cpp:276
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1399
llvm::MachineBasicBlock::isBeginSection
bool isBeginSection() const
Returns true if this block begins any section.
Definition: MachineBasicBlock.h:618
llvm::MachineBasicBlock::setSectionID
void setSectionID(MBBSectionID V)
Sets the section ID for this basic block.
Definition: MachineBasicBlock.h:651
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::MachineFunction::front
const MachineBasicBlock & front() const
Definition: MachineFunction.h:882
llvm::TargetInstrInfo
TargetInstrInfo - Interface to description of machine instruction set.
Definition: TargetInstrInfo.h:98
TargetMachine.h
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:24
Y
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
llvm::MDNode::operands
ArrayRef< MDOperand > operands() const
Definition: Metadata.h:1289
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::MDTuple
Tuple of metadata.
Definition: Metadata.h:1328
TBB
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
Definition: RISCVRedundantCopyElimination.cpp:76
TII
const HexagonInstrInfo * TII
Definition: HexagonCopyToCombine.cpp:125
llvm::BasicBlockSection::Labels
@ Labels
INITIALIZE_PASS
INITIALIZE_PASS(BasicBlockSections, "bbsections-prepare", "Prepares for basic block sections, by splitting functions " "into clusters of basic blocks.", false, false) static void updateBranches(MachineFunction &MF
llvm::BasicBlockSection::All
@ All
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:94
Passes.h
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::cl::opt
Definition: CommandLine.h:1410
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::clear
void clear()
Definition: DenseMap.h:110
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
BasicBlockSectionUtils.h
llvm::DenseMap
Definition: DenseMap.h:714
llvm::BBClusterInfo
Definition: BasicBlockSectionsProfileReader.h:33
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::BasicBlockSectionsProfileReader
Definition: BasicBlockSectionsProfileReader.h:44
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:445
MachineFunctionPass.h
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:150
llvm::MachineFunction::getName
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Definition: MachineFunction.cpp:582
llvm::MBBSectionID::ExceptionSectionID
const static MBBSectionID ExceptionSectionID
Definition: MachineBasicBlock.h:64
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::BBClusterInfo::PositionInCluster
unsigned PositionInCluster
Definition: BasicBlockSectionsProfileReader.h:39
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::empty
bool empty() const
Definition: DenseMap.h:98
llvm::MachineFunction
Definition: MachineFunction.h:258
llvm::MachineBasicBlock::getNumber
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
Definition: MachineBasicBlock.h:1143
Cond
SmallVector< MachineOperand, 4 > Cond
Definition: BasicBlockSections.cpp:137
llvm::MachineBasicBlock::isEHPad
bool isEHPad() const
Returns true if the block is a landing pad.
Definition: MachineBasicBlock.h:580
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::MachineBasicBlock::findBranchDebugLoc
DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
Definition: MachineBasicBlock.cpp:1436
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition: ilist_node.h:82
llvm::MachineFunction::hasBBSections
bool hasBBSections() const
Returns true if this function has basic block sections enabled.
Definition: MachineFunction.h:650
llvm::initializeBasicBlockSectionsPass
void initializeBasicBlockSectionsPass(PassRegistry &)
PreLayoutFallThroughs
const SmallVector< MachineBasicBlock * > & PreLayoutFallThroughs
Definition: BasicBlockSections.cpp:135
llvm::MachineBasicBlock::getSectionID
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
Definition: MachineBasicBlock.h:636
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
hasInstrProfHashMismatch
static bool hasInstrProfHashMismatch(MachineFunction &MF)
Definition: BasicBlockSections.cpp:294
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:638
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::MachineFunction::getTarget
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Definition: MachineFunction.h:668
llvm::MachineBasicBlock::isEndSection
bool isEndSection() const
Returns true if this block ends any section.
Definition: MachineBasicBlock.h:621
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end
iterator end()
Definition: DenseMap.h:84
llvm::MBBSectionID::ColdSectionID
const static MBBSectionID ColdSectionID
Definition: MachineBasicBlock.h:63
BBSectionsDetectSourceDrift
cl::opt< bool > BBSectionsDetectSourceDrift("bbsections-detect-source-drift", cl::desc("This checks if there is a fdo instr. profile hash " "mismatch for this function"), cl::init(true), cl::Hidden)
BasicBlockSectionsProfileReader.h
llvm::TargetStackID::Default
@ Default
Definition: TargetFrameLowering.h:28
llvm::BasicBlockSectionsProfileReader::getBBClusterInfoForFunction
std::pair< bool, SmallVector< BBClusterInfo > > getBBClusterInfoForFunction(StringRef FuncName) const
llvm::BuildMI
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Definition: MachineInstrBuilder.h:357
llvm::MachineBasicBlock::getFallThrough
MachineBasicBlock * getFallThrough(bool JumpToFallThrough=false)
Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...
Definition: MachineBasicBlock.cpp:947
SmallVector.h
llvm::MachineBasicBlock::begin
iterator begin()
Definition: MachineBasicBlock.h:309
N
#define N
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::cl::desc
Definition: CommandLine.h:411
llvm::MachineBasicBlock::updateTerminator
void updateTerminator(MachineBasicBlock *PreviousLayoutSuccessor)
Update the terminator instructions in block to account for changes to block layout which may have bee...
Definition: MachineBasicBlock.cpp:667
MachineFunction.h
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::MachineBasicBlock::getBBIDOrNumber
unsigned getBBIDOrNumber() const
Returns the BBID of the block when BBAddrMapVersion >= 2, otherwise returns MachineBasicBlock::Number...
Definition: MachineBasicBlock.cpp:1658
llvm::MachineFunction::setBBSectionsType
void setBBSectionsType(BasicBlockSection V)
Definition: MachineFunction.h:661
InitializePasses.h
llvm::createBasicBlockSectionsPass
MachineFunctionPass * createBasicBlockSectionsPass()
createBasicBlockSections Pass - This pass assigns sections to machine basic blocks and is enabled wit...
Definition: BasicBlockSections.cpp:398
llvm::MachineFunction::RenumberBlocks
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them.
Definition: MachineFunction.cpp:326
llvm::TargetMachine::getBBSectionsType
llvm::BasicBlockSection getBBSectionsType() const
If basic blocks should be emitted into their own section, corresponding to -fbasic-block-sections.
Definition: TargetMachine.h:308