Changeset 4014 in CLRX


Ignore:
Timestamp:
Apr 17, 2018, 4:29:33 PM (6 months ago)
Author:
matszpk
Message:

CLRadeonExtender: AsmRegAlloc?: Avoid reinitializing/copying whole flowStackBlocks array while executing createRoutineData.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/amdasm/AsmRegAllocSSAData.cpp

    r4013 r4014  
    978978        SimpleCache<BlockIndex, RoutineData>& subroutinesCache,
    979979        const RoutineMap& routineMap, RoutineData& rdata,
    980         BlockIndex routineBlock, bool noMainLoop = false,
    981         const CBlockBitPool& prevFlowStackBlocks = {})
    982 {
     980        BlockIndex routineBlock, CBlockBitPool& prevFlowStackBlocks,
     981        CBlockBitPool& flowStackBlocks, bool noMainLoop = false)
     982{
     983    bool fromSubroutine = noMainLoop;
    983984    ARDOut << "--------- createRoutineData ----------------\n";
    984985    CBlockBitPool visited(codeBlocks.size(), false);
     
    990991    RoutineMap subrDataForLoopMap;
    991992    std::deque<FlowStackEntry> flowStack;
    992     CBlockBitPool flowStackBlocks(codeBlocks.size(), false);
    993     if (!prevFlowStackBlocks.empty())
    994         flowStackBlocks = prevFlowStackBlocks;
     993    //CBlockBitPool flowStackBlocks(codeBlocks.size(), false);
     994    //if (!prevFlowStackBlocks.empty())
     995        //flowStackBlocks = prevFlowStackBlocks;
    995996    // last SSA ids map from returns
    996997    RetSSAIdMap retSSAIdMap;
    997998    flowStack.push_back({ routineBlock, 0 });
    998     flowStackBlocks[routineBlock] = true;
     999    if (!fromSubroutine)
     1000        flowStackBlocks[routineBlock] = true;
    9991001   
    10001002    while (!flowStack.empty())
     
    10221024           
    10231025            RoutineData subrData;
    1024             const bool oldFB = flowStackBlocks[entry.blockIndex];
    1025             flowStackBlocks[entry.blockIndex] = !oldFB;
     1026            bool oldFB = false;
     1027            if (!fromSubroutine)
     1028            {
     1029                oldFB = flowStackBlocks[entry.blockIndex];
     1030                flowStackBlocks[entry.blockIndex] = !oldFB;
     1031            }
    10261032            createRoutineData(codeBlocks, curSSAIdMap, loopBlocks, callBlocks,
    10271033                    subroutToCache, subroutinesCache, routineMap, subrData,
    1028                     entry.blockIndex, true, flowStackBlocks);
     1034                    entry.blockIndex, flowStackBlocks, flowStackBlocks, true);
    10291035            RoutineData subrDataCopy;
    1030             flowStackBlocks[entry.blockIndex] = oldFB;
     1036            if (!fromSubroutine)
     1037                flowStackBlocks[entry.blockIndex] = oldFB;
    10311038           
    10321039            if (loopBlocks.find(entry.blockIndex) != loopBlocks.end())
     
    11021109                tryAddLoopEnd(entry, routineBlock, rdata, isLoop, noMainLoop);
    11031110               
    1104                 flowStackBlocks[entry.blockIndex] = !flowStackBlocks[entry.blockIndex];
     1111                if (!fromSubroutine)
     1112                    flowStackBlocks[entry.blockIndex] = !flowStackBlocks[entry.blockIndex];
    11051113                flowStack.pop_back();
    11061114                continue;
     
    11381146                    // no joining. no returns
    11391147                    ARDOut << "procretend2 nojoin\n";
    1140                     flowStackBlocks[entry.blockIndex] = !flowStackBlocks[entry.blockIndex];
     1148                    if (!fromSubroutine)
     1149                        flowStackBlocks[entry.blockIndex] =
     1150                                    !flowStackBlocks[entry.blockIndex];
    11411151                    flowStack.pop_back();
    11421152                    continue;
     
    11701180                }
    11711181                ARDOut << "procretend2\n";
    1172                 flowStackBlocks[entry.blockIndex] = !flowStackBlocks[entry.blockIndex];
     1182                if (!fromSubroutine)
     1183                    flowStackBlocks[entry.blockIndex] = !flowStackBlocks[entry.blockIndex];
    11731184                flowStack.pop_back();
    11741185                // propagate haveReturn to previous block
     
    12101221            {
    12111222                tryAddLoopEnd(entry, routineBlock, rdata, isLoop, noMainLoop);
    1212                 flowStackBlocks[entry.blockIndex] = !flowStackBlocks[entry.blockIndex];
     1223                if (!fromSubroutine)
     1224                    flowStackBlocks[entry.blockIndex] = !flowStackBlocks[entry.blockIndex];
    12131225                flowStack.pop_back();
    12141226                continue;
     
    12771289            flowStack.push_back({ nextBlock, 0 });
    12781290            // negate - if true (already in flowstack, then popping keep this state)
    1279             flowStackBlocks[nextBlock] = !flowStackBlocks[nextBlock];
     1291            if (!fromSubroutine)
     1292                flowStackBlocks[nextBlock] = !flowStackBlocks[nextBlock];
    12801293            entry.nextIndex++;
    12811294        }
     
    13041317            flowStack.push_back({ nextBlock, 0 });
    13051318            // negate - if true (already in flowstack, then popping keep this state)
    1306             flowStackBlocks[nextBlock] = !flowStackBlocks[nextBlock];
     1319            if (!fromSubroutine)
     1320                flowStackBlocks[nextBlock] = !flowStackBlocks[nextBlock];
    13071321            entry.nextIndex++;
    13081322        }
     
    13661380            }
    13671381           
    1368             flowStackBlocks[entry.blockIndex] = false;
     1382            if (!fromSubroutine)
     1383                flowStackBlocks[entry.blockIndex] = false;
    13691384            ARDOut << "pop: " << entry.blockIndex << "\n";
    13701385           
     
    13791394        }
    13801395    }
     1396   
     1397    /*if (prevFlowStackBlocks.empty())
     1398        assert(std::find(flowStackBlocks.begin(), flowStackBlocks.end(), true)
     1399                    == flowStackBlocks.end());
     1400    else
     1401        assert(flowStackBlocks == prevFlowStackBlocks);*/
    13811402    ARDOut << "--------- createRoutineData end ------------\n";
    13821403}
     
    14701491    CBlockBitPool waysToCache(codeBlocks.size(), false);
    14711492    CBlockBitPool flowStackBlocks(codeBlocks.size(), false);
     1493   
     1494    CBlockBitPool prevCallFlowStackBlocks;
     1495    CBlockBitPool callFlowStackBlocks(codeBlocks.size(), false);
    14721496    // subroutToCache - true if given block begin subroutine to cache
    14731497    ResSecondPointsToCache cblocksToCache(codeBlocks.size());
     
    15961620                createRoutineData(codeBlocks, curSSAIdMap, loopBlocks, callBlocks,
    15971621                            cblocksToCache, subroutinesCache, routineMap, prevRdata,
    1598                             routineBlock);
     1622                            routineBlock, prevCallFlowStackBlocks, callFlowStackBlocks);
    15991623                isRoutineGen[routineBlock] = true;
    16001624               
Note: See TracChangeset for help on using the changeset viewer.