summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp43
1 files changed, 39 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 08a51b9b0242..1cb57a4fa425 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -606,6 +606,26 @@ void MachineBasicBlock::removeLiveIn(MCRegister Reg, LaneBitmask LaneMask) {
LiveIns.erase(I);
}
+void MachineBasicBlock::removeLiveInOverlappedWith(MCRegister Reg) {
+ const MachineFunction *MF = getParent();
+ const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
+ // Remove Reg and its subregs from live in set.
+ for (MCPhysReg S : TRI->subregs_inclusive(Reg))
+ removeLiveIn(S);
+
+ // Remove live-in bitmask in super registers as well.
+ for (MCPhysReg Super : TRI->superregs(Reg)) {
+ for (MCSubRegIndexIterator SRI(Super, TRI); SRI.isValid(); ++SRI) {
+ if (Reg == SRI.getSubReg()) {
+ unsigned SubRegIndex = SRI.getSubRegIndex();
+ LaneBitmask SubRegLaneMask = TRI->getSubRegIndexLaneMask(SubRegIndex);
+ removeLiveIn(Super, SubRegLaneMask);
+ break;
+ }
+ }
+ }
+}
+
MachineBasicBlock::livein_iterator
MachineBasicBlock::removeLiveIn(MachineBasicBlock::livein_iterator I) {
// Get non-const version of iterator.
@@ -1160,7 +1180,7 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
MachineBasicBlock *Succ, const SplitCriticalEdgeAnalyses &Analyses,
std::vector<SparseBitVector<>> *LiveInSets, MachineDomTreeUpdater *MDTU) {
- if (!canSplitCriticalEdge(Succ))
+ if (!canSplitCriticalEdge(Succ, Analyses.MLI))
return nullptr;
MachineFunction *MF = getParent();
@@ -1388,8 +1408,8 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
return NMBB;
}
-bool MachineBasicBlock::canSplitCriticalEdge(
- const MachineBasicBlock *Succ) const {
+bool MachineBasicBlock::canSplitCriticalEdge(const MachineBasicBlock *Succ,
+ const MachineLoopInfo *MLI) const {
// Splitting the critical edge to a landing pad block is non-trivial. Don't do
// it in this generic function.
if (Succ->isEHPad())
@@ -1403,8 +1423,17 @@ bool MachineBasicBlock::canSplitCriticalEdge(
const MachineFunction *MF = getParent();
// Performance might be harmed on HW that implements branching using exec mask
// where both sides of the branches are always executed.
- if (MF->getTarget().requiresStructuredCFG())
+
+ if (MF->getTarget().requiresStructuredCFG()) {
+ // If `Succ` is a loop header, splitting the critical edge will not
+ // break structured CFG.
+ if (MLI) {
+ const MachineLoop *L = MLI->getLoopFor(Succ);
+ return L && L->getHeader() == Succ;
+ }
+
return false;
+ }
// Do we have an Indirect jump with a jumptable that we can rewrite?
int JTI = findJumpTableIndex(*this);
@@ -1802,6 +1831,12 @@ bool MachineBasicBlock::sizeWithoutDebugLargerThan(unsigned Limit) const {
return false;
}
+void MachineBasicBlock::removePHIsIncomingValuesForPredecessor(
+ const MachineBasicBlock &PredMBB) {
+ for (MachineInstr &Phi : phis())
+ Phi.removePHIIncomingValueFor(PredMBB);
+}
+
const MBBSectionID MBBSectionID::ColdSectionID(MBBSectionID::SectionType::Cold);
const MBBSectionID
MBBSectionID::ExceptionSectionID(MBBSectionID::SectionType::Exception);