Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.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 Address Map
61// ==================
62//
63// With -fbasic-block-address-map, we emit 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"
73#include "llvm/CodeGen/BasicBlockSectionUtils.h"
74#include "llvm/CodeGen/BasicBlockSectionsProfileReader.h"
75#include "llvm/CodeGen/MachineDominators.h"
76#include "llvm/CodeGen/MachineFunction.h"
77#include "llvm/CodeGen/MachineFunctionPass.h"
78#include "llvm/CodeGen/MachinePostDominators.h"
79#include "llvm/CodeGen/Passes.h"
80#include "llvm/CodeGen/TargetInstrInfo.h"
81#include "llvm/InitializePasses.h"
82#include "llvm/Target/TargetMachine.h"
83#include <optional>
84
85using namespacellvm;
86
87// Placing the cold clusters in a separate section mitigates against poor
88// profiles and allows optimizations such as hugepage mapping to be applied at a
89// section granularity. Defaults to ".text.split." which is recognized by lld
90// via the `-z keep-text-section-prefix` flag.
91cl::opt<std::string>llvm::BBSectionsColdTextPrefix(
92"bbsections-cold-text-prefix",
93cl::desc("The text prefix to use for cold basic block clusters"),
94cl::init(".text.split."),cl::Hidden);
95
96staticcl::opt<bool>BBSectionsDetectSourceDrift(
97"bbsections-detect-source-drift",
98cl::desc("This checks if there is a fdo instr. profile hash "
99"mismatch for this function"),
100cl::init(true),cl::Hidden);
101
102namespace{
103
104classBasicBlockSections :publicMachineFunctionPass {
105public:
106staticcharID;
107
108BasicBlockSectionsProfileReaderWrapperPass *BBSectionsProfileReader =nullptr;
109
110 BasicBlockSections() :MachineFunctionPass(ID) {
111initializeBasicBlockSectionsPass(*PassRegistry::getPassRegistry());
112 }
113
114StringRefgetPassName() const override{
115return"Basic Block Sections Analysis";
116 }
117
118voidgetAnalysisUsage(AnalysisUsage &AU)const override;
119
120 /// Identify basic blocks that need separate sections and prepare to emit them
121 /// accordingly.
122boolrunOnMachineFunction(MachineFunction &MF)override;
123
124private:
125bool handleBBSections(MachineFunction &MF);
126bool handleBBAddrMap(MachineFunction &MF);
127};
128
129}// end anonymous namespace
130
131char BasicBlockSections::ID = 0;
132INITIALIZE_PASS_BEGIN(
133 BasicBlockSections,"bbsections-prepare",
134"Prepares for basic block sections, by splitting functions "
135"into clusters of basic blocks.",
136false,false)
137INITIALIZE_PASS_DEPENDENCY(BasicBlockSectionsProfileReaderWrapperPass)
138INITIALIZE_PASS_END(BasicBlockSections, "bbsections-prepare",
139 "Preparesfor basicblocksections, by splittingfunctions "
140 "into clusters of basicblocks.",
141false,false)
142
143// This function updates and optimizes the branching instructions of every basic
144// block in a given function to account for changes in the layout.
145staticvoid
146updateBranches(MachineFunction &MF,
147constSmallVector<MachineBasicBlock *> &PreLayoutFallThroughs) {
148constTargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
149SmallVector<MachineOperand, 4>Cond;
150for (auto &MBB : MF) {
151auto NextMBBI = std::next(MBB.getIterator());
152auto *FTMBB = PreLayoutFallThroughs[MBB.getNumber()];
153// If this block had a fallthrough before we need an explicit unconditional
154// branch to that block if either
155// 1- the block ends a section, which means its next block may be
156// reorderd by the linker, or
157// 2- the fallthrough block is not adjacent to the block in the new
158// order.
159if (FTMBB && (MBB.isEndSection() || &*NextMBBI != FTMBB))
160TII->insertUnconditionalBranch(MBB, FTMBB,MBB.findBranchDebugLoc());
161
162// We do not optimize branches for machine basic blocks ending sections, as
163// their adjacent block might be reordered by the linker.
164if (MBB.isEndSection())
165continue;
166
167// It might be possible to optimize branches by flipping the branch
168// condition.
169Cond.clear();
170MachineBasicBlock *TBB =nullptr, *FBB =nullptr;// For analyzeBranch.
171if (TII->analyzeBranch(MBB,TBB, FBB,Cond))
172continue;
173MBB.updateTerminator(FTMBB);
174 }
175}
176
177// This function sorts basic blocks according to the cluster's information.
178// All explicitly specified clusters of basic blocks will be ordered
179// accordingly. All non-specified BBs go into a separate "Cold" section.
180// Additionally, if exception handling landing pads end up in more than one
181// clusters, they are moved into a single "Exception" section. Eventually,
182// clusters are ordered in increasing order of their IDs, with the "Exception"
183// and "Cold" succeeding all other clusters.
184// FuncClusterInfo represents the cluster information for basic blocks. It
185// maps from BBID of basic blocks to their cluster information. If this is
186// empty, it means unique sections for all basic blocks in the function.
187staticvoid
188assignSections(MachineFunction &MF,
189constDenseMap<UniqueBBID, BBClusterInfo> &FuncClusterInfo) {
190assert(MF.hasBBSections() &&"BB Sections is not set for function.");
191// This variable stores the section ID of the cluster containing eh_pads (if
192// all eh_pads are one cluster). If more than one cluster contain eh_pads, we
193// set it equal to ExceptionSectionID.
194 std::optional<MBBSectionID> EHPadsSectionID;
195
196for (auto &MBB : MF) {
197// With the 'all' option, every basic block is placed in a unique section.
198// With the 'list' option, every basic block is placed in a section
199// associated with its cluster, unless we want individual unique sections
200// for every basic block in this function (if FuncClusterInfo is empty).
201if (MF.getTarget().getBBSectionsType() ==llvm::BasicBlockSection::All ||
202 FuncClusterInfo.empty()) {
203// If unique sections are desired for all basic blocks of the function, we
204// set every basic block's section ID equal to its original position in
205// the layout (which is equal to its number). This ensures that basic
206// blocks are ordered canonically.
207MBB.setSectionID(MBB.getNumber());
208 }else {
209autoI = FuncClusterInfo.find(*MBB.getBBID());
210if (I != FuncClusterInfo.end()) {
211MBB.setSectionID(I->second.ClusterID);
212 }else {
213constTargetInstrInfo &TII =
214 *MBB.getParent()->getSubtarget().getInstrInfo();
215
216if (TII.isMBBSafeToSplitToCold(MBB)) {
217// BB goes into the special cold section if it is not specified in the
218// cluster info map.
219MBB.setSectionID(MBBSectionID::ColdSectionID);
220 }
221 }
222 }
223
224if (MBB.isEHPad() && EHPadsSectionID !=MBB.getSectionID() &&
225 EHPadsSectionID !=MBBSectionID::ExceptionSectionID) {
226// If we already have one cluster containing eh_pads, this must be updated
227// to ExceptionSectionID. Otherwise, we set it equal to the current
228// section ID.
229 EHPadsSectionID = EHPadsSectionID ?MBBSectionID::ExceptionSectionID
230 :MBB.getSectionID();
231 }
232 }
233
234// If EHPads are in more than one section, this places all of them in the
235// special exception section.
236if (EHPadsSectionID ==MBBSectionID::ExceptionSectionID)
237for (auto &MBB : MF)
238if (MBB.isEHPad())
239MBB.setSectionID(*EHPadsSectionID);
240}
241
242voidllvm::sortBasicBlocksAndUpdateBranches(
243MachineFunction &MF,MachineBasicBlockComparator MBBCmp) {
244 [[maybe_unused]]constMachineBasicBlock *EntryBlock = &MF.front();
245SmallVector<MachineBasicBlock *> PreLayoutFallThroughs(MF.getNumBlockIDs());
246for (auto &MBB : MF)
247 PreLayoutFallThroughs[MBB.getNumber()] =
248MBB.getFallThrough(/*JumpToFallThrough=*/false);
249
250 MF.sort(MBBCmp);
251assert(&MF.front() == EntryBlock &&
252"Entry block should not be displaced by basic block sections");
253
254// Set IsBeginSection and IsEndSection according to the assigned section IDs.
255 MF.assignBeginEndSections();
256
257// After reordering basic blocks, we must update basic block branches to
258// insert explicit fallthrough branches when required and optimize branches
259// when possible.
260updateBranches(MF, PreLayoutFallThroughs);
261}
262
263// If the exception section begins with a landing pad, that landing pad will
264// assume a zero offset (relative to @LPStart) in the LSDA. However, a value of
265// zero implies "no landing pad." This function inserts a NOP just before the EH
266// pad label to ensure a nonzero offset.
267voidllvm::avoidZeroOffsetLandingPad(MachineFunction &MF) {
268for (auto &MBB : MF) {
269if (MBB.isBeginSection() &&MBB.isEHPad()) {
270MachineBasicBlock::iteratorMI =MBB.begin();
271while (!MI->isEHLabel())
272 ++MI;
273 MF.getSubtarget().getInstrInfo()->insertNoop(MBB,MI);
274 }
275 }
276}
277
278boolllvm::hasInstrProfHashMismatch(MachineFunction &MF) {
279if (!BBSectionsDetectSourceDrift)
280returnfalse;
281
282constchar MetadataName[] ="instr_prof_hash_mismatch";
283auto *Existing = MF.getFunction().getMetadata(LLVMContext::MD_annotation);
284if (Existing) {
285MDTuple *Tuple = cast<MDTuple>(Existing);
286for (constauto &N : Tuple->operands())
287if (N.equalsStr(MetadataName))
288returntrue;
289 }
290
291returnfalse;
292}
293
294// Identify, arrange, and modify basic blocks which need separate sections
295// according to the specification provided by the -fbasic-block-sections flag.
296bool BasicBlockSections::handleBBSections(MachineFunction &MF) {
297auto BBSectionsType = MF.getTarget().getBBSectionsType();
298if (BBSectionsType == BasicBlockSection::None)
299returnfalse;
300
301// Check for source drift. If the source has changed since the profiles
302// were obtained, optimizing basic blocks might be sub-optimal.
303// This only applies to BasicBlockSection::List as it creates
304// clusters of basic blocks using basic block ids. Source drift can
305// invalidate these groupings leading to sub-optimal code generation with
306// regards to performance.
307if (BBSectionsType == BasicBlockSection::List &&
308hasInstrProfHashMismatch(MF))
309returnfalse;
310// Renumber blocks before sorting them. This is useful for accessing the
311// original layout positions and finding the original fallthroughs.
312 MF.RenumberBlocks();
313
314DenseMap<UniqueBBID, BBClusterInfo> FuncClusterInfo;
315if (BBSectionsType == BasicBlockSection::List) {
316auto [HasProfile, ClusterInfo] =
317 getAnalysis<BasicBlockSectionsProfileReaderWrapperPass>()
318 .getClusterInfoForFunction(MF.getName());
319if (!HasProfile)
320returnfalse;
321for (auto &BBClusterInfo : ClusterInfo) {
322 FuncClusterInfo.try_emplace(BBClusterInfo.BBID,BBClusterInfo);
323 }
324 }
325
326 MF.setBBSectionsType(BBSectionsType);
327assignSections(MF, FuncClusterInfo);
328
329constMachineBasicBlock &EntryBB = MF.front();
330auto EntryBBSectionID = EntryBB.getSectionID();
331
332// Helper function for ordering BB sections as follows:
333// * Entry section (section including the entry block).
334// * Regular sections (in increasing order of their Number).
335// ...
336// * Exception section
337// * Cold section
338auto MBBSectionOrder = [EntryBBSectionID](constMBBSectionID &LHS,
339constMBBSectionID &RHS) {
340// We make sure that the section containing the entry block precedes all the
341// other sections.
342if (LHS == EntryBBSectionID || RHS == EntryBBSectionID)
343returnLHS == EntryBBSectionID;
344returnLHS.Type ==RHS.Type ?LHS.Number <RHS.Number :LHS.Type <RHS.Type;
345 };
346
347// We sort all basic blocks to make sure the basic blocks of every cluster are
348// contiguous and ordered accordingly. Furthermore, clusters are ordered in
349// increasing order of their section IDs, with the exception and the
350// cold section placed at the end of the function.
351// Also, we force the entry block of the function to be placed at the
352// beginning of the function, regardless of the requested order.
353auto Comparator = [&](constMachineBasicBlock &X,
354constMachineBasicBlock &Y) {
355auto XSectionID =X.getSectionID();
356auto YSectionID =Y.getSectionID();
357if (XSectionID != YSectionID)
358return MBBSectionOrder(XSectionID, YSectionID);
359// Make sure that the entry block is placed at the beginning.
360if (&X == &EntryBB || &Y == &EntryBB)
361return &X == &EntryBB;
362// If the two basic block are in the same section, the order is decided by
363// their position within the section.
364if (XSectionID.Type == MBBSectionID::SectionType::Default)
365return FuncClusterInfo.lookup(*X.getBBID()).PositionInCluster <
366 FuncClusterInfo.lookup(*Y.getBBID()).PositionInCluster;
367returnX.getNumber() <Y.getNumber();
368 };
369
370sortBasicBlocksAndUpdateBranches(MF, Comparator);
371avoidZeroOffsetLandingPad(MF);
372returntrue;
373}
374
375// When the BB address map needs to be generated, this renumbers basic blocks to
376// make them appear in increasing order of their IDs in the function. This
377// avoids the need to store basic block IDs in the BB address map section, since
378// they can be determined implicitly.
379bool BasicBlockSections::handleBBAddrMap(MachineFunction &MF) {
380if (!MF.getTarget().Options.BBAddrMap)
381returnfalse;
382 MF.RenumberBlocks();
383returntrue;
384}
385
386bool BasicBlockSections::runOnMachineFunction(MachineFunction &MF) {
387// First handle the basic block sections.
388auto R1 = handleBBSections(MF);
389// Handle basic block address map after basic block sections are finalized.
390autoR2 = handleBBAddrMap(MF);
391
392// We renumber blocks, so update the dominator tree we want to preserve.
393if (auto *WP = getAnalysisIfAvailable<MachineDominatorTreeWrapperPass>())
394 WP->getDomTree().updateBlockNumbers();
395if (auto *WP = getAnalysisIfAvailable<MachinePostDominatorTreeWrapperPass>())
396 WP->getPostDomTree().updateBlockNumbers();
397
398return R1 ||R2;
399}
400
401void BasicBlockSections::getAnalysisUsage(AnalysisUsage &AU) const{
402 AU.setPreservesAll();
403 AU.addRequired<BasicBlockSectionsProfileReaderWrapperPass>();
404 AU.addUsedIfAvailable<MachineDominatorTreeWrapperPass>();
405 AU.addUsedIfAvailable<MachinePostDominatorTreeWrapperPass>();
406MachineFunctionPass::getAnalysisUsage(AU);
407}
408
409MachineFunctionPass *llvm::createBasicBlockSectionsPass() {
410returnnew BasicBlockSections();
411}
for
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
Definition:AArch64ExpandPseudoInsts.cpp:115
const
aarch64 promote const
Definition:AArch64PromoteConstant.cpp:230
functions
Lower uses of LDS variables from non kernel functions
Definition:AMDGPULowerModuleLDSPass.cpp:1536
MBB
MachineBasicBlock & MBB
Definition:ARMSLSHardening.cpp:71
BasicBlockSectionUtils.h
BasicBlockSectionsProfileReader.h
assignSections
static void assignSections(MachineFunction &MF, const DenseMap< UniqueBBID, BBClusterInfo > &FuncClusterInfo)
Definition:BasicBlockSections.cpp:188
BBSectionsDetectSourceDrift
static 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)
blocks
bbsections Prepares for basic block by splitting functions into clusters of basic blocks
Definition:BasicBlockSections.cpp:140
updateBranches
bbsections Prepares for basic block by splitting functions into clusters of basic static false void updateBranches(MachineFunction &MF, const SmallVector< MachineBasicBlock * > &PreLayoutFallThroughs)
Definition:BasicBlockSections.cpp:146
prepare
bbsections prepare
Definition:BasicBlockSections.cpp:138
sections
bbsections Prepares for basic block sections
Definition:BasicBlockSections.cpp:139
Passes.h
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
TII
const HexagonInstrInfo * TII
Definition:HexagonCopyToCombine.cpp:125
MI
IRTranslator LLVM IR MI
Definition:IRTranslator.cpp:112
InitializePasses.h
I
#define I(x, y, z)
Definition:MD5.cpp:58
MachineDominators.h
MachineFunctionPass.h
MachineFunction.h
MachinePostDominators.h
R2
#define R2(n)
Y
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
INITIALIZE_PASS_DEPENDENCY
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition:PassSupport.h:55
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:57
INITIALIZE_PASS_BEGIN
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:52
TBB
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
Definition:RISCVRedundantCopyElimination.cpp:76
Cond
const SmallVectorImpl< MachineOperand > & Cond
Definition:RISCVRedundantCopyElimination.cpp:75
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SmallVector.h
This file defines the SmallVector class.
StringRef.h
TargetInstrInfo.h
block
unify loop Fixup each natural loop to have a single exit block
Definition:UnifyLoopExits.cpp:70
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:PassAnalysisSupport.h:47
llvm::AnalysisUsage::addUsedIfAvailable
AnalysisUsage & addUsedIfAvailable()
Add the specified Pass class to the set of analyses used by this pass.
Definition:PassAnalysisSupport.h:117
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition:PassAnalysisSupport.h:75
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition:PassAnalysisSupport.h:130
llvm::BasicBlockSectionsProfileReaderWrapperPass
Definition:BasicBlockSectionsProfileReader.h:178
llvm::DenseMapBase::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:194
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition:DenseMap.h:156
llvm::DenseMapBase::try_emplace
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Definition:DenseMap.h:226
llvm::DenseMapBase::empty
bool empty() const
Definition:DenseMap.h:98
llvm::DenseMapBase::end
iterator end()
Definition:DenseMap.h:84
llvm::DenseMap
Definition:DenseMap.h:727
llvm::GlobalObject::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition:Value.h:565
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::MDNode::operands
ArrayRef< MDOperand > operands() const
Definition:Metadata.h:1432
llvm::MDTuple
Tuple of metadata.
Definition:Metadata.h:1479
llvm::MachineBasicBlock
Definition:MachineBasicBlock.h:125
llvm::MachineBasicBlock::isEHPad
bool isEHPad() const
Returns true if the block is a landing pad.
Definition:MachineBasicBlock.h:634
llvm::MachineBasicBlock::getFallThrough
MachineBasicBlock * getFallThrough(bool JumpToFallThrough=true)
Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...
Definition:MachineBasicBlock.cpp:977
llvm::MachineBasicBlock::getNumber
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
Definition:MachineBasicBlock.h:1217
llvm::MachineBasicBlock::getBBID
std::optional< UniqueBBID > getBBID() const
Definition:MachineBasicBlock.h:681
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:693
llvm::MachineBasicBlock::getSectionID
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
Definition:MachineBasicBlock.h:684
llvm::MachineBasicBlock::setSectionID
void setSectionID(MBBSectionID V)
Sets the section ID for this basic block.
Definition:MachineBasicBlock.h:693
llvm::MachineBasicBlock::begin
iterator begin()
Definition:MachineBasicBlock.h:355
llvm::MachineBasicBlock::getParent
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Definition:MachineBasicBlock.h:311
llvm::MachineBasicBlock::isBeginSection
bool isBeginSection() const
Returns true if this block begins any section.
Definition:MachineBasicBlock.h:672
llvm::MachineBasicBlock::findBranchDebugLoc
DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
Definition:MachineBasicBlock.cpp:1559
llvm::MachineBasicBlock::isEndSection
bool isEndSection() const
Returns true if this block ends any section.
Definition:MachineBasicBlock.h:675
llvm::MachineDominatorTreeWrapperPass
Analysis pass which computes a MachineDominatorTree.
Definition:MachineDominators.h:131
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition:MachineFunctionPass.h:30
llvm::MachineFunctionPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Definition:MachineFunctionPass.cpp:169
llvm::MachineFunctionPass::runOnMachineFunction
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
llvm::MachineFunction
Definition:MachineFunction.h:267
llvm::MachineFunction::setBBSectionsType
void setBBSectionsType(BasicBlockSection V)
Definition:MachineFunction.h:722
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition:MachineFunction.h:733
llvm::MachineFunction::getName
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Definition:MachineFunction.cpp:645
llvm::MachineFunction::hasBBSections
bool hasBBSections() const
Returns true if this function has basic block sections enabled.
Definition:MachineFunction.h:716
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition:MachineFunction.h:704
llvm::MachineFunction::getNumBlockIDs
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
Definition:MachineFunction.h:876
llvm::MachineFunction::sort
void sort(Comp comp)
Definition:MachineFunction.h:985
llvm::MachineFunction::RenumberBlocks
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them.
Definition:MachineFunction.cpp:343
llvm::MachineFunction::front
const MachineBasicBlock & front() const
Definition:MachineFunction.h:959
llvm::MachineFunction::assignBeginEndSections
void assignBeginEndSections()
Assign IsBeginSection IsEndSection fields for basic blocks in this function.
Definition:MachineFunction.cpp:415
llvm::MachineFunction::getTarget
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Definition:MachineFunction.h:729
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::MachinePostDominatorTreeWrapperPass
Definition:MachinePostDominators.h:90
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition:PassRegistry.cpp:24
llvm::Pass::getPassName
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Definition:Pass.cpp:81
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::TargetInstrInfo
TargetInstrInfo - Interface to description of machine instruction set.
Definition:TargetInstrInfo.h:112
llvm::TargetInstrInfo::insertNoop
virtual void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const
Insert a noop into the instruction stream at the specified point.
Definition:TargetInstrInfo.cpp:68
llvm::TargetMachine::Options
TargetOptions Options
Definition:TargetMachine.h:118
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:320
llvm::TargetOptions::BBAddrMap
unsigned BBAddrMap
Definition:TargetOptions.h:323
llvm::TargetSubtargetInfo::getInstrInfo
virtual const TargetInstrInfo * getInstrInfo() const
Definition:TargetSubtargetInfo.h:97
llvm::cl::opt
Definition:CommandLine.h:1423
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition:STLFunctionalExtras.h:37
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition:ilist_node.h:132
unsigned
TargetMachine.h
false
Definition:StackSlotColoring.cpp:193
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition:CallingConv.h:24
llvm::cl::Hidden
@ Hidden
Definition:CommandLine.h:137
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:CommandLine.h:443
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::createBasicBlockSectionsPass
MachineFunctionPass * createBasicBlockSectionsPass()
createBasicBlockSections Pass - This pass assigns sections to machine basic blocks and is enabled wit...
Definition:BasicBlockSections.cpp:409
llvm::hasInstrProfHashMismatch
bool hasInstrProfHashMismatch(MachineFunction &MF)
This checks if the source of this function has drifted since this binary was profiled previously.
Definition:BasicBlockSections.cpp:278
llvm::initializeBasicBlockSectionsPass
void initializeBasicBlockSectionsPass(PassRegistry &)
llvm::BasicBlockSection::All
@ All
llvm::avoidZeroOffsetLandingPad
void avoidZeroOffsetLandingPad(MachineFunction &MF)
Definition:BasicBlockSections.cpp:267
llvm::BBSectionsColdTextPrefix
cl::opt< std::string > BBSectionsColdTextPrefix
llvm::sortBasicBlocksAndUpdateBranches
void sortBasicBlocksAndUpdateBranches(MachineFunction &MF, MachineBasicBlockComparator MBBCmp)
Definition:BasicBlockSections.cpp:242
N
#define N
llvm::BBClusterInfo
Definition:BasicBlockSectionsProfileReader.h:36
llvm::BBClusterInfo::BBID
UniqueBBID BBID
Definition:BasicBlockSectionsProfileReader.h:38
llvm::MBBSectionID
Definition:MachineBasicBlock.h:55
llvm::MBBSectionID::ExceptionSectionID
static const MBBSectionID ExceptionSectionID
Definition:MachineBasicBlock.h:68
llvm::MBBSectionID::ColdSectionID
static const MBBSectionID ColdSectionID
Definition:MachineBasicBlock.h:67
llvm::cl::desc
Definition:CommandLine.h:409

Generated on Fri Jul 18 2025 10:30:21 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp