diff options
author | Max Kazantsev <mkazantsev@azul.com> | 2022-04-05 14:10:00 +0700 |
---|---|---|
committer | Max Kazantsev <mkazantsev@azul.com> | 2022-04-05 14:20:42 +0700 |
commit | 9a2798c7a36e3261ac01adb617785da8f1165767 (patch) | |
tree | dd8d79f0dd7c72b00a6e48bc5404cab72fde9b36 | |
parent | 970ae8376e53d1ecbae82d306552c5e55c913477 (diff) | |
download | llvm-9a2798c7a36e3261ac01adb617785da8f1165767.zip llvm-9a2798c7a36e3261ac01adb617785da8f1165767.tar.gz llvm-9a2798c7a36e3261ac01adb617785da8f1165767.tar.bz2 |
[CodeGen][NFC] Hoist budget check out of loop
Less computations & early exit if we know for sure that the limit will be exceeded.
-rw-r--r-- | llvm/lib/CodeGen/RegAllocGreedy.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp index 3b23a22..365dd89 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.cpp +++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp @@ -123,7 +123,7 @@ CSRFirstTimeCost("regalloc-csr-first-time-cost", cl::desc("Cost for first time use of callee-saved register."), cl::init(0), cl::Hidden); -static cl::opt<long> GrowRegionComplexityBudget( +static cl::opt<unsigned long> GrowRegionComplexityBudget( "grow-region-complexity-budget", cl::desc("growRegion() does not scale with the number of BB edges, so " "limit its budget and bail out once we reach the limit."), @@ -780,17 +780,18 @@ bool RAGreedy::growRegion(GlobalSplitCandidate &Cand) { unsigned Visited = 0; #endif - long Budget = GrowRegionComplexityBudget; + unsigned long Budget = GrowRegionComplexityBudget; while (true) { ArrayRef<unsigned> NewBundles = SpillPlacer->getRecentPositive(); // Find new through blocks in the periphery of PrefRegBundles. for (unsigned Bundle : NewBundles) { // Look at all blocks connected to Bundle in the full graph. ArrayRef<unsigned> Blocks = Bundles->getBlocks(Bundle); + // Limit compilation time by bailing out after we use all our budget. + if (Blocks.size() >= Budget) + return false; + Budget -= Blocks.size(); for (unsigned Block : Blocks) { - // Limit compilation time by bailing out after we use all our budget. - if (Budget-- == 0) - return false; if (!Todo.test(Block)) continue; Todo.reset(Block); |