diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-03-04 00:58:40 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-03-04 00:58:40 +0000 |
commit | 40a42a2ccaaa19a109667ed7abf224cc8733cd9c (patch) | |
tree | bd0d560f032bf3734a16548983876f12367d3793 /lib/CodeGen/SpillPlacement.cpp | |
parent | 13ba2dab631636e525a44bb259aaea56a860d1c7 (diff) | |
download | llvm-40a42a2ccaaa19a109667ed7abf224cc8733cd9c.tar.gz llvm-40a42a2ccaaa19a109667ed7abf224cc8733cd9c.tar.bz2 llvm-40a42a2ccaaa19a109667ed7abf224cc8733cd9c.tar.xz |
Precompute block frequencies, pow() isn't free.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126975 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SpillPlacement.cpp')
-rw-r--r-- | lib/CodeGen/SpillPlacement.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/CodeGen/SpillPlacement.cpp b/lib/CodeGen/SpillPlacement.cpp index 9c0bf1629a..57951ed806 100644 --- a/lib/CodeGen/SpillPlacement.cpp +++ b/lib/CodeGen/SpillPlacement.cpp @@ -175,9 +175,12 @@ bool SpillPlacement::runOnMachineFunction(MachineFunction &mf) { nodes = new Node[bundles->getNumBundles()]; // Compute total ingoing and outgoing block frequencies for all bundles. + BlockFrequency.resize(mf.getNumBlockIDs()); for (MachineFunction::iterator I = mf.begin(), E = mf.end(); I != E; ++I) { - float Freq = getBlockFrequency(I); + float Freq = LiveIntervals::getSpillWeight(true, false, + loops->getLoopDepth(I)); unsigned Num = I->getNumber(); + BlockFrequency[Num] = Freq; nodes[bundles->getBundle(Num, 1)].Frequency[0] += Freq; nodes[bundles->getBundle(Num, 0)].Frequency[1] += Freq; } @@ -206,8 +209,7 @@ void SpillPlacement:: prepareNodes(const SmallVectorImpl<BlockConstraint> &LiveBlocks) { for (SmallVectorImpl<BlockConstraint>::const_iterator I = LiveBlocks.begin(), E = LiveBlocks.end(); I != E; ++I) { - MachineBasicBlock *MBB = MF->getBlockNumbered(I->Number); - float Freq = getBlockFrequency(MBB); + float Freq = getBlockFrequency(I->Number); // Is this a transparent block? Link ingoing and outgoing bundles. if (I->Entry == DontCare && I->Exit == DontCare) { @@ -320,11 +322,3 @@ SpillPlacement::placeSpills(const SmallVectorImpl<BlockConstraint> &LiveBlocks, } return Perfect; } - -/// getBlockFrequency - Return our best estimate of the block frequency which is -/// the expected number of block executions per function invocation. -float SpillPlacement::getBlockFrequency(const MachineBasicBlock *MBB) { - // Use the unnormalized spill weight for real block frequencies. - return LiveIntervals::getSpillWeight(true, false, loops->getLoopDepth(MBB)); -} - |