@@ -14,8 +14,6 @@ SPDX-License-Identifier: MIT
1414#include " SpillManagerGMRF.h"
1515#include " common.h"
1616#include < optional>
17- #include < fstream>
18- #include < tuple>
1917
2018using namespace vISA ;
2119
@@ -45,10 +43,15 @@ void LinearScanRA::allocForbiddenVector(LSLiveRange *lr) {
4543}
4644
4745void globalLinearScan::allocRetRegsVector (LSLiveRange *lr) {
48- unsigned size = builder.kernel .getNumRegTotal ();
49- bool *forbidden = (bool *)GLSMem.alloc (sizeof (bool ) * size);
50- memset (forbidden, false , size);
51- lr->setRegGRFs (forbidden);
46+ auto size = builder.kernel .getNumRegTotal ();
47+ if (lr->getRetGRFs () == nullptr ) {
48+ bool *forbidden = (bool *)GLSMem->alloc (sizeof (bool ) * size);
49+ memset (forbidden, false , size);
50+ lr->setRegGRFs (forbidden);
51+ } else {
52+ // If we are vector is preallocated, simply clear it
53+ lr->clearRetGRF (size);
54+ }
5255}
5356
5457LSLiveRange *LinearScanRA::GetOrCreateLocalLiveRange (G4_Declare *topdcl) {
@@ -865,7 +868,7 @@ int LinearScanRA::linearScanRA() {
865868 PhyRegsManager pregManager (builder, initPregs, doBCR);
866869 globalLinearScan ra (gra, &l, globalLiveIntervals, &preAssignedLiveIntervals,
867870 inputIntervals, pregManager, numRegLRA, numRowsEOT,
868- latestLexID, doBCR, highInternalConflict);
871+ latestLexID, doBCR, highInternalConflict, &LSMem );
869872
870873 // Run linear scan RA
871874 bool success = ra.runLinearScan (builder, globalLiveIntervals, spillLRs);
@@ -1783,8 +1786,8 @@ globalLinearScan::globalLinearScan(
17831786 std::list<LSInputLiveRange *, std_arena_based_allocator<LSInputLiveRange *>>
17841787 &inputLivelIntervals,
17851788 PhyRegsManager &pregMgr, unsigned int numReg, unsigned int numEOT,
1786- unsigned int lastLexID, bool bankConflict, bool internalConflict)
1787- : gra(g), builder(g.builder), GLSMem(4096 ), pregManager(pregMgr),
1789+ unsigned int lastLexID, bool bankConflict, bool internalConflict, Mem_Manager* GLSMem )
1790+ : gra(g), builder(g.builder), GLSMem(GLSMem ), pregManager(pregMgr),
17881791 liveIntervals(lv), preAssignedIntervals(assignedLiveIntervals),
17891792 inputIntervals(inputLivelIntervals), numRowsEOT(numEOT),
17901793 lastLexicalID(lastLexID), numRegLRA(numReg), doBankConflict(bankConflict),
@@ -1943,8 +1946,9 @@ bool globalLinearScan::runLinearScan(IR_Builder &builder,
19431946 lr->getFirstRef (idx);
19441947 if (!lr->isEOT () && !lr->getAssigned ()) {
19451948 // Add forbidden for preAssigned registers
1949+ auto isTopDclPseudoVCA = builder.kernel .fg .isPseudoVCADcl (lr->getTopDcl ());
19461950 for (auto preAssginedLI : *preAssignedIntervals) {
1947- if (builder. kernel . fg . isPseudoVCADcl (lr-> getTopDcl ()) &&
1951+ if (isTopDclPseudoVCA &&
19481952 (builder.isPreDefRet (preAssginedLI->getTopDcl ()) ||
19491953 builder.isPreDefArg (preAssginedLI->getTopDcl ()))) {
19501954 continue ;
0 commit comments