57 auto TII = MF.getSubtarget().getInstrInfo();
64 for (
auto &
I : OrigBB.
instrs()) {
66 if (
I.isBundledWithPred())
68 TII->duplicate(*CloneBB, CloneBB->
end(),
I);
93 for (
size_t I = 0;
I < ClonePath.
size(); ++
I) {
94 unsigned BBID = ClonePath[
I];
105 <<
"block #" << BBID <<
" is not a successor of block #"
111 for (
auto &
MI : *PathBB) {
115 if (
MI.isNotDuplicable() && !
MI.isCFIInstruction()) {
118 <<
" has non-duplicable instructions in function " << MF.
getName()
123 if (PathBB->isMachineBlockAddressTaken()) {
128 <<
" has its machine block address taken in function "
132 if (PathBB->isInlineAsmBrIndirectTarget()) {
136 <<
" is a branch target of an 'asm goto' in function "
142 if (
I != ClonePath.
size() - 1 && !PathBB->empty() &&
143 PathBB->back().isIndirectBranch()) {
146 <<
" has indirect branch and appears as the non-tail block of a "
160 if (ClonePaths.empty())
162 bool AnyPathsCloned =
false;
166 BBIDToBlock.
try_emplace(BB.getBBID()->BaseID, &BB);
169 auto TII = MF.getSubtarget().getInstrInfo();
170 for (
const auto &ClonePath : ClonePaths) {
171 if (!IsValidCloning(MF, BBIDToBlock, ClonePath)) {
174 for (
unsigned BBID : ClonePath)
175 ++NClonesForBBID[BBID];
179 for (
unsigned BBID : ClonePath) {
181 if (PrevBB ==
nullptr) {
186 TII->insertUnconditionalBranch(*OrigBB, FT,
193 CloneMachineBasicBlock(*OrigBB, ++NClonesForBBID[BBID]);
201 for (
auto &LiveIn : OrigBB->
liveins())
206 AnyPathsCloned =
true;
208 return AnyPathsCloned;
237 "Applies path clonings for the -basic-block-sections=list option",
false,
246 assert(MF.getTarget().getBBSectionsType() == BasicBlockSection::List &&
247 "BB Sections list not enabled!");
251 return ApplyCloning(MF,
252 getAnalysis<BasicBlockSectionsProfileReaderWrapperPass>()
253 .getClonePathsForFunction(MF.getName()));
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
bbsections Prepares for basic block sections
const HexagonInstrInfo * TII
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file defines the SmallVector class.
unify loop Fixup each natural loop to have a single exit block
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
BasicBlockSectionsProfileReaderWrapperPass * BBSectionsProfileReader
bool runOnMachineFunction(MachineFunction &MF) override
Identify basic blocks that need separate sections and prepare to emit them accordingly.
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
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...
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
const ValueT & at(const_arg_type_t< KeyT > Val) const
at - Return the entry for the specified key, or abort if no such entry exists.
LLVM_ABI MachineBasicBlock * getFallThrough(bool JumpToFallThrough=true)
Return the fallthrough block if the block can implicitly transfer control to the block after it by fa...
iterator_range< livein_iterator > liveins() const
void push_back(MachineInstr *MI)
std::optional< UniqueBBID > getBBID() const
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
succ_iterator succ_begin()
LLVM_ABI void copySuccessor(const MachineBasicBlock *Orig, succ_iterator I)
Copy a successor (and any probability info) from original block to this block's.
LLVM_ABI void ReplaceUsesOfBlockWith(MachineBasicBlock *Old, MachineBasicBlock *New)
Given a machine basic block that branched to 'Old', change the code and CFG so that it branches to 'N...
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ABI DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
LLVM_ABI bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
static LLVM_ABI raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
This is an optimization pass for GlobalISel generic memory operations.
bool hasInstrProfHashMismatch(MachineFunction &MF)
This checks if the source of this function has drifted since this binary was profiled previously.
LLVM_ABI void initializeBasicBlockPathCloningPass(PassRegistry &)
LLVM_ABI MachineFunctionPass * createBasicBlockPathCloningPass()