Lines Matching refs:Region

544 collectRegionsConstants(OutlinableRegion &Region,  in collectRegionsConstants()  argument
549 IRSimilarityCandidate &C = *Region.Candidate; in collectRegionsConstants()
595 for (OutlinableRegion *Region : Regions) in findSameConstants()
596 collectRegionsConstants(*Region, GVNToConstant, NotSame); in findSameConstants()
856 OutlinableRegion &Region, std::vector<unsigned> &InputGVNs, in getCodeExtractorArguments() argument
859 IRSimilarityCandidate &C = *Region.Candidate; in getCodeExtractorArguments()
875 CodeExtractor *CE = Region.CE; in getCodeExtractorArguments()
877 assert(Region.StartBB && "Region must have a start BasicBlock!"); in getCodeExtractorArguments()
878 Function *OrigF = Region.StartBB->getParent(); in getCodeExtractorArguments()
885 Region.IgnoreRegion = true; in getCodeExtractorArguments()
899 Region.IgnoreRegion = true; in getCodeExtractorArguments()
926 findExtractedInputToOverallInputMapping(OutlinableRegion &Region, in findExtractedInputToOverallInputMapping() argument
930 IRSimilarityCandidate &C = *Region.Candidate; in findExtractedInputToOverallInputMapping()
931 OutlinableGroup &Group = *Region.Parent; in findExtractedInputToOverallInputMapping()
976 Region.AggArgToConstant.insert(std::make_pair(AggArgIt->second, CST)); in findExtractedInputToOverallInputMapping()
980 Region.AggArgToConstant.insert(std::make_pair(TypeIndex, CST)); in findExtractedInputToOverallInputMapping()
992 Region.ChangedArgOrder = true; in findExtractedInputToOverallInputMapping()
993 Region.ExtractedArgToAgg.insert( in findExtractedInputToOverallInputMapping()
995 Region.AggArgToExtracted.insert( in findExtractedInputToOverallInputMapping()
1000 Region.ExtractedArgToAgg.insert(std::make_pair(OriginalIndex, TypeIndex)); in findExtractedInputToOverallInputMapping()
1001 Region.AggArgToExtracted.insert(std::make_pair(TypeIndex, OriginalIndex)); in findExtractedInputToOverallInputMapping()
1016 Region.NumExtractedInputs = OriginalIndex; in findExtractedInputToOverallInputMapping()
1166 static Optional<unsigned> getGVNForPHINode(OutlinableRegion &Region, in getGVNForPHINode() argument
1170 OutlinableGroup &Group = *Region.Parent; in getGVNForPHINode()
1171 IRSimilarityCandidate &Cand = *Region.Candidate; in getGVNForPHINode()
1186 Region.IgnoreRegion = true; in getGVNForPHINode()
1268 findExtractedOutputToOverallOutputMapping(OutlinableRegion &Region, in findExtractedOutputToOverallOutputMapping() argument
1270 OutlinableGroup &Group = *Region.Parent; in findExtractedOutputToOverallOutputMapping()
1271 IRSimilarityCandidate &C = *Region.Candidate; in findExtractedOutputToOverallOutputMapping()
1295 unsigned OriginalIndex = Region.NumExtractedInputs; in findExtractedOutputToOverallOutputMapping()
1331 Region.ExtractedArgToAgg.insert(std::make_pair(OriginalIndex, Jdx)); in findExtractedOutputToOverallOutputMapping()
1332 Region.AggArgToExtracted.insert(std::make_pair(Jdx, OriginalIndex)); in findExtractedOutputToOverallOutputMapping()
1346 Region.ExtractedArgToAgg.insert( in findExtractedOutputToOverallOutputMapping()
1348 Region.AggArgToExtracted.insert( in findExtractedOutputToOverallOutputMapping()
1367 GVN = getGVNForPHINode(Region, PN, BlocksInRegion, AggArgIdx); in findExtractedOutputToOverallOutputMapping()
1381 Region.GVNStores.push_back(*GVN); in findExtractedOutputToOverallOutputMapping()
1389 stable_sort(Region.GVNStores); in findExtractedOutputToOverallOutputMapping()
1392 void IROutliner::findAddInputsOutputs(Module &M, OutlinableRegion &Region, in findAddInputsOutputs() argument
1397 getCodeExtractorArguments(Region, Inputs, NotSame, OutputMappings, ArgInputs, in findAddInputsOutputs()
1400 if (Region.IgnoreRegion) in findAddInputsOutputs()
1405 findExtractedInputToOverallInputMapping(Region, Inputs, ArgInputs); in findAddInputsOutputs()
1409 findExtractedOutputToOverallOutputMapping(Region, Outputs); in findAddInputsOutputs()
1421 CallInst *replaceCalledFunction(Module &M, OutlinableRegion &Region) { in replaceCalledFunction() argument
1425 OutlinableGroup &Group = *Region.Parent; in replaceCalledFunction()
1426 CallInst *Call = Region.Call; in replaceCalledFunction()
1435 if (!Region.ChangedArgOrder && AggFunc->arg_size() == Call->arg_size()) { in replaceCalledFunction()
1454 << Region.OutputBlockNum << "\n"); in replaceCalledFunction()
1456 Region.OutputBlockNum)); in replaceCalledFunction()
1460 ArgPair = Region.AggArgToExtracted.find(AggArgIdx); in replaceCalledFunction()
1461 if (ArgPair != Region.AggArgToExtracted.end()) { in replaceCalledFunction()
1473 if (Region.AggArgToConstant.find(AggArgIdx) != in replaceCalledFunction()
1474 Region.AggArgToConstant.end()) { in replaceCalledFunction()
1475 Constant *CST = Region.AggArgToConstant.find(AggArgIdx)->second; in replaceCalledFunction()
1500 CallInst *OldCall = Region.Call; in replaceCalledFunction()
1501 if (Region.NewFront->Inst == OldCall) in replaceCalledFunction()
1502 Region.NewFront->Inst = Call; in replaceCalledFunction()
1503 if (Region.NewBack->Inst == OldCall) in replaceCalledFunction()
1504 Region.NewBack->Inst = Call; in replaceCalledFunction()
1507 Call->setDebugLoc(Region.Call->getDebugLoc()); in replaceCalledFunction()
1514 Region.Call = Call; in replaceCalledFunction()
1587 const OutlinableRegion &Region) { in getPassedArgumentInAlreadyOutlinedFunction() argument
1591 return Region.Call->getArgOperand(A->getArgNo()); in getPassedArgumentInAlreadyOutlinedFunction()
1603 const OutlinableRegion &Region) { in getPassedArgumentAndAdjustArgumentLocation() argument
1608 if (Region.AggArgToConstant.count(ArgNum)) in getPassedArgumentAndAdjustArgumentLocation()
1609 return Region.AggArgToConstant.find(ArgNum)->second; in getPassedArgumentAndAdjustArgumentLocation()
1613 ArgNum = Region.AggArgToExtracted.find(ArgNum)->second; in getPassedArgumentAndAdjustArgumentLocation()
1614 return Region.Call->getArgOperand(ArgNum); in getPassedArgumentAndAdjustArgumentLocation()
1628 PHINode *PN, OutlinableRegion &Region, in findCanonNumsForPHI() argument
1640 IVal = getPassedArgumentInAlreadyOutlinedFunction(A, Region); in findCanonNumsForPHI()
1642 IVal = getPassedArgumentAndAdjustArgumentLocation(A, Region); in findCanonNumsForPHI()
1649 Optional<unsigned> GVN = Region.Candidate->getGVN(IVal); in findCanonNumsForPHI()
1651 Optional<unsigned> CanonNum = Region.Candidate->getCanonicalNum(*GVN); in findCanonNumsForPHI()
1671 findOrCreatePHIInBlock(PHINode &PN, OutlinableRegion &Region, in findOrCreatePHIInBlock() argument
1675 OutlinableGroup &Group = *Region.Parent; in findOrCreatePHIInBlock()
1686 findCanonNumsForPHI(&PN, Region, OutputMappings, PNCanonNums, in findOrCreatePHIInBlock()
1731 Region.findCorrespondingBlockIn(*FirstRegion, ToAdd.second); in findOrCreatePHIInBlock()
1759 Region.findCorrespondingBlockIn(*FirstRegion, IncomingBlock); in findOrCreatePHIInBlock()
1772 Value *Val = Region.findCorrespondingValueIn(*FirstRegion, IncomingVal); in findOrCreatePHIInBlock()
1793 replaceArgumentUses(OutlinableRegion &Region, in replaceArgumentUses() argument
1797 OutlinableGroup &Group = *Region.Parent; in replaceArgumentUses()
1798 assert(Region.ExtractedFunction && "Region has no extracted function?"); in replaceArgumentUses()
1800 Function *DominatingFunction = Region.ExtractedFunction; in replaceArgumentUses()
1806 for (unsigned ArgIdx = 0; ArgIdx < Region.ExtractedFunction->arg_size(); in replaceArgumentUses()
1808 assert(Region.ExtractedArgToAgg.find(ArgIdx) != in replaceArgumentUses()
1809 Region.ExtractedArgToAgg.end() && in replaceArgumentUses()
1811 unsigned AggArgIdx = Region.ExtractedArgToAgg.find(ArgIdx)->second; in replaceArgumentUses()
1813 Argument *Arg = Region.ExtractedFunction->getArg(ArgIdx); in replaceArgumentUses()
1816 if (ArgIdx < Region.NumExtractedInputs) { in replaceArgumentUses()
1818 << *Region.ExtractedFunction << " with " << *AggArg in replaceArgumentUses()
1821 Value *V = Region.Call->getArgOperand(ArgIdx); in replaceArgumentUses()
1822 Region.RemappedArguments.insert(std::make_pair(V, AggArg)); in replaceArgumentUses()
1871 Region.Candidate->getGVN(ValueOperand).has_value()) { in replaceArgumentUses()
1875 Region.findCorrespondingValueIn(*Group.Regions[0], ValueOperand); in replaceArgumentUses()
1883 if (Region.Candidate->getGVN(PN)) in replaceArgumentUses()
1888 Region.PHIBlocks.insert(std::make_pair(RetVal, PN->getParent())); in replaceArgumentUses()
1906 PHINode *NewPN = findOrCreatePHIInBlock(*PN, Region, OverallPhiBlock, in replaceArgumentUses()
1918 << *Region.ExtractedFunction << " with " << *AggArg in replaceArgumentUses()
1928 void replaceConstants(OutlinableRegion &Region) { in replaceConstants() argument
1929 OutlinableGroup &Group = *Region.Parent; in replaceConstants()
1931 for (std::pair<unsigned, Constant *> &Const : Region.AggArgToConstant) { in replaceConstants()
2017 OutlinableRegion &Region) { in analyzeAndPruneOutputBlocks() argument
2046 Region.OutputBlockNum = -1; in analyzeAndPruneOutputBlocks()
2064 OutlinableGroup &OG, OutlinableRegion &Region, in alignOutputBlockWithAggFunc() argument
2072 if (analyzeAndPruneOutputBlocks(OutputBBs, Region)) in alignOutputBlockWithAggFunc()
2083 << Region.ExtractedFunction << " to " in alignOutputBlockWithAggFunc()
2086 Region.OutputBlockNum = MatchingBB.value(); in alignOutputBlockWithAggFunc()
2092 Region.OutputBlockNum = OutputStoreBBs.size(); in alignOutputBlockWithAggFunc()
2103 << Region.ExtractedFunction << " to " in alignOutputBlockWithAggFunc()
2356 const OutlinableRegion &Region) { in isCompatibleWithAlreadyOutlinedCode() argument
2357 IRSimilarityCandidate *IRSC = Region.Candidate; in isCompatibleWithAlreadyOutlinedCode()
2369 if (!Region.Candidate->backInstruction()->isTerminator()) { in isCompatibleWithAlreadyOutlinedCode()
2371 Region.Candidate->backInstruction()->getNextNonDebugInstruction(); in isCompatibleWithAlreadyOutlinedCode()
2373 if (Region.Candidate->end()->Inst != NewEndInst) { in isCompatibleWithAlreadyOutlinedCode()
2374 IRInstructionDataList *IDL = Region.Candidate->front()->IDL; in isCompatibleWithAlreadyOutlinedCode()
2381 IDL->insert(Region.Candidate->end(), *NewEndIRID); in isCompatibleWithAlreadyOutlinedCode()
2470 for (OutlinableRegion *Region : CurrentGroup.Regions) { in findBenefitFromAllRegions()
2471 TargetTransformInfo &TTI = getTTI(*Region->StartBB->getParent()); in findBenefitFromAllRegions()
2474 RegionBenefit += Region->getBenefit(TTI); in findBenefitFromAllRegions()
2490 static Value *findOutputValueInRegion(OutlinableRegion &Region, in findOutputValueInRegion() argument
2492 OutlinableGroup &CurrentGroup = *Region.Parent; in findOutputValueInRegion()
2503 Optional<unsigned> OGVN = Region.Candidate->fromCanonicalNum(OutputCanon); in findOutputValueInRegion()
2505 Optional<Value *> OV = Region.Candidate->fromGVN(*OGVN); in findOutputValueInRegion()
2513 for (OutlinableRegion *Region : CurrentGroup.Regions) { in findCostOutputReloads()
2514 TargetTransformInfo &TTI = getTTI(*Region->StartBB->getParent()); in findCostOutputReloads()
2517 for (unsigned OutputCanon : Region->GVNStores) { in findCostOutputReloads()
2518 Value *V = findOutputValueInRegion(*Region, OutputCanon); in findCostOutputReloads()
2661 void IROutliner::updateOutputMapping(OutlinableRegion &Region, in updateOutputMapping() argument
2668 for (unsigned ArgIdx = Region.NumExtractedInputs; in updateOutputMapping()
2669 ArgIdx < Region.Call->arg_size(); ArgIdx++) { in updateOutputMapping()
2670 if (Operand == Region.Call->getArgOperand(ArgIdx)) { in updateOutputMapping()
2671 OutputIdx = ArgIdx - Region.NumExtractedInputs; in updateOutputMapping()
2693 bool IROutliner::extractSection(OutlinableRegion &Region) { in extractSection() argument
2695 assert(Region.StartBB && "StartBB for the OutlinableRegion is nullptr!"); in extractSection()
2696 BasicBlock *InitialStart = Region.StartBB; in extractSection()
2697 Function *OrigF = Region.StartBB->getParent(); in extractSection()
2699 Region.ExtractedFunction = in extractSection()
2700 Region.CE->extractCodeRegion(CEAC, ArgInputs, Outputs); in extractSection()
2704 if (!Region.ExtractedFunction) { in extractSection()
2705 LLVM_DEBUG(dbgs() << "CodeExtractor failed to outline " << Region.StartBB in extractSection()
2707 Region.reattachCandidate(); in extractSection()
2715 User *InstAsUser = Region.ExtractedFunction->user_back(); in extractSection()
2717 Region.PrevBB = RewrittenBB->getSinglePredecessor(); in extractSection()
2718 assert(Region.PrevBB && "PrevBB is nullptr?"); in extractSection()
2719 if (Region.PrevBB == InitialStart) { in extractSection()
2724 Region.PrevBB = NewPrev; in extractSection()
2728 Region.StartBB = RewrittenBB; in extractSection()
2729 Region.EndBB = RewrittenBB; in extractSection()
2736 IRInstructionDataList *IDL = Region.Candidate->front()->IDL; in extractSection()
2739 Region.NewFront = new (InstDataAllocator.Allocate()) IRInstructionData( in extractSection()
2741 Region.NewBack = new (InstDataAllocator.Allocate()) IRInstructionData( in extractSection()
2746 IDL->insert(Region.Candidate->begin(), *Region.NewFront); in extractSection()
2749 IDL->insert(Region.Candidate->end(), *Region.NewBack); in extractSection()
2751 IDL->erase(Region.Candidate->begin(), std::prev(Region.Candidate->end())); in extractSection()
2760 if (Region.ExtractedFunction == CI->getCalledFunction()) in extractSection()
2761 Region.Call = CI; in extractSection()
2763 updateOutputMapping(Region, Outputs.getArrayRef(), LI); in extractSection()
2764 Region.reattachCandidate(); in extractSection()
2874 [&R](OutlinableRegion *Region) { in doOutline() argument
2877 Region->Candidate->frontInstruction()->getDebugLoc()); in doOutline()
2901 for (OutlinableRegion *Region : CurrentGroup.Regions) { in doOutline()
2904 if (!isCompatibleWithAlreadyOutlinedCode(*Region)) in doOutline()
2906 OutlinedRegions.push_back(Region); in doOutline()
2923 for (OutlinableRegion *Region : CurrentGroup.Regions) { in doOutline()
2924 Region->splitCandidate(); in doOutline()
2925 if (!Region->CandidateSplit) in doOutline()
2927 OutlinedRegions.push_back(Region); in doOutline()
2980 [&R](OutlinableRegion *Region) { in doOutline() argument
2982 Region->Candidate->frontInstruction()->getDebugLoc()); in doOutline()