Lines Matching refs:Region
293 collectRegionsConstants(OutlinableRegion &Region, in collectRegionsConstants() argument
298 IRSimilarityCandidate &C = *Region.Candidate; in collectRegionsConstants()
344 for (OutlinableRegion *Region : Regions) in findSameConstants()
345 collectRegionsConstants(*Region, GVNToConstant, NotSame); in findSameConstants()
579 OutlinableRegion &Region, std::vector<unsigned> &InputGVNs, in getCodeExtractorArguments() argument
582 IRSimilarityCandidate &C = *Region.Candidate; in getCodeExtractorArguments()
598 CodeExtractor *CE = Region.CE; in getCodeExtractorArguments()
600 assert(Region.StartBB && "Region must have a start BasicBlock!"); in getCodeExtractorArguments()
601 Function *OrigF = Region.StartBB->getParent(); in getCodeExtractorArguments()
608 Region.IgnoreRegion = true; in getCodeExtractorArguments()
622 Region.IgnoreRegion = true; in getCodeExtractorArguments()
649 findExtractedInputToOverallInputMapping(OutlinableRegion &Region, in findExtractedInputToOverallInputMapping() argument
653 IRSimilarityCandidate &C = *Region.Candidate; in findExtractedInputToOverallInputMapping()
654 OutlinableGroup &Group = *Region.Parent; in findExtractedInputToOverallInputMapping()
687 Region.AggArgToConstant.insert(std::make_pair(TypeIndex, CST)); in findExtractedInputToOverallInputMapping()
696 Region.ExtractedArgToAgg.insert(std::make_pair(OriginalIndex, TypeIndex)); in findExtractedInputToOverallInputMapping()
697 Region.AggArgToExtracted.insert(std::make_pair(TypeIndex, OriginalIndex)); in findExtractedInputToOverallInputMapping()
711 Region.NumExtractedInputs = OriginalIndex; in findExtractedInputToOverallInputMapping()
720 findExtractedOutputToOverallOutputMapping(OutlinableRegion &Region, in findExtractedOutputToOverallOutputMapping() argument
722 OutlinableGroup &Group = *Region.Parent; in findExtractedOutputToOverallOutputMapping()
723 IRSimilarityCandidate &C = *Region.Candidate; in findExtractedOutputToOverallOutputMapping()
726 unsigned OriginalIndex = Region.NumExtractedInputs; in findExtractedOutputToOverallOutputMapping()
758 Region.ExtractedArgToAgg.insert(std::make_pair(OriginalIndex, Jdx)); in findExtractedOutputToOverallOutputMapping()
759 Region.AggArgToExtracted.insert(std::make_pair(Jdx, OriginalIndex)); in findExtractedOutputToOverallOutputMapping()
760 Region.GVNStores.push_back(GlobalValue); in findExtractedOutputToOverallOutputMapping()
770 Region.ExtractedArgToAgg.insert( in findExtractedOutputToOverallOutputMapping()
772 Region.AggArgToExtracted.insert( in findExtractedOutputToOverallOutputMapping()
774 Region.GVNStores.push_back(GlobalValue); in findExtractedOutputToOverallOutputMapping()
777 stable_sort(Region.GVNStores); in findExtractedOutputToOverallOutputMapping()
783 void IROutliner::findAddInputsOutputs(Module &M, OutlinableRegion &Region, in findAddInputsOutputs() argument
788 getCodeExtractorArguments(Region, Inputs, NotSame, OutputMappings, ArgInputs, in findAddInputsOutputs()
791 if (Region.IgnoreRegion) in findAddInputsOutputs()
796 findExtractedInputToOverallInputMapping(Region, Inputs, ArgInputs); in findAddInputsOutputs()
800 findExtractedOutputToOverallOutputMapping(Region, Outputs.getArrayRef()); in findAddInputsOutputs()
812 CallInst *replaceCalledFunction(Module &M, OutlinableRegion &Region) { in replaceCalledFunction() argument
816 OutlinableGroup &Group = *Region.Parent; in replaceCalledFunction()
817 CallInst *Call = Region.Call; in replaceCalledFunction()
844 << Region.OutputBlockNum << "\n"); in replaceCalledFunction()
846 Region.OutputBlockNum)); in replaceCalledFunction()
850 ArgPair = Region.AggArgToExtracted.find(AggArgIdx); in replaceCalledFunction()
851 if (ArgPair != Region.AggArgToExtracted.end()) { in replaceCalledFunction()
863 if (Region.AggArgToConstant.find(AggArgIdx) != in replaceCalledFunction()
864 Region.AggArgToConstant.end()) { in replaceCalledFunction()
865 Constant *CST = Region.AggArgToConstant.find(AggArgIdx)->second; in replaceCalledFunction()
890 CallInst *OldCall = Region.Call; in replaceCalledFunction()
891 if (Region.NewFront->Inst == OldCall) in replaceCalledFunction()
892 Region.NewFront->Inst = Call; in replaceCalledFunction()
893 if (Region.NewBack->Inst == OldCall) in replaceCalledFunction()
894 Region.NewBack->Inst = Call; in replaceCalledFunction()
897 Call->setDebugLoc(Region.Call->getDebugLoc()); in replaceCalledFunction()
901 Region.Call = Call; in replaceCalledFunction()
918 static void replaceArgumentUses(OutlinableRegion &Region, in replaceArgumentUses() argument
920 OutlinableGroup &Group = *Region.Parent; in replaceArgumentUses()
921 assert(Region.ExtractedFunction && "Region has no extracted function?"); in replaceArgumentUses()
923 for (unsigned ArgIdx = 0; ArgIdx < Region.ExtractedFunction->arg_size(); in replaceArgumentUses()
925 assert(Region.ExtractedArgToAgg.find(ArgIdx) != in replaceArgumentUses()
926 Region.ExtractedArgToAgg.end() && in replaceArgumentUses()
928 unsigned AggArgIdx = Region.ExtractedArgToAgg.find(ArgIdx)->second; in replaceArgumentUses()
930 Argument *Arg = Region.ExtractedFunction->getArg(ArgIdx); in replaceArgumentUses()
933 if (ArgIdx < Region.NumExtractedInputs) { in replaceArgumentUses()
935 << *Region.ExtractedFunction << " with " << *AggArg in replaceArgumentUses()
956 << *Region.ExtractedFunction << " with " << *AggArg in replaceArgumentUses()
966 void replaceConstants(OutlinableRegion &Region) { in replaceConstants() argument
967 OutlinableGroup &Group = *Region.Parent; in replaceConstants()
969 for (std::pair<unsigned, Constant *> &Const : Region.AggArgToConstant) { in replaceConstants()
1077 alignOutputBlockWithAggFunc(OutlinableGroup &OG, OutlinableRegion &Region, in alignOutputBlockWithAggFunc() argument
1081 DenseSet<unsigned> ValuesToFind(Region.GVNStores.begin(), in alignOutputBlockWithAggFunc()
1082 Region.GVNStores.end()); in alignOutputBlockWithAggFunc()
1093 collectRelevantInstructions(*(Region.ExtractedFunction), ExcludeBBs); in alignOutputBlockWithAggFunc()
1106 Optional<unsigned> GVN = Region.Candidate->getGVN(V); in alignOutputBlockWithAggFunc()
1125 Region.OutputBlockNum = -1; in alignOutputBlockWithAggFunc()
1138 << Region.ExtractedFunction << " to " in alignOutputBlockWithAggFunc()
1141 Region.OutputBlockNum = MatchingBB.getValue(); in alignOutputBlockWithAggFunc()
1146 Region.OutputBlockNum = OutputStoreBBs.size(); in alignOutputBlockWithAggFunc()
1149 << Region.ExtractedFunction << " to " in alignOutputBlockWithAggFunc()
1370 for (OutlinableRegion *Region : CurrentGroup.Regions) { in findBenefitFromAllRegions()
1371 TargetTransformInfo &TTI = getTTI(*Region->StartBB->getParent()); in findBenefitFromAllRegions()
1374 RegionBenefit += Region->getBenefit(TTI); in findBenefitFromAllRegions()
1385 for (OutlinableRegion *Region : CurrentGroup.Regions) { in findCostOutputReloads()
1386 TargetTransformInfo &TTI = getTTI(*Region->StartBB->getParent()); in findCostOutputReloads()
1389 for (unsigned OutputGVN : Region->GVNStores) { in findCostOutputReloads()
1390 Optional<Value *> OV = Region->Candidate->fromGVN(OutputGVN); in findCostOutputReloads()
1516 void IROutliner::updateOutputMapping(OutlinableRegion &Region, in updateOutputMapping() argument
1523 for (unsigned ArgIdx = Region.NumExtractedInputs; in updateOutputMapping()
1524 ArgIdx < Region.Call->arg_size(); ArgIdx++) { in updateOutputMapping()
1525 if (Operand == Region.Call->getArgOperand(ArgIdx)) { in updateOutputMapping()
1526 OutputIdx = ArgIdx - Region.NumExtractedInputs; in updateOutputMapping()
1549 bool IROutliner::extractSection(OutlinableRegion &Region) { in extractSection() argument
1551 Region.CE->findInputsOutputs(ArgInputs, Outputs, SinkCands); in extractSection()
1553 assert(Region.StartBB && "StartBB for the OutlinableRegion is nullptr!"); in extractSection()
1554 assert(Region.FollowBB && "FollowBB for the OutlinableRegion is nullptr!"); in extractSection()
1555 Function *OrigF = Region.StartBB->getParent(); in extractSection()
1557 Region.ExtractedFunction = Region.CE->extractCodeRegion(CEAC); in extractSection()
1561 if (!Region.ExtractedFunction) { in extractSection()
1562 LLVM_DEBUG(dbgs() << "CodeExtractor failed to outline " << Region.StartBB in extractSection()
1564 Region.reattachCandidate(); in extractSection()
1568 BasicBlock *RewrittenBB = Region.FollowBB->getSinglePredecessor(); in extractSection()
1569 Region.StartBB = RewrittenBB; in extractSection()
1570 Region.EndBB = RewrittenBB; in extractSection()
1577 IRInstructionDataList *IDL = Region.Candidate->front()->IDL; in extractSection()
1580 Region.NewFront = new (InstDataAllocator.Allocate()) IRInstructionData( in extractSection()
1582 Region.NewBack = new (InstDataAllocator.Allocate()) IRInstructionData( in extractSection()
1587 IDL->insert(Region.Candidate->begin(), *Region.NewFront); in extractSection()
1590 IDL->insert(Region.Candidate->end(), *Region.NewBack); in extractSection()
1592 IDL->erase(Region.Candidate->begin(), std::prev(Region.Candidate->end())); in extractSection()
1601 if (Region.ExtractedFunction == CI->getCalledFunction()) in extractSection()
1602 Region.Call = CI; in extractSection()
1604 updateOutputMapping(Region, Outputs.getArrayRef(), LI); in extractSection()
1605 Region.reattachCandidate(); in extractSection()
1696 [&R](OutlinableRegion *Region) { in doOutline() argument
1699 Region->Candidate->frontInstruction()->getDebugLoc()); in doOutline()
1744 [&R](OutlinableRegion *Region) { in doOutline() argument
1746 Region->Candidate->frontInstruction()->getDebugLoc()); in doOutline()