@@ -1053,21 +1053,58 @@ void emitDataVarLiveInterval(VISAKernelImpl* visaKernel, LiveIntervalInfo* lrInf
1053
1053
}
1054
1054
}
1055
1055
1056
+ template <class T >
1057
+ void emitFrameDescriptorOffsetLiveInterval (LiveIntervalInfo* lrInfo, StackCall::FrameDescriptorOfsets memOffset, T& t)
1058
+ {
1059
+ // Used to emit fields of Frame Descriptor
1060
+ // location = [start, end) @ BE_FP+offset
1061
+ std::vector<std::pair<uint32_t , uint32_t >> lrs;
1062
+ if (lrInfo)
1063
+ lrInfo->getLiveIntervals (lrs);
1064
+ else
1065
+ return ;
1066
+
1067
+ uint32_t start = 0 , end = 0 ;
1068
+ if (lrs.size () > 0 )
1069
+ {
1070
+ start = lrs.front ().first ;
1071
+ end = lrs.back ().second ;
1072
+ }
1073
+
1074
+ std::sort (lrs.begin (), lrs.end (), [](std::pair<uint32_t , uint32_t >& a, std::pair<uint32_t , uint32_t >& b) { return a.first < b.first ; });
1075
+
1076
+ emitDataUInt16 (1 , t);
1077
+
1078
+ emitDataUInt32 (start, t);
1079
+ emitDataUInt32 (end, t);
1080
+
1081
+ emitDataUInt8 ((uint8_t )VARMAP_PREG_FILE_GRF, t);
1082
+
1083
+ emitDataUInt8 ((uint8_t )VARMAP_PREG_FILE_MEMORY, t);
1084
+
1085
+ emitDataUInt32 ((uint32_t )memOffset, t);
1086
+ }
1087
+
1056
1088
void populateUniqueSubs (G4_Kernel* kernel, std::unordered_map<G4_BB*, bool >& uniqueSubs)
1057
1089
{
1058
1090
// Traverse kernel and populate all unique subs.
1059
1091
// Iterating over all BBs of kernel visits all
1060
1092
// subroutine call sites.
1093
+ auto isStackObj = kernel->fg .getHasStackCalls () || kernel->fg .getIsStackCallFunc ();
1061
1094
for (auto bb : kernel->fg )
1062
1095
{
1063
1096
if (&bb->getParent () != &kernel->fg )
1064
1097
continue ;
1065
1098
1066
- if (bb->isEndWithCall () &&
1067
- !kernel->getKernelDebugInfo ()->isFcallWithSaveRestore (bb))
1099
+ if (bb->isEndWithCall ())
1068
1100
{
1069
- // This is a subroutine call
1070
- uniqueSubs[bb->Succs .front ()] = false ;
1101
+ if (!isStackObj || // definitely a subroutine since kernel has no stack calls
1102
+ (isStackObj && // a subroutine iff call dst != pre-defined reg as per ABI
1103
+ bb->back ()->getDst ()->getTopDcl ()->getRegVar ()->getPhyReg ()->asGreg ()->getRegNum () != kernel->getFPSPGRF ()))
1104
+ {
1105
+ // This is a subroutine call
1106
+ uniqueSubs[bb->Succs .front ()] = false ;
1107
+ }
1071
1108
}
1072
1109
}
1073
1110
}
@@ -1205,16 +1242,16 @@ void SaveRestoreManager::sieveInstructions(CallerOrCallee c)
1205
1242
// Remove temp movs emitted for send header
1206
1243
// creation since they are not technically
1207
1244
// caller save
1208
- if (entry.first < CALLEE_SAVE_START &&
1209
- entry.first >= CALLER_SAVE_START &&
1245
+ if (entry.first < visaKernel-> getKernel ()-> calleeSaveStart () &&
1246
+ entry.first >= 0 &&
1210
1247
entry.second .first == SaveRestoreInfo::RegOrMem::MemOffBEFP)
1211
1248
{
1212
1249
removeEntry = false ;
1213
1250
}
1214
1251
}
1215
1252
else if (c == CallerOrCallee::Callee)
1216
1253
{
1217
- if (entry.first >= CALLEE_SAVE_START &&
1254
+ if (entry.first >= visaKernel-> getKernel ()-> calleeSaveStart () &&
1218
1255
entry.second .first == SaveRestoreInfo::RegOrMem::MemOffBEFP)
1219
1256
{
1220
1257
removeEntry = false ;
@@ -1408,7 +1445,7 @@ void emitDataCallFrameInfo(VISAKernelImpl* visaKernel, T& t)
1408
1445
if (befpLIInfo)
1409
1446
{
1410
1447
emitDataUInt8 ((uint8_t )1 , t);
1411
- uint32_t idx = kernel->getKernelDebugInfo ()->getVarIndex (befpDcl );
1448
+ uint32_t idx = kernel->getKernelDebugInfo ()->getVarIndex (kernel-> fg . framePtrDcl );
1412
1449
emitDataVarLiveInterval (visaKernel, befpLIInfo, idx, sizeof (uint32_t ), t);
1413
1450
}
1414
1451
else
@@ -1428,8 +1465,8 @@ void emitDataCallFrameInfo(VISAKernelImpl* visaKernel, T& t)
1428
1465
if (callerfpLIInfo)
1429
1466
{
1430
1467
emitDataUInt8 ((uint8_t )1 , t);
1431
- uint32_t idx = kernel-> getKernelDebugInfo ()-> getVarIndex (callerfpdcl);
1432
- emitDataVarLiveInterval (visaKernel, callerfpLIInfo, idx, sizeof ( uint32_t ) , t);
1468
+ // Caller's be_fp is stored in frame descriptor
1469
+ emitFrameDescriptorOffsetLiveInterval ( callerfpLIInfo, StackCall::FrameDescriptorOfsets::BE_FP , t);
1433
1470
}
1434
1471
else
1435
1472
{
@@ -1448,8 +1485,7 @@ void emitDataCallFrameInfo(VISAKernelImpl* visaKernel, T& t)
1448
1485
if (fretVarLIInfo)
1449
1486
{
1450
1487
emitDataUInt8 ((uint8_t )1 , t);
1451
- uint32_t idx = kernel->getKernelDebugInfo ()->getVarIndex (fretVar);
1452
- emitDataVarLiveInterval (visaKernel, fretVarLIInfo, idx, sizeof (uint32_t ), t);
1488
+ emitFrameDescriptorOffsetLiveInterval (fretVarLIInfo, StackCall::FrameDescriptorOfsets::Ret_IP, t);
1453
1489
}
1454
1490
else
1455
1491
{
@@ -1934,6 +1970,29 @@ void KernelDebugInfo::computeDebugInfo(std::list<G4_BB*>& stackCallEntryBBs)
1934
1970
{
1935
1971
updateCallStackLiveIntervals ();
1936
1972
}
1973
+ else
1974
+ {
1975
+ updateCallStackMain ();
1976
+ }
1977
+ }
1978
+
1979
+ void KernelDebugInfo::updateCallStackMain ()
1980
+ {
1981
+ if (!getKernel ().fg .getHasStackCalls ())
1982
+ return ;
1983
+
1984
+ // Set live-interval for BE_FP
1985
+ auto befp = getBEFP ();
1986
+ if (befp)
1987
+ {
1988
+ uint32_t start = 0 ;
1989
+ if (getBEFPSetupInst ())
1990
+ {
1991
+ start = (uint32_t )getBEFPSetupInst ()->getGenOffset () +
1992
+ (uint32_t )getBinInstSize (getBEFPSetupInst ());
1993
+ }
1994
+ updateDebugInfo (getKernel (), befp, start, mapCISAIndexGenOffset.back ().second );
1995
+ }
1937
1996
}
1938
1997
1939
1998
void KernelDebugInfo::updateCallStackLiveIntervals ()
@@ -1964,24 +2023,30 @@ void KernelDebugInfo::updateCallStackLiveIntervals()
1964
2023
{
1965
2024
reloc_offset = (reloc_offset == 0 ) ?
1966
2025
(uint32_t )insts->getGenOffset () : reloc_offset;
1967
- }
1968
-
1969
- if ((insts->isReturn () || insts->opcode () == G4_jmpi) &&
1970
- insts->getSrc (0 )->asSrcRegRegion ()->getBase ()->asRegVar ()->getDeclare ()->getRootDeclare ()
1971
- == fretVar)
1972
- {
1973
- end = (uint32_t )insts->getGenOffset ();
1974
2026
break ;
1975
2027
}
1976
2028
}
1977
- if (end > 0 )
1978
- {
2029
+ if (reloc_offset > 0 )
1979
2030
break ;
1980
- }
2031
+ }
2032
+
2033
+ uint32_t start = 0 ;
2034
+ if (getBEFPSetupInst ())
2035
+ {
2036
+ // Frame descriptor can be addressed once once BE_FP is defined
2037
+ start = (uint32_t )getBEFPSetupInst ()->getGenOffset () +
2038
+ getBinInstSize (getBEFPSetupInst ());
2039
+ }
2040
+
2041
+ if (getCallerBEFPRestoreInst ())
2042
+ {
2043
+ end = (uint32_t )getCallerBEFPRestoreInst ()->getGenOffset ();
1981
2044
}
1982
2045
1983
2046
MUST_BE_TRUE (end >= reloc_offset, " Failed to update live-interval for retval" );
1984
- for (uint32_t i = 0 ; i <= end - reloc_offset; i++)
2047
+ MUST_BE_TRUE (start >= reloc_offset, " Failed to update start for retval" );
2048
+ MUST_BE_TRUE (end >= start, " end less then start for retval" );
2049
+ for (uint32_t i = start - reloc_offset; i <= end - reloc_offset; i++)
1985
2050
{
1986
2051
updateDebugInfo (*kernel, fretVar, i);
1987
2052
}
0 commit comments