@@ -1053,58 +1053,21 @@ void emitDataVarLiveInterval(VISAKernelImpl* visaKernel, LiveIntervalInfo* lrInf
10531053 }
10541054}
10551055
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-
10881056void populateUniqueSubs (G4_Kernel* kernel, std::unordered_map<G4_BB*, bool >& uniqueSubs)
10891057{
10901058 // Traverse kernel and populate all unique subs.
10911059 // Iterating over all BBs of kernel visits all
10921060 // subroutine call sites.
1093- auto isStackObj = kernel->fg .getHasStackCalls () || kernel->fg .getIsStackCallFunc ();
10941061 for (auto bb : kernel->fg )
10951062 {
10961063 if (&bb->getParent () != &kernel->fg )
10971064 continue ;
10981065
1099- if (bb->isEndWithCall ())
1066+ if (bb->isEndWithCall () &&
1067+ !kernel->getKernelDebugInfo ()->isFcallWithSaveRestore (bb))
11001068 {
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- }
1069+ // This is a subroutine call
1070+ uniqueSubs[bb->Succs .front ()] = false ;
11081071 }
11091072 }
11101073}
@@ -1242,16 +1205,16 @@ void SaveRestoreManager::sieveInstructions(CallerOrCallee c)
12421205 // Remove temp movs emitted for send header
12431206 // creation since they are not technically
12441207 // caller save
1245- if (entry.first < visaKernel-> getKernel ()-> calleeSaveStart () &&
1246- entry.first >= 0 &&
1208+ if (entry.first < CALLEE_SAVE_START &&
1209+ entry.first >= CALLER_SAVE_START &&
12471210 entry.second .first == SaveRestoreInfo::RegOrMem::MemOffBEFP)
12481211 {
12491212 removeEntry = false ;
12501213 }
12511214 }
12521215 else if (c == CallerOrCallee::Callee)
12531216 {
1254- if (entry.first >= visaKernel-> getKernel ()-> calleeSaveStart () &&
1217+ if (entry.first >= CALLEE_SAVE_START &&
12551218 entry.second .first == SaveRestoreInfo::RegOrMem::MemOffBEFP)
12561219 {
12571220 removeEntry = false ;
@@ -1445,7 +1408,7 @@ void emitDataCallFrameInfo(VISAKernelImpl* visaKernel, T& t)
14451408 if (befpLIInfo)
14461409 {
14471410 emitDataUInt8 ((uint8_t )1 , t);
1448- uint32_t idx = kernel->getKernelDebugInfo ()->getVarIndex (kernel-> fg . framePtrDcl );
1411+ uint32_t idx = kernel->getKernelDebugInfo ()->getVarIndex (befpDcl );
14491412 emitDataVarLiveInterval (visaKernel, befpLIInfo, idx, sizeof (uint32_t ), t);
14501413 }
14511414 else
@@ -1465,8 +1428,8 @@ void emitDataCallFrameInfo(VISAKernelImpl* visaKernel, T& t)
14651428 if (callerfpLIInfo)
14661429 {
14671430 emitDataUInt8 ((uint8_t )1 , t);
1468- // Caller's be_fp is stored in frame descriptor
1469- emitFrameDescriptorOffsetLiveInterval ( callerfpLIInfo, StackCall::FrameDescriptorOfsets::BE_FP , t);
1431+ uint32_t idx = kernel-> getKernelDebugInfo ()-> getVarIndex (callerfpdcl);
1432+ emitDataVarLiveInterval (visaKernel, callerfpLIInfo, idx, sizeof ( uint32_t ) , t);
14701433 }
14711434 else
14721435 {
@@ -1485,7 +1448,8 @@ void emitDataCallFrameInfo(VISAKernelImpl* visaKernel, T& t)
14851448 if (fretVarLIInfo)
14861449 {
14871450 emitDataUInt8 ((uint8_t )1 , t);
1488- emitFrameDescriptorOffsetLiveInterval (fretVarLIInfo, StackCall::FrameDescriptorOfsets::Ret_IP, t);
1451+ uint32_t idx = kernel->getKernelDebugInfo ()->getVarIndex (fretVar);
1452+ emitDataVarLiveInterval (visaKernel, fretVarLIInfo, idx, sizeof (uint32_t ), t);
14891453 }
14901454 else
14911455 {
@@ -1970,29 +1934,6 @@ void KernelDebugInfo::computeDebugInfo(std::list<G4_BB*>& stackCallEntryBBs)
19701934 {
19711935 updateCallStackLiveIntervals ();
19721936 }
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- }
19961937}
19971938
19981939void KernelDebugInfo::updateCallStackLiveIntervals ()
@@ -2023,30 +1964,24 @@ void KernelDebugInfo::updateCallStackLiveIntervals()
20231964 {
20241965 reloc_offset = (reloc_offset == 0 ) ?
20251966 (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 ();
20261974 break ;
20271975 }
20281976 }
2029- if (reloc_offset > 0 )
1977+ if (end > 0 )
1978+ {
20301979 break ;
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 ();
1980+ }
20441981 }
20451982
20461983 MUST_BE_TRUE (end >= reloc_offset, " Failed to update live-interval for retval" );
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++)
1984+ for (uint32_t i = 0 ; i <= end - reloc_offset; i++)
20501985 {
20511986 updateDebugInfo (*kernel, fretVar, i);
20521987 }
0 commit comments