[llvm] r278981 - Tail Duplication: Accept explicit threshold for duplicating.
Kyle Butt via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 17 14:07:36 PDT 2016
Author: iteratee
Date: Wed Aug 17 16:07:35 2016
New Revision: 278981
URL: http://llvm.org/viewvc/llvm-project?rev=278981&view=rev
Log:
Tail Duplication: Accept explicit threshold for duplicating.
This will allow tail duplication and tail merging during layout to have a
shared threshold to make sure that they don't overlap. No observable change
intended.
Modified:
llvm/trunk/include/llvm/CodeGen/TailDuplicator.h
llvm/trunk/lib/CodeGen/TailDuplicator.cpp
Modified: llvm/trunk/include/llvm/CodeGen/TailDuplicator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TailDuplicator.h?rev=278981&r1=278980&r2=278981&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/TailDuplicator.h (original)
+++ llvm/trunk/include/llvm/CodeGen/TailDuplicator.h Wed Aug 17 16:07:35 2016
@@ -34,6 +34,7 @@ class TailDuplicator {
const MachineModuleInfo *MMI;
MachineRegisterInfo *MRI;
bool PreRegAlloc;
+ unsigned TailDupSize;
// A list of virtual registers for which to update SSA form.
SmallVector<unsigned, 16> SSAUpdateVRs;
@@ -45,8 +46,11 @@ class TailDuplicator {
DenseMap<unsigned, AvailableValsTy> SSAUpdateVals;
public:
+ /// Prepare to run on a specific machine function.
+ /// @param TailDupSize - Maxmimum size of blocks to tail-duplicate.
void initMF(MachineFunction &MF, const MachineModuleInfo *MMI,
- const MachineBranchProbabilityInfo *MBPI);
+ const MachineBranchProbabilityInfo *MBPI,
+ unsigned TailDupSize = 0);
bool tailDuplicateBlocks(MachineFunction &MF);
static bool isSimpleBB(MachineBasicBlock *TailBB);
bool shouldTailDuplicate(const MachineFunction &MF, bool IsSimple,
Modified: llvm/trunk/lib/CodeGen/TailDuplicator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplicator.cpp?rev=278981&r1=278980&r2=278981&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TailDuplicator.cpp (original)
+++ llvm/trunk/lib/CodeGen/TailDuplicator.cpp Wed Aug 17 16:07:35 2016
@@ -57,12 +57,14 @@ static cl::opt<unsigned> TailDupLimit("t
namespace llvm {
void TailDuplicator::initMF(MachineFunction &MF, const MachineModuleInfo *MMIin,
- const MachineBranchProbabilityInfo *MBPIin) {
+ const MachineBranchProbabilityInfo *MBPIin,
+ unsigned TailDupSizeIn) {
TII = MF.getSubtarget().getInstrInfo();
TRI = MF.getSubtarget().getRegisterInfo();
MRI = &MF.getRegInfo();
MMI = MMIin;
MBPI = MBPIin;
+ TailDupSize = TailDupSizeIn;
assert(MBPI != nullptr && "Machine Branch Probability Info required");
@@ -511,12 +513,14 @@ bool TailDuplicator::shouldTailDuplicate
// duplicate only one, because one branch instruction can be eliminated to
// compensate for the duplication.
unsigned MaxDuplicateCount;
- if (TailDuplicateSize.getNumOccurrences() == 0 &&
- // FIXME: Use Function::optForSize().
+ if (TailDupSize == 0 &&
+ TailDuplicateSize.getNumOccurrences() == 0 &&
MF.getFunction()->optForSize())
MaxDuplicateCount = 1;
- else
+ else if (TailDupSize == 0)
MaxDuplicateCount = TailDuplicateSize;
+ else
+ MaxDuplicateCount = TailDupSize;
// If the block to be duplicated ends in an unanalyzable fallthrough, don't
// duplicate it.
More information about the llvm-commits
mailing list