diff options
author | Ellis Hoag <ellis.sparky.hoag@gmail.com> | 2025-01-22 09:50:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-22 09:50:49 -0800 |
commit | b1943f40e74dcfe4ebd6213e1a8a01403bd5ffa9 (patch) | |
tree | de109994c4729e1407b6e8183b96d7e58a1207fd /llvm/lib/CodeGen/BranchFolding.cpp | |
parent | 511dc261ab94da7db6e67b05cdcef9dcff44798a (diff) | |
download | llvm-b1943f40e74dcfe4ebd6213e1a8a01403bd5ffa9.zip llvm-b1943f40e74dcfe4ebd6213e1a8a01403bd5ffa9.tar.gz llvm-b1943f40e74dcfe4ebd6213e1a8a01403bd5ffa9.tar.bz2 |
[BranchFolding] Remove getBranchDebugLoc() (#114613)
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index 65476fa..29a3076 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -1268,15 +1268,6 @@ static bool IsBetterFallthrough(MachineBasicBlock *MBB1, return MBB2I->isCall() && !MBB1I->isCall(); } -/// getBranchDebugLoc - Find and return, if any, the DebugLoc of the branch -/// instructions on the block. -static DebugLoc getBranchDebugLoc(MachineBasicBlock &MBB) { - MachineBasicBlock::iterator I = MBB.getLastNonDebugInstr(); - if (I != MBB.end() && I->isBranch()) - return I->getDebugLoc(); - return DebugLoc(); -} - static void copyDebugInfoToPredecessor(const TargetInstrInfo *TII, MachineBasicBlock &MBB, MachineBasicBlock &PredMBB) { @@ -1403,11 +1394,11 @@ ReoptimizeBlock: // destination, remove the branch, replacing it with an unconditional one or // a fall-through. if (PriorTBB && PriorTBB == PriorFBB) { - DebugLoc dl = getBranchDebugLoc(PrevBB); + DebugLoc Dl = PrevBB.findBranchDebugLoc(); TII->removeBranch(PrevBB); PriorCond.clear(); if (PriorTBB != MBB) - TII->insertBranch(PrevBB, PriorTBB, nullptr, PriorCond, dl); + TII->insertBranch(PrevBB, PriorTBB, nullptr, PriorCond, Dl); MadeChange = true; ++NumBranchOpts; goto ReoptimizeBlock; @@ -1461,9 +1452,9 @@ ReoptimizeBlock: // If the prior block branches somewhere else on the condition and here if // the condition is false, remove the uncond second branch. if (PriorFBB == MBB) { - DebugLoc dl = getBranchDebugLoc(PrevBB); + DebugLoc Dl = PrevBB.findBranchDebugLoc(); TII->removeBranch(PrevBB); - TII->insertBranch(PrevBB, PriorTBB, nullptr, PriorCond, dl); + TII->insertBranch(PrevBB, PriorTBB, nullptr, PriorCond, Dl); MadeChange = true; ++NumBranchOpts; goto ReoptimizeBlock; @@ -1475,9 +1466,9 @@ ReoptimizeBlock: if (PriorTBB == MBB) { SmallVector<MachineOperand, 4> NewPriorCond(PriorCond); if (!TII->reverseBranchCondition(NewPriorCond)) { - DebugLoc dl = getBranchDebugLoc(PrevBB); + DebugLoc Dl = PrevBB.findBranchDebugLoc(); TII->removeBranch(PrevBB); - TII->insertBranch(PrevBB, PriorFBB, nullptr, NewPriorCond, dl); + TII->insertBranch(PrevBB, PriorFBB, nullptr, NewPriorCond, Dl); MadeChange = true; ++NumBranchOpts; goto ReoptimizeBlock; @@ -1513,9 +1504,9 @@ ReoptimizeBlock: LLVM_DEBUG(dbgs() << "\nMoving MBB: " << *MBB << "To make fallthrough to: " << *PriorTBB << "\n"); - DebugLoc dl = getBranchDebugLoc(PrevBB); + DebugLoc Dl = PrevBB.findBranchDebugLoc(); TII->removeBranch(PrevBB); - TII->insertBranch(PrevBB, MBB, nullptr, NewPriorCond, dl); + TII->insertBranch(PrevBB, MBB, nullptr, NewPriorCond, Dl); // Move this block to the end of the function. MBB->moveAfter(&MF.back()); @@ -1576,9 +1567,9 @@ ReoptimizeBlock: if (CurTBB && CurFBB && CurFBB == MBB && CurTBB != MBB) { SmallVector<MachineOperand, 4> NewCond(CurCond); if (!TII->reverseBranchCondition(NewCond)) { - DebugLoc dl = getBranchDebugLoc(*MBB); + DebugLoc Dl = MBB->findBranchDebugLoc(); TII->removeBranch(*MBB); - TII->insertBranch(*MBB, CurFBB, CurTBB, NewCond, dl); + TII->insertBranch(*MBB, CurFBB, CurTBB, NewCond, Dl); MadeChange = true; ++NumBranchOpts; goto ReoptimizeBlock; @@ -1590,7 +1581,7 @@ ReoptimizeBlock: if (CurTBB && CurCond.empty() && !CurFBB && IsBranchOnlyBlock(MBB) && CurTBB != MBB && !MBB->hasAddressTaken() && !MBB->isEHPad()) { - DebugLoc dl = getBranchDebugLoc(*MBB); + DebugLoc Dl = MBB->findBranchDebugLoc(); // This block may contain just an unconditional branch. Because there can // be 'non-branch terminators' in the block, try removing the branch and // then seeing if the block is empty. @@ -1624,9 +1615,9 @@ ReoptimizeBlock: assert(!PriorFBB && "Machine CFG out of date!"); PriorFBB = MBB; } - DebugLoc pdl = getBranchDebugLoc(PrevBB); + DebugLoc PrevDl = PrevBB.findBranchDebugLoc(); TII->removeBranch(PrevBB); - TII->insertBranch(PrevBB, PriorTBB, PriorFBB, PriorCond, pdl); + TII->insertBranch(PrevBB, PriorTBB, PriorFBB, PriorCond, PrevDl); } // Iterate through all the predecessors, revectoring each in-turn. @@ -1659,10 +1650,11 @@ ReoptimizeBlock: bool NewCurUnAnalyzable = TII->analyzeBranch( *PMBB, NewCurTBB, NewCurFBB, NewCurCond, true); if (!NewCurUnAnalyzable && NewCurTBB && NewCurTBB == NewCurFBB) { - DebugLoc pdl = getBranchDebugLoc(*PMBB); + DebugLoc PrevDl = PMBB->findBranchDebugLoc(); TII->removeBranch(*PMBB); NewCurCond.clear(); - TII->insertBranch(*PMBB, NewCurTBB, nullptr, NewCurCond, pdl); + TII->insertBranch(*PMBB, NewCurTBB, nullptr, NewCurCond, + PrevDl); MadeChange = true; ++NumBranchOpts; } @@ -1681,7 +1673,7 @@ ReoptimizeBlock: } // Add the branch back if the block is more than just an uncond branch. - TII->insertBranch(*MBB, CurTBB, nullptr, CurCond, dl); + TII->insertBranch(*MBB, CurTBB, nullptr, CurCond, Dl); } } |