Commit 68908993 authored by Djordje Todorovic's avatar Djordje Todorovic
Browse files

[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
parent d2e0fee7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ void BranchFolder::RemoveDeadBlock(MachineBasicBlock *MBB) {

  // 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.
+4 −4
Original line number Diff line number Diff line
@@ -1851,7 +1851,7 @@ bool IfConverter::IfConvertDiamondCommon(
  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 @@ bool IfConverter::IfConvertDiamondCommon(

    // 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,7 +2188,7 @@ void IfConverter::CopyAndPredicateBlock(BBInfo &ToBBI, BBInfo &FromBBI,

    MachineInstr *MI = MF.CloneMachineInstr(&I);
    // Make a copy of the call site info.
    if (MI->isCall(MachineInstr::IgnoreBundle))
    if (I.isCandidateForCallSiteEntry())
      MF.copyCallSiteInfo(&I, MI);

    ToBBI.BB->insert(ToBBI.BB->end(), MI);
+2 −1
Original line number Diff line number Diff line
@@ -864,7 +864,8 @@ foldMemoryOperand(ArrayRef<std::pair<MachineInstr *, unsigned>> Ops,
      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();

+2 −1
Original line number Diff line number Diff line
@@ -231,7 +231,8 @@ bool LiveRangeEdit::foldAsLoad(LiveInterval *LI,
    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);
+14 −3
Original line number Diff line number Diff line
@@ -863,7 +863,8 @@ try_next:;

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 @@ MachineFunction::getCallSiteInfo(const MachineInstr *MI) {

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::moveCallSiteInfo(const MachineInstr *Old,
}

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::eraseCallSiteInfo(const MachineInstr *MI) {

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())
Loading