[CSInfo] Use isCandidateForCallSiteEntry() when updating the CSInfo
Use the isCandidateForCallSiteEntry().
This should mostly be an NFC, but there are some parts ensuring
the moveCallSiteInfo() and copyCallSiteInfo() operate with call site
entry candidates (both Src and Dest should be the call site entry
candidates).
Differential Revision: https://reviews.llvm.org/D74122
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index e355e16..f5b8329 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -170,7 +170,7 @@
// Update call site info.
std::for_each(MBB->begin(), MBB->end(), [MF](const MachineInstr &MI) {
- if (MI.isCall(MachineInstr::IgnoreBundle))
+ if (MI.isCandidateForCallSiteEntry())
MF->eraseCallSiteInfo(&MI);
});
// Remove the block.
diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp
index 1a42092..7845573 100644
--- a/llvm/lib/CodeGen/IfConversion.cpp
+++ b/llvm/lib/CodeGen/IfConversion.cpp
@@ -1851,7 +1851,7 @@
while (NumDups1 != 0) {
// Since this instruction is going to be deleted, update call
// site info state if the instruction is call instruction.
- if (DI2->isCall(MachineInstr::IgnoreBundle))
+ if (DI2->isCandidateForCallSiteEntry())
MBB2.getParent()->eraseCallSiteInfo(&*DI2);
++DI2;
@@ -1900,7 +1900,7 @@
// Since this instruction is going to be deleted, update call
// site info state if the instruction is call instruction.
- if (DI1->isCall(MachineInstr::IgnoreBundle))
+ if (DI1->isCandidateForCallSiteEntry())
MBB1.getParent()->eraseCallSiteInfo(&*DI1);
// skip dbg_value instructions
@@ -2188,8 +2188,8 @@
MachineInstr *MI = MF.CloneMachineInstr(&I);
// Make a copy of the call site info.
- if (MI->isCall(MachineInstr::IgnoreBundle))
- MF.copyCallSiteInfo(&I,MI);
+ if (I.isCandidateForCallSiteEntry())
+ MF.copyCallSiteInfo(&I, MI);
ToBBI.BB->insert(ToBBI.BB->end(), MI);
ToBBI.NonPredSize++;
diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp
index ed3e159..94e3ff7 100644
--- a/llvm/lib/CodeGen/InlineSpiller.cpp
+++ b/llvm/lib/CodeGen/InlineSpiller.cpp
@@ -864,7 +864,8 @@
HSpiller.rmFromMergeableSpills(*MI, FI))
--NumSpills;
LIS.ReplaceMachineInstrInMaps(*MI, *FoldMI);
- if (MI->isCall())
+ // Update the call site info.
+ if (MI->isCandidateForCallSiteEntry())
MI->getMF()->moveCallSiteInfo(MI, FoldMI);
MI->eraseFromParent();
diff --git a/llvm/lib/CodeGen/LiveRangeEdit.cpp b/llvm/lib/CodeGen/LiveRangeEdit.cpp
index 85fa967..a77ad10 100644
--- a/llvm/lib/CodeGen/LiveRangeEdit.cpp
+++ b/llvm/lib/CodeGen/LiveRangeEdit.cpp
@@ -231,7 +231,8 @@
return false;
LLVM_DEBUG(dbgs() << " folded: " << *FoldMI);
LIS.ReplaceMachineInstrInMaps(*UseMI, *FoldMI);
- if (UseMI->isCall())
+ // Update the call site info.
+ if (UseMI->isCandidateForCallSiteEntry())
UseMI->getMF()->moveCallSiteInfo(UseMI, FoldMI);
UseMI->eraseFromParent();
DefMI->addRegisterDead(LI->reg, nullptr);
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 10b6aa9..06b5ab5 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -863,7 +863,8 @@
MachineFunction::CallSiteInfoMap::iterator
MachineFunction::getCallSiteInfo(const MachineInstr *MI) {
- assert(MI->isCall() && "Call site info refers only to call instructions!");
+ assert(MI->isCandidateForCallSiteEntry() &&
+ "Call site info refers only to call (MI) candidates");
if (!Target.Options.EnableDebugEntryValues)
return CallSitesInfo.end();
@@ -872,7 +873,11 @@
void MachineFunction::moveCallSiteInfo(const MachineInstr *Old,
const MachineInstr *New) {
- assert(New->isCall() && "Call site info refers only to call instructions!");
+ assert(Old->isCandidateForCallSiteEntry() &&
+ "Call site info refers only to call (MI) candidates");
+
+ if (!New->isCandidateForCallSiteEntry())
+ return eraseCallSiteInfo(Old);
CallSiteInfoMap::iterator CSIt = getCallSiteInfo(Old);
if (CSIt == CallSitesInfo.end())
@@ -884,6 +889,8 @@
}
void MachineFunction::eraseCallSiteInfo(const MachineInstr *MI) {
+ assert(MI->isCandidateForCallSiteEntry() &&
+ "Call site info refers only to call (MI) candidates");
CallSiteInfoMap::iterator CSIt = getCallSiteInfo(MI);
if (CSIt == CallSitesInfo.end())
return;
@@ -892,7 +899,11 @@
void MachineFunction::copyCallSiteInfo(const MachineInstr *Old,
const MachineInstr *New) {
- assert(New->isCall() && "Call site info refers only to call instructions!");
+ assert(Old->isCandidateForCallSiteEntry() &&
+ "Call site info refers only to call (MI) candidates");
+
+ if (!New->isCandidateForCallSiteEntry())
+ return eraseCallSiteInfo(Old);
CallSiteInfoMap::iterator CSIt = getCallSiteInfo(Old);
if (CSIt == CallSitesInfo.end())
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 46a6e86..8fd3679 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -1260,7 +1260,7 @@
MOP.getReg(), true, /* isDef = true */
true /* isImp = true */));
}
- if (MI.isCall())
+ if (MI.isCandidateForCallSiteEntry())
MI.getMF()->eraseCallSiteInfo(&MI);
};
// Copy over the defs in the outlined range.
diff --git a/llvm/lib/CodeGen/PeepholeOptimizer.cpp b/llvm/lib/CodeGen/PeepholeOptimizer.cpp
index c9c279c..b51a766 100644
--- a/llvm/lib/CodeGen/PeepholeOptimizer.cpp
+++ b/llvm/lib/CodeGen/PeepholeOptimizer.cpp
@@ -1776,7 +1776,8 @@
LocalMIs.erase(MI);
LocalMIs.erase(DefMI);
LocalMIs.insert(FoldMI);
- if (MI->isCall())
+ // Update the call site info.
+ if (MI->isCandidateForCallSiteEntry())
MI->getMF()->moveCallSiteInfo(MI, FoldMI);
MI->eraseFromParent();
DefMI->eraseFromParent();
diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp
index 3c4f884..d1f212f 100644
--- a/llvm/lib/CodeGen/TargetInstrInfo.cpp
+++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp
@@ -143,7 +143,7 @@
// from the end of MBB.
while (Tail != MBB->end()) {
auto MI = Tail++;
- if (MI->isCall())
+ if (MI->isCandidateForCallSiteEntry())
MBB->getParent()->eraseCallSiteInfo(&*MI);
MBB->erase(MI);
}
diff --git a/llvm/lib/CodeGen/UnreachableBlockElim.cpp b/llvm/lib/CodeGen/UnreachableBlockElim.cpp
index b770e1d..97d698d 100644
--- a/llvm/lib/CodeGen/UnreachableBlockElim.cpp
+++ b/llvm/lib/CodeGen/UnreachableBlockElim.cpp
@@ -151,7 +151,7 @@
for (unsigned i = 0, e = DeadBlocks.size(); i != e; ++i) {
// Remove any call site information for calls in the block.
for (auto &I : DeadBlocks[i]->instrs())
- if (I.isCall(MachineInstr::IgnoreBundle))
+ if (I.isCandidateForCallSiteEntry())
DeadBlocks[i]->getParent()->eraseCallSiteInfo(&I);
DeadBlocks[i]->eraseFromParent();
diff --git a/llvm/lib/CodeGen/XRayInstrumentation.cpp b/llvm/lib/CodeGen/XRayInstrumentation.cpp
index f1a4b0f..a98888b 100644
--- a/llvm/lib/CodeGen/XRayInstrumentation.cpp
+++ b/llvm/lib/CodeGen/XRayInstrumentation.cpp
@@ -111,7 +111,7 @@
for (auto &MO : T.operands())
MIB.add(MO);
Terminators.push_back(&T);
- if (T.isCall())
+ if (T.isCandidateForCallSiteEntry())
MF.eraseCallSiteInfo(&T);
}
}