diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-02-14 23:15:38 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-02-14 23:15:38 +0000 |
commit | eb9f040f0d07e2fa9b3b5ef46d5ee32511d28811 (patch) | |
tree | e77cb754983e5b09c8b79a17de979b916cae617c /include/llvm/CodeGen/CalcSpillWeights.h | |
parent | 3fc178ffdad0c3359f8e4bad084556a3054e1ed2 (diff) | |
download | external_llvm-eb9f040f0d07e2fa9b3b5ef46d5ee32511d28811.zip external_llvm-eb9f040f0d07e2fa9b3b5ef46d5ee32511d28811.tar.gz external_llvm-eb9f040f0d07e2fa9b3b5ef46d5ee32511d28811.tar.bz2 |
Move more fragments of spill weight calculation into CalcSpillWeights.h
Simplify the spill weight calculation a bit by bypassing
getApproximateInstructionCount() and using LiveInterval::getSize() directly.
This changes the computed spill weights, but only by a constant factor in each
function. It should not affect how spill weights compare against each other, and
so it shouldn't affect code generation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125530 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/CalcSpillWeights.h')
-rw-r--r-- | include/llvm/CodeGen/CalcSpillWeights.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/CalcSpillWeights.h b/include/llvm/CodeGen/CalcSpillWeights.h index 24264d7..853ebf9 100644 --- a/include/llvm/CodeGen/CalcSpillWeights.h +++ b/include/llvm/CodeGen/CalcSpillWeights.h @@ -20,6 +20,26 @@ namespace llvm { class LiveIntervals; class MachineLoopInfo; + /// normalizeSpillWeight - The spill weight of a live interval is computed as: + /// + /// (sum(use freq) + sum(def freq)) / (K + size) + /// + /// @param UseDefFreq Expected number of executed use and def instructions + /// per function call. Derived from block frequencies. + /// @param Size Size of live interval as returnexd by getSize() + /// + static inline float normalizeSpillWeight(float UseDefFreq, unsigned Size) { + // The magic constant 200 corresponds to approx. 25 instructions since + // SlotIndexes allocate 8 slots per instruction. + // + // The constant is added to avoid depending too much on accidental SlotIndex + // gaps for small intervals. The effect is that small intervals have a spill + // weight that is mostly proportional to the number of uses, while large + // intervals get a spill weight that is closer to a use density. + // + return UseDefFreq / (Size + 200); + } + /// VirtRegAuxInfo - Calculate auxiliary information for a virtual /// register such as its spill weight and allocation hint. class VirtRegAuxInfo { |