llvm.org GIT mirror llvm / cc4798b
Merging r328884: ------------------------------------------------------------------------ r328884 | timshen | 2018-03-30 10:51:00 -0700 (Fri, 30 Mar 2018) | 19 lines [BlockPlacement] Disable block placement tail duplciation in structured CFG. Summary: Tail duplication easily breaks the structure of CFG, e.g. duplicating on a region entry. If the structure is intended to be preserved, then we may want to configure tail duplication, or disable it for structured CFG. From our benchmark results disabling it doesn't cause performance regression. Notice that this currently affects AMDGPU backend. In the next patch, I also plan to turn on requiresStructuredCFG for NVPTX. All unit tests still pass. Reviewers: jlebar, arsenm Subscribers: jholewinski, sanjoy, wdng, tpr, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D45008 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@333474 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 1 year, 4 months ago
1 changed file(s) with 11 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
511511 }
512512
513513 bool runOnMachineFunction(MachineFunction &F) override;
514
515 bool allowTailDupPlacement() const {
516 assert(F);
517 return TailDupPlacement && !F->getTarget().requiresStructuredCFG();
518 }
514519
515520 void getAnalysisUsage(AnalysisUsage &AU) const override {
516521 AU.addRequired();
10171022 MachineBasicBlock *Succ1 = BestA.Dest;
10181023 MachineBasicBlock *Succ2 = BestB.Dest;
10191024 // Check to see if tail-duplication would be profitable.
1020 if (TailDupPlacement && shouldTailDuplicate(Succ2) &&
1025 if (allowTailDupPlacement() && shouldTailDuplicate(Succ2) &&
10211026 canTailDuplicateUnplacedPreds(BB, Succ2, Chain, BlockFilter) &&
10221027 isProfitableToTailDup(BB, Succ2, MBPI->getEdgeProbability(BB, Succ1),
10231028 Chain, BlockFilter)) {
10431048 return Result;
10441049 }
10451050
1046 /// When the option TailDupPlacement is on, this method checks if the
1051 /// When the option allowTailDupPlacement() is on, this method checks if the
10471052 /// fallthrough candidate block \p Succ (of block \p BB) can be tail-duplicated
10481053 /// into all of its unplaced, unfiltered predecessors, that are not BB.
10491054 bool MachineBlockPlacement::canTailDuplicateUnplacedPreds(
14921497 if (hasBetterLayoutPredecessor(BB, Succ, SuccChain, SuccProb, RealSuccProb,
14931498 Chain, BlockFilter)) {
14941499 // If tail duplication would make Succ profitable, place it.
1495 if (TailDupPlacement && shouldTailDuplicate(Succ))
1500 if (allowTailDupPlacement() && shouldTailDuplicate(Succ))
14961501 DupCandidates.push_back(std::make_tuple(SuccProb, Succ));
14971502 continue;
14981503 }
17011706 auto Result = selectBestSuccessor(BB, Chain, BlockFilter);
17021707 MachineBasicBlock* BestSucc = Result.BB;
17031708 bool ShouldTailDup = Result.ShouldTailDup;
1704 if (TailDupPlacement)
1709 if (allowTailDupPlacement())
17051710 ShouldTailDup |= (BestSucc && shouldTailDuplicate(BestSucc));
17061711
17071712 // If an immediate successor isn't available, look for the best viable
17231728
17241729 // Placement may have changed tail duplication opportunities.
17251730 // Check for that now.
1726 if (TailDupPlacement && BestSucc && ShouldTailDup) {
1731 if (allowTailDupPlacement() && BestSucc && ShouldTailDup) {
17271732 // If the chosen successor was duplicated into all its predecessors,
17281733 // don't bother laying it out, just go round the loop again with BB as
17291734 // the chain end.
27572762 TailDupSize = TailDupPlacementAggressiveThreshold;
27582763 }
27592764
2760 if (TailDupPlacement) {
2765 if (allowTailDupPlacement()) {
27612766 MPDT = &getAnalysis();
27622767 if (MF.getFunction().optForSize())
27632768 TailDupSize = 1;