@@ -1268,15 +1268,6 @@ static bool IsBetterFallthrough(MachineBasicBlock *MBB1,
1268
1268
return MBB2I->isCall () && !MBB1I->isCall ();
1269
1269
}
1270
1270
1271
- // / getBranchDebugLoc - Find and return, if any, the DebugLoc of the branch
1272
- // / instructions on the block.
1273
- static DebugLoc getBranchDebugLoc (MachineBasicBlock &MBB) {
1274
- MachineBasicBlock::iterator I = MBB.getLastNonDebugInstr ();
1275
- if (I != MBB.end () && I->isBranch ())
1276
- return I->getDebugLoc ();
1277
- return DebugLoc ();
1278
- }
1279
-
1280
1271
static void copyDebugInfoToPredecessor (const TargetInstrInfo *TII,
1281
1272
MachineBasicBlock &MBB,
1282
1273
MachineBasicBlock &PredMBB) {
@@ -1403,11 +1394,11 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
1403
1394
// destination, remove the branch, replacing it with an unconditional one or
1404
1395
// a fall-through.
1405
1396
if (PriorTBB && PriorTBB == PriorFBB) {
1406
- DebugLoc dl = getBranchDebugLoc ( PrevBB);
1397
+ DebugLoc Dl = PrevBB. findBranchDebugLoc ( );
1407
1398
TII->removeBranch (PrevBB);
1408
1399
PriorCond.clear ();
1409
1400
if (PriorTBB != MBB)
1410
- TII->insertBranch (PrevBB, PriorTBB, nullptr , PriorCond, dl );
1401
+ TII->insertBranch (PrevBB, PriorTBB, nullptr , PriorCond, Dl );
1411
1402
MadeChange = true ;
1412
1403
++NumBranchOpts;
1413
1404
goto ReoptimizeBlock;
@@ -1461,9 +1452,9 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
1461
1452
// If the prior block branches somewhere else on the condition and here if
1462
1453
// the condition is false, remove the uncond second branch.
1463
1454
if (PriorFBB == MBB) {
1464
- DebugLoc dl = getBranchDebugLoc ( PrevBB);
1455
+ DebugLoc Dl = PrevBB. findBranchDebugLoc ( );
1465
1456
TII->removeBranch (PrevBB);
1466
- TII->insertBranch (PrevBB, PriorTBB, nullptr , PriorCond, dl );
1457
+ TII->insertBranch (PrevBB, PriorTBB, nullptr , PriorCond, Dl );
1467
1458
MadeChange = true ;
1468
1459
++NumBranchOpts;
1469
1460
goto ReoptimizeBlock;
@@ -1475,9 +1466,9 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
1475
1466
if (PriorTBB == MBB) {
1476
1467
SmallVector<MachineOperand, 4 > NewPriorCond (PriorCond);
1477
1468
if (!TII->reverseBranchCondition (NewPriorCond)) {
1478
- DebugLoc dl = getBranchDebugLoc ( PrevBB);
1469
+ DebugLoc Dl = PrevBB. findBranchDebugLoc ( );
1479
1470
TII->removeBranch (PrevBB);
1480
- TII->insertBranch (PrevBB, PriorFBB, nullptr , NewPriorCond, dl );
1471
+ TII->insertBranch (PrevBB, PriorFBB, nullptr , NewPriorCond, Dl );
1481
1472
MadeChange = true ;
1482
1473
++NumBranchOpts;
1483
1474
goto ReoptimizeBlock;
@@ -1513,9 +1504,9 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
1513
1504
LLVM_DEBUG (dbgs () << " \n Moving MBB: " << *MBB
1514
1505
<< " To make fallthrough to: " << *PriorTBB << " \n " );
1515
1506
1516
- DebugLoc dl = getBranchDebugLoc ( PrevBB);
1507
+ DebugLoc Dl = PrevBB. findBranchDebugLoc ( );
1517
1508
TII->removeBranch (PrevBB);
1518
- TII->insertBranch (PrevBB, MBB, nullptr , NewPriorCond, dl );
1509
+ TII->insertBranch (PrevBB, MBB, nullptr , NewPriorCond, Dl );
1519
1510
1520
1511
// Move this block to the end of the function.
1521
1512
MBB->moveAfter (&MF.back ());
@@ -1576,9 +1567,9 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
1576
1567
if (CurTBB && CurFBB && CurFBB == MBB && CurTBB != MBB) {
1577
1568
SmallVector<MachineOperand, 4 > NewCond (CurCond);
1578
1569
if (!TII->reverseBranchCondition (NewCond)) {
1579
- DebugLoc dl = getBranchDebugLoc (* MBB);
1570
+ DebugLoc Dl = MBB-> findBranchDebugLoc ( );
1580
1571
TII->removeBranch (*MBB);
1581
- TII->insertBranch (*MBB, CurFBB, CurTBB, NewCond, dl );
1572
+ TII->insertBranch (*MBB, CurFBB, CurTBB, NewCond, Dl );
1582
1573
MadeChange = true ;
1583
1574
++NumBranchOpts;
1584
1575
goto ReoptimizeBlock;
@@ -1590,7 +1581,7 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
1590
1581
if (CurTBB && CurCond.empty () && !CurFBB &&
1591
1582
IsBranchOnlyBlock (MBB) && CurTBB != MBB &&
1592
1583
!MBB->hasAddressTaken () && !MBB->isEHPad ()) {
1593
- DebugLoc dl = getBranchDebugLoc (* MBB);
1584
+ DebugLoc Dl = MBB-> findBranchDebugLoc ( );
1594
1585
// This block may contain just an unconditional branch. Because there can
1595
1586
// be 'non-branch terminators' in the block, try removing the branch and
1596
1587
// then seeing if the block is empty.
@@ -1624,9 +1615,9 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
1624
1615
assert (!PriorFBB && " Machine CFG out of date!" );
1625
1616
PriorFBB = MBB;
1626
1617
}
1627
- DebugLoc pdl = getBranchDebugLoc ( PrevBB);
1618
+ DebugLoc PrevDl = PrevBB. findBranchDebugLoc ( );
1628
1619
TII->removeBranch (PrevBB);
1629
- TII->insertBranch (PrevBB, PriorTBB, PriorFBB, PriorCond, pdl );
1620
+ TII->insertBranch (PrevBB, PriorTBB, PriorFBB, PriorCond, PrevDl );
1630
1621
}
1631
1622
1632
1623
// Iterate through all the predecessors, revectoring each in-turn.
@@ -1659,10 +1650,11 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
1659
1650
bool NewCurUnAnalyzable = TII->analyzeBranch (
1660
1651
*PMBB, NewCurTBB, NewCurFBB, NewCurCond, true );
1661
1652
if (!NewCurUnAnalyzable && NewCurTBB && NewCurTBB == NewCurFBB) {
1662
- DebugLoc pdl = getBranchDebugLoc (* PMBB);
1653
+ DebugLoc PrevDl = PMBB-> findBranchDebugLoc ( );
1663
1654
TII->removeBranch (*PMBB);
1664
1655
NewCurCond.clear ();
1665
- TII->insertBranch (*PMBB, NewCurTBB, nullptr , NewCurCond, pdl);
1656
+ TII->insertBranch (*PMBB, NewCurTBB, nullptr , NewCurCond,
1657
+ PrevDl);
1666
1658
MadeChange = true ;
1667
1659
++NumBranchOpts;
1668
1660
}
@@ -1681,7 +1673,7 @@ bool BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
1681
1673
}
1682
1674
1683
1675
// Add the branch back if the block is more than just an uncond branch.
1684
- TII->insertBranch (*MBB, CurTBB, nullptr , CurCond, dl );
1676
+ TII->insertBranch (*MBB, CurTBB, nullptr , CurCond, Dl );
1685
1677
}
1686
1678
}
1687
1679
0 commit comments