summaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2014-03-21 21:46:24 +0000
committerManman Ren <manman.ren@gmail.com>2014-03-21 21:46:24 +0000
commit8dbd561a886fee0ab8565567bfef6b518769e87f (patch)
tree1c4f1cbc518f80bf0c7ca9bd6c218dc51968201f /lib/CodeGen
parentc1011e635c114962452c60da197294080e5dfe2c (diff)
downloadllvm-8dbd561a886fee0ab8565567bfef6b518769e87f.tar.gz
llvm-8dbd561a886fee0ab8565567bfef6b518769e87f.tar.bz2
llvm-8dbd561a886fee0ab8565567bfef6b518769e87f.tar.xz
Register allocator: add condition to hoist a spill to outer loop.
We make sure a spill is not hoisted to a hotter outer loop by adding a condition. Hoist a spill to outer loop if there are multiple dependents (it can be beneficial if more than one dependents are hoisted) or if DepSV (the hoisting source) is hotter than SV (the hoisting destination). rdar://16268194 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204522 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/InlineSpiller.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/CodeGen/InlineSpiller.cpp b/lib/CodeGen/InlineSpiller.cpp
index 64211c8d31..0f7ba8e01e 100644
--- a/lib/CodeGen/InlineSpiller.cpp
+++ b/lib/CodeGen/InlineSpiller.cpp
@@ -22,6 +22,7 @@
#include "llvm/CodeGen/LiveRangeEdit.h"
#include "llvm/CodeGen/LiveStackAnalysis.h"
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
+#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
@@ -440,7 +441,20 @@ void InlineSpiller::propagateSiblingValue(SibValueMap::iterator SVIIter,
// Also hoist spills to blocks with smaller loop depth, but make sure
// that the new value dominates. Non-phi dependents are always
// dominated, phis need checking.
+
+ const BranchProbability MarginProb(4, 5); // 80%
+ // Hoist a spill to outer loop if there are multiple dependents (it
+ // can be beneficial if more than one dependents are hoisted) or
+ // if DepSV (the hoisting source) is hotter than SV (the hoisting
+ // destination) (we add a 80% margin to bias a little towards
+ // loop depth).
+ bool HoistCondition =
+ (MBFI.getBlockFreq(DepSV.SpillMBB) >=
+ (MBFI.getBlockFreq(SV.SpillMBB) * MarginProb)) ||
+ Deps->size() > 1;
+
if ((Loops.getLoopDepth(DepSV.SpillMBB) > SpillDepth) &&
+ HoistCondition &&
(!DepSVI->first->isPHIDef() ||
MDT.dominates(SV.SpillMBB, DepSV.SpillMBB))) {
Changed = true;