@@ -124,12 +124,6 @@ CSRFirstTimeCost("regalloc-csr-first-time-cost",
124
124
cl::desc (" Cost for first time use of callee-saved register." ),
125
125
cl::init(0 ), cl::Hidden);
126
126
127
- static cl::opt<bool > ConsiderLocalIntervalCost (
128
- " consider-local-interval-cost" , cl::Hidden,
129
- cl::desc (" Consider the cost of local intervals created by a split "
130
- " candidate when choosing the best split candidate." ),
131
- cl::init(false ));
132
-
133
127
static cl::opt<long > GrowRegionComplexityBudget (
134
128
" grow-region-complexity-budget" ,
135
129
cl::desc (" growRegion() does not scale with the number of BB edges, so "
@@ -996,44 +990,12 @@ bool RAGreedy::splitCanCauseEvictionChain(Register Evictee,
996
990
return true ;
997
991
}
998
992
999
- // / Check if splitting VirtRegToSplit will create a local split interval
1000
- // / in basic block number BBNumber that may cause a spill.
1001
- // /
1002
- // / \param VirtRegToSplit The register considered to be split.
1003
- // / \param Cand The split candidate that determines the physical
1004
- // / register we are splitting for and the interferences.
1005
- // / \param BBNumber The number of a BB for which the region split process
1006
- // / will create a local split interval.
1007
- // / \param Order The physical registers that may get evicted by a
1008
- // / split artifact of VirtRegToSplit.
1009
- // / \return True if splitting VirtRegToSplit may cause a spill, false
1010
- // / otherwise.
1011
- bool RAGreedy::splitCanCauseLocalSpill (unsigned VirtRegToSplit,
1012
- GlobalSplitCandidate &Cand,
1013
- unsigned BBNumber,
1014
- const AllocationOrder &Order) {
1015
- Cand.Intf .moveToBlock (BBNumber);
1016
-
1017
- // Check if the local interval will find a non interfereing assignment.
1018
- for (auto PhysReg : Order.getOrder ()) {
1019
- if (!Matrix->checkInterference (Cand.Intf .first ().getPrevIndex (),
1020
- Cand.Intf .last (), PhysReg))
1021
- return false ;
1022
- }
1023
-
1024
- // The local interval is not able to find non interferencing assignment
1025
- // and not able to evict a less worthy interval, therfore, it can cause a
1026
- // spill.
1027
- return true ;
1028
- }
1029
-
1030
993
// / calcGlobalSplitCost - Return the global split cost of following the split
1031
994
// / pattern in LiveBundles. This cost should be added to the local cost of the
1032
995
// / interference pattern in SplitConstraints.
1033
996
// /
1034
997
BlockFrequency RAGreedy::calcGlobalSplitCost (GlobalSplitCandidate &Cand,
1035
- const AllocationOrder &Order,
1036
- bool *CanCauseEvictionChain) {
998
+ const AllocationOrder &Order) {
1037
999
BlockFrequency GlobalCost = 0 ;
1038
1000
const BitVector &LiveBundles = Cand.LiveBundles ;
1039
1001
Register VirtRegToSplit = SA->getParent ().reg ();
@@ -1046,29 +1008,6 @@ BlockFrequency RAGreedy::calcGlobalSplitCost(GlobalSplitCandidate &Cand,
1046
1008
unsigned Ins = 0 ;
1047
1009
1048
1010
Cand.Intf .moveToBlock (BC.Number );
1049
- // Check wheather a local interval is going to be created during the region
1050
- // split. Calculate adavanced spilt cost (cost of local intervals) if option
1051
- // is enabled.
1052
- if (EnableAdvancedRASplitCost && Cand.Intf .hasInterference () && BI.LiveIn &&
1053
- BI.LiveOut && RegIn && RegOut) {
1054
-
1055
- if (CanCauseEvictionChain &&
1056
- splitCanCauseEvictionChain (VirtRegToSplit, Cand, BC.Number , Order)) {
1057
- // This interference causes our eviction from this assignment, we might
1058
- // evict somebody else and eventually someone will spill, add that cost.
1059
- // See splitCanCauseEvictionChain for detailed description of scenarios.
1060
- GlobalCost += SpillPlacer->getBlockFrequency (BC.Number );
1061
- GlobalCost += SpillPlacer->getBlockFrequency (BC.Number );
1062
-
1063
- *CanCauseEvictionChain = true ;
1064
-
1065
- } else if (splitCanCauseLocalSpill (VirtRegToSplit, Cand, BC.Number ,
1066
- Order)) {
1067
- // This interference causes local interval to spill, add that cost.
1068
- GlobalCost += SpillPlacer->getBlockFrequency (BC.Number );
1069
- GlobalCost += SpillPlacer->getBlockFrequency (BC.Number );
1070
- }
1071
- }
1072
1011
1073
1012
if (BI.LiveIn )
1074
1013
Ins += RegIn != (BC.Entry == SpillPlacement::PrefReg);
@@ -1089,20 +1028,6 @@ BlockFrequency RAGreedy::calcGlobalSplitCost(GlobalSplitCandidate &Cand,
1089
1028
if (Cand.Intf .hasInterference ()) {
1090
1029
GlobalCost += SpillPlacer->getBlockFrequency (Number);
1091
1030
GlobalCost += SpillPlacer->getBlockFrequency (Number);
1092
-
1093
- // Check wheather a local interval is going to be created during the
1094
- // region split.
1095
- if (EnableAdvancedRASplitCost && CanCauseEvictionChain &&
1096
- splitCanCauseEvictionChain (VirtRegToSplit, Cand, Number, Order)) {
1097
- // This interference cause our eviction from this assignment, we might
1098
- // evict somebody else, add that cost.
1099
- // See splitCanCauseEvictionChain for detailed description of
1100
- // scenarios.
1101
- GlobalCost += SpillPlacer->getBlockFrequency (Number);
1102
- GlobalCost += SpillPlacer->getBlockFrequency (Number);
1103
-
1104
- *CanCauseEvictionChain = true ;
1105
- }
1106
1031
}
1107
1032
continue ;
1108
1033
}
@@ -1285,19 +1210,8 @@ MCRegister RAGreedy::tryRegionSplit(const LiveInterval &VirtReg,
1285
1210
MBFI->printBlockFreq (dbgs (), BestCost) << ' \n ' );
1286
1211
}
1287
1212
1288
- bool CanCauseEvictionChain = false ;
1289
- unsigned BestCand =
1290
- calculateRegionSplitCost (VirtReg, Order, BestCost, NumCands,
1291
- false /* IgnoreCSR*/ , &CanCauseEvictionChain);
1292
-
1293
- // Split candidates with compact regions can cause a bad eviction sequence.
1294
- // See splitCanCauseEvictionChain for detailed description of scenarios.
1295
- // To avoid it, we need to comapre the cost with the spill cost and not the
1296
- // current max frequency.
1297
- if (HasCompact && (BestCost > SpillCost) && (BestCand != NoCand) &&
1298
- CanCauseEvictionChain) {
1299
- return MCRegister::NoRegister;
1300
- }
1213
+ unsigned BestCand = calculateRegionSplitCost (VirtReg, Order, BestCost,
1214
+ NumCands, false /* IgnoreCSR*/ );
1301
1215
1302
1216
// No solutions found, fall back to single block splitting.
1303
1217
if (!HasCompact && BestCand == NoCand)
@@ -1309,8 +1223,8 @@ MCRegister RAGreedy::tryRegionSplit(const LiveInterval &VirtReg,
1309
1223
unsigned RAGreedy::calculateRegionSplitCost (const LiveInterval &VirtReg,
1310
1224
AllocationOrder &Order,
1311
1225
BlockFrequency &BestCost,
1312
- unsigned &NumCands, bool IgnoreCSR,
1313
- bool *CanCauseEvictionChain ) {
1226
+ unsigned &NumCands,
1227
+ bool IgnoreCSR ) {
1314
1228
unsigned BestCand = NoCand;
1315
1229
for (MCPhysReg PhysReg : Order) {
1316
1230
assert (PhysReg);
@@ -1373,8 +1287,7 @@ unsigned RAGreedy::calculateRegionSplitCost(const LiveInterval &VirtReg,
1373
1287
continue ;
1374
1288
}
1375
1289
1376
- bool HasEvictionChain = false ;
1377
- Cost += calcGlobalSplitCost (Cand, Order, &HasEvictionChain);
1290
+ Cost += calcGlobalSplitCost (Cand, Order);
1378
1291
LLVM_DEBUG ({
1379
1292
dbgs () << " , total = " ;
1380
1293
MBFI->printBlockFreq (dbgs (), Cost) << " with bundles" ;
@@ -1385,24 +1298,10 @@ unsigned RAGreedy::calculateRegionSplitCost(const LiveInterval &VirtReg,
1385
1298
if (Cost < BestCost) {
1386
1299
BestCand = NumCands;
1387
1300
BestCost = Cost;
1388
- // See splitCanCauseEvictionChain for detailed description of bad
1389
- // eviction chain scenarios.
1390
- if (CanCauseEvictionChain)
1391
- *CanCauseEvictionChain = HasEvictionChain;
1392
1301
}
1393
1302
++NumCands;
1394
1303
}
1395
1304
1396
- if (CanCauseEvictionChain && BestCand != NoCand) {
1397
- // See splitCanCauseEvictionChain for detailed description of bad
1398
- // eviction chain scenarios.
1399
- LLVM_DEBUG (dbgs () << " Best split candidate of vreg "
1400
- << printReg (VirtReg.reg (), TRI) << " may " );
1401
- if (!(*CanCauseEvictionChain))
1402
- LLVM_DEBUG (dbgs () << " not " );
1403
- LLVM_DEBUG (dbgs () << " cause bad eviction chain\n " );
1404
- }
1405
-
1406
1305
return BestCand;
1407
1306
}
1408
1307
@@ -2738,11 +2637,6 @@ bool RAGreedy::runOnMachineFunction(MachineFunction &mf) {
2738
2637
TII = MF->getSubtarget ().getInstrInfo ();
2739
2638
RCI.runOnMachineFunction (mf);
2740
2639
2741
- EnableAdvancedRASplitCost =
2742
- ConsiderLocalIntervalCost.getNumOccurrences ()
2743
- ? ConsiderLocalIntervalCost
2744
- : MF->getSubtarget ().enableAdvancedRASplitCost ();
2745
-
2746
2640
if (VerifyEnabled)
2747
2641
MF->verify (this , " Before greedy register allocator" );
2748
2642
0 commit comments