Go to the documentation of this file.
90 "bbsections-cold-text-prefix",
91 cl::desc(
"The text prefix to use for cold basic block clusters"),
95 "bbsections-detect-source-drift",
96 cl::desc(
"This checks if there is a fdo instr. profile hash "
97 "mismatch for this function"),
113 return "Basic Block Sections Analysis";
127 "Prepares for basic block sections, by splitting functions "
128 "into clusters of basic blocks.",
173 std::pair<bool, SmallVector<BBClusterInfo, 4>>
P =
178 if (
P.second.empty()) {
207 std::optional<MBBSectionID> EHPadsSectionID;
209 for (
auto &
MBB : MF) {
215 FuncBBClusterInfo.
empty()) {
225 if (
I != FuncBBClusterInfo.
end()) {
260 assert(&MF.front() == EntryBlock &&
261 "Entry block should not be displaced by basic block sections");
264 MF.assignBeginEndSections();
277 for (
auto &
MBB : MF) {
280 while (!
MI->isEHLabel())
282 MCInst Nop = MF.getSubtarget().getInstrInfo()->getNop();
284 MF.getSubtarget().getInstrInfo()->
get(
Nop.getOpcode()));
298 const char MetadataName[] =
"instr_prof_hash_mismatch";
301 MDTuple *Tuple = cast<MDTuple>(Existing);
303 if (cast<MDString>(
N.get())->getString() == MetadataName)
313 "BB Sections not enabled!");
339 BBSectionsProfileReader = &getAnalysis<BasicBlockSectionsProfileReader>();
364 if (
LHS == EntryBBSectionID ||
RHS == EntryBBSectionID)
365 return LHS == EntryBBSectionID;
375 auto XSectionID =
X.getSectionID();
376 auto YSectionID =
Y.getSectionID();
377 if (XSectionID != YSectionID)
378 return MBBSectionOrder(XSectionID, YSectionID);
384 return X.getNumber() <
Y.getNumber();
392 void BasicBlockSections::getAnalysisUsage(
AnalysisUsage &AU)
const {
399 return new BasicBlockSections();
bool getBBClusterInfoForFunction(const MachineFunction &MF, BasicBlockSectionsProfileReader *BBSectionsProfileReader, DenseMap< unsigned, BBClusterInfo > &V)
This is an optimization pass for GlobalISel generic memory operations.
void sortBasicBlocksAndUpdateBranches(MachineFunction &MF, MachineBasicBlockComparator MBBCmp)
static void assignSections(MachineFunction &MF, const DenseMap< unsigned, BBClusterInfo > &FuncBBClusterInfo)
static const unsigned Nop
Instruction opcodes emitted via means other than CodeGen.
cl::opt< std::string > BBSectionsColdTextPrefix
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...
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
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....
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
Instances of this class represent a single low-level machine instruction.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
void avoidZeroOffsetLandingPad(MachineFunction &MF)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
bool isBeginSection() const
Returns true if this block begins any section.
void setSectionID(MBBSectionID V)
Sets the section ID for this basic block.
const MachineBasicBlock & front() const
TargetInstrInfo - Interface to description of machine instruction set.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
ArrayRef< MDOperand > operands() const
Represent the analysis usage information of a pass.
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const HexagonInstrInfo * TII
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
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
An efficient, type-erasing, non-owning reference to a callable.
initializer< Ty > init(const Ty &Val)
iterator find(const_arg_type_t< KeyT > Val)
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
const static MBBSectionID ExceptionSectionID
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned PositionInCluster
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
SmallVector< MachineOperand, 4 > Cond
bool isEHPad() const
Returns true if the block is a landing pad.
StringRef - Represent a constant reference to a string, i.e.
DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
self_iterator getIterator()
bool hasBBSections() const
Returns true if this function has basic block sections enabled.
void initializeBasicBlockSectionsPass(PassRegistry &)
const SmallVector< MachineBasicBlock * > & PreLayoutFallThroughs
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
static bool hasInstrProfHashMismatch(MachineFunction &MF)
Function & getFunction()
Return the LLVM function that this machine code represents.
void setPreservesAll()
Set by analyses that do not transform their input at all.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
bool isEndSection() const
Returns true if this block ends any section.
const static MBBSectionID ColdSectionID
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)
std::pair< bool, SmallVector< BBClusterInfo > > getBBClusterInfoForFunction(StringRef FuncName) const
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
MachineBasicBlock * getFallThrough(bool JumpToFallThrough=false)
Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...
AnalysisUsage & addRequired()
void updateTerminator(MachineBasicBlock *PreviousLayoutSuccessor)
Update the terminator instructions in block to account for changes to block layout which may have bee...
unsigned getBBIDOrNumber() const
Returns the BBID of the block when BBAddrMapVersion >= 2, otherwise returns MachineBasicBlock::Number...
void setBBSectionsType(BasicBlockSection V)
MachineFunctionPass * createBasicBlockSectionsPass()
createBasicBlockSections Pass - This pass assigns sections to machine basic blocks and is enabled wit...
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them.
llvm::BasicBlockSection getBBSectionsType() const
If basic blocks should be emitted into their own section, corresponding to -fbasic-block-sections.