56 auto TII = MF.getSubtarget().getInstrInfo();
63 for (
auto &
I : OrigBB.
instrs()) {
65 if (
I.isBundledWithPred())
67 TII->duplicate(*CloneBB, CloneBB->
end(),
I);
92 for (
size_t I = 0;
I < ClonePath.
size(); ++
I) {
93 unsigned BBID = ClonePath[
I];
104 <<
"block #" << BBID <<
" is not a successor of block #"
110 for (
auto &
MI : *PathBB) {
114 if (
MI.isNotDuplicable() && !
MI.isCFIInstruction()) {
117 <<
" has non-duplicable instructions in function " << MF.
getName()
122 if (PathBB->isMachineBlockAddressTaken()) {
128 <<
" has its machine block address taken in function "
134 if (
I != ClonePath.
size() - 1 && !PathBB->empty() &&
135 PathBB->back().isIndirectBranch()) {
138 <<
" has indirect branch and appears as the non-tail block of a "
152 if (ClonePaths.empty())
154 bool AnyPathsCloned =
false;
158 BBIDToBlock.
try_emplace(BB.getBBID()->BaseID, &BB);
161 auto TII = MF.getSubtarget().getInstrInfo();
162 for (
const auto &ClonePath : ClonePaths) {
163 if (!IsValidCloning(MF, BBIDToBlock, ClonePath)) {
166 for (
unsigned BBID : ClonePath)
167 ++NClonesForBBID[BBID];
171 for (
unsigned BBID : ClonePath) {
173 if (PrevBB ==
nullptr) {
178 TII->insertUnconditionalBranch(*OrigBB, FT,
185 CloneMachineBasicBlock(*OrigBB, ++NClonesForBBID[BBID]);
193 for (
auto &LiveIn : OrigBB->
liveins())
198 AnyPathsCloned =
true;
200 return AnyPathsCloned;
229 "Applies path clonings for the -basic-block-sections=list option",
false,
238 assert(MF.getTarget().getBBSectionsType() == BasicBlockSection::List &&
239 "BB Sections list not enabled!");
243 return ApplyCloning(MF,
244 getAnalysis<BasicBlockSectionsProfileReaderWrapperPass>()
245 .getClonePathsForFunction(MF.getName()));
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
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)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
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()
void copySuccessor(const MachineBasicBlock *Orig, succ_iterator I)
Copy a successor (and any probability info) from original block to this block's.
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.
DebugLoc findBranchDebugLoc()
Find and return the merged DebugLoc of the branch instructions of the block.
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 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 raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
This is an optimization pass for GlobalISel generic memory operations.
MachineFunctionPass * createBasicBlockPathCloningPass()
bool hasInstrProfHashMismatch(MachineFunction &MF)
This checks if the source of this function has drifted since this binary was profiled previously.
void initializeBasicBlockPathCloningPass(PassRegistry &)