@@ -944,6 +944,8 @@ int LinearScanRA::linearScanRA()
944
944
eotLiveIntervals.clear ();
945
945
unsigned latestLexID = 0 ;
946
946
947
+ // Some live through intervals are implicit
948
+ calculateLiveThroughIntervals ();
947
949
for (auto bb : kernel.fg )
948
950
{
949
951
calculateLiveIntervalsGlobal (bb, globalLiveIntervals, eotLiveIntervals);
@@ -975,11 +977,15 @@ int LinearScanRA::linearScanRA()
975
977
COUT_ERROR << " ===== preAssignedLiveIntervals============" << std::endl;
976
978
printLiveIntervals (preAssignedLiveIntervals);
977
979
#endif
980
+ // Copy over alignment for vars inserted by RA
981
+ gra.copyMissingAlignment ();
982
+
978
983
PhyRegsManager pregManager (builder, initPregs, doBCR);
979
984
globalLinearScan ra (gra, &l, globalLiveIntervals, &preAssignedLiveIntervals, inputIntervals, pregManager,
980
985
mem, numRegLRA, numRowsEOT, latestLexID,
981
986
doBCR, highInternalConflict);
982
987
988
+ // Run linear scan RA
983
989
bool success = ra.runLinearScan (builder, globalLiveIntervals, spillLRs);
984
990
985
991
auto underSpillThreshold = [this ](int numSpill, int asmCount)
@@ -1055,6 +1061,29 @@ int LinearScanRA::linearScanRA()
1055
1061
COUT_ERROR << " ===== printSpillLiveIntervals============" << std::endl;
1056
1062
printSpillLiveIntervals (spillLRs);
1057
1063
#endif
1064
+ if (builder.hasScratchSurface () && !hasStackCall &&
1065
+ (nextSpillOffset + globalScratchOffset) > SCRATCH_MSG_LIMIT)
1066
+ {
1067
+ // create temp variable to store old a0.2 - this is marked as live-in and live-out.
1068
+ // because the variable is emitted only post RA to preserve old value of a0.2.
1069
+ G4_Declare * a0Dcl = kernel.fg .builder ->getOldA0Dot2Temp ();
1070
+ LSLiveRange* lr = gra.getLSLR (a0Dcl);
1071
+ if (!lr)
1072
+ {
1073
+ lr = CreateLocalLiveRange (a0Dcl);
1074
+ globalDeclares.push_back (a0Dcl);
1075
+ }
1076
+ }
1077
+ else if (gra.useLscForNonStackCallSpillFill ) {
1078
+ G4_Declare* a0Dcl = kernel.fg .builder ->getOldA0Dot2Temp ();
1079
+ LSLiveRange* lr = gra.getLSLR (a0Dcl);
1080
+ if (!lr)
1081
+ {
1082
+ lr = CreateLocalLiveRange (a0Dcl);
1083
+ globalDeclares.push_back (a0Dcl);
1084
+ }
1085
+ }
1086
+
1058
1087
1059
1088
// update jit metadata information for spill
1060
1089
if (auto jitInfo = builder.getJitInfo ())
@@ -1794,6 +1823,33 @@ void LinearScanRA::calculateLiveOutIntervals(G4_BB* bb, std::vector<LSLiveRange*
1794
1823
return ;
1795
1824
}
1796
1825
1826
+ void LinearScanRA::calculateLiveThroughIntervals ()
1827
+ {
1828
+ for (auto dcl : globalDeclares)
1829
+ {
1830
+ if (dcl->getAliasDeclare () != NULL ||
1831
+ dcl->getRegFile () == G4_INPUT ||
1832
+ dcl->isSpilled ())
1833
+ continue ;
1834
+
1835
+ LSLiveRange* lr = gra.getLSLR (dcl);
1836
+ if (lr &&
1837
+ dcl->isInput () && dcl->isOutput () && !lr->isGRFRegAssigned ())
1838
+ {
1839
+ lr->setFirstRef (nullptr , 0 );
1840
+ lr->setLastRef (nullptr , lastInstLexID * 2 + 1 );
1841
+ if (!lr->isPushedToIntervalList ())
1842
+ {
1843
+ liveThroughIntervals.push_back (lr);
1844
+ lr->setPushed (true );
1845
+ }
1846
+ }
1847
+ }
1848
+
1849
+ return ;
1850
+ }
1851
+
1852
+
1797
1853
//
1798
1854
// Live intervals:
1799
1855
// 1. not input variables
0 commit comments