Rename isEarlierInSameTrace to isUsefulDominator.

In very rare cases caused by irreducible control flow, the dominating
block can have the same trace head without actually being part of the
trace.

As long as such a dominator still has valid instruction depths, it is OK
to use it for computing instruction depths.

Rename the function to avoid lying, and add a check that instruction
depths are computed for the dominator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176668 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen
2013-03-07 23:55:49 +00:00
parent 11687d4982
commit 6ffcd5efe1
2 changed files with 20 additions and 7 deletions

View File

@@ -165,12 +165,25 @@ public:
/// Invalidate height resources when a block below this one has changed. /// Invalidate height resources when a block below this one has changed.
void invalidateHeight() { InstrHeight = ~0u; HasValidInstrHeights = false; } void invalidateHeight() { InstrHeight = ~0u; HasValidInstrHeights = false; }
/// Determine if this block belongs to the same trace as TBI and comes /// Assuming that this is a dominator of TBI, determine if it contains
/// before it in the trace. /// useful instruction depths. A dominating block can be above the current
/// trace head, and any dependencies from such a far away dominator are not
/// expected to affect the critical path.
///
/// Also returns true when TBI == this. /// Also returns true when TBI == this.
bool isEarlierInSameTrace(const TraceBlockInfo &TBI) const { bool isUsefulDominator(const TraceBlockInfo &TBI) const {
return hasValidDepth() && TBI.hasValidDepth() && // The trace for TBI may not even be calculated yet.
Head == TBI.Head && InstrDepth <= TBI.InstrDepth; if (!hasValidDepth() || !TBI.hasValidDepth())
return false;
// Instruction depths are only comparable if the traces share a head.
if (Head != TBI.Head)
return false;
// It is almost always the case that TBI belongs to the same trace as
// this block, but rare convoluted cases involving irreducible control
// flow, a dominator may share a trace head without actually being on the
// same trace as TBI. This is not a big problem as long as it doesn't
// increase the instruction depth.
return HasValidInstrDepths && InstrDepth <= TBI.InstrDepth;
} }
// Data-dependency-related information. Per-instruction depth and height // Data-dependency-related information. Per-instruction depth and height

View File

@@ -677,7 +677,7 @@ computeCrossBlockCriticalPath(const TraceBlockInfo &TBI) {
const MachineInstr *DefMI = MTM.MRI->getVRegDef(LIR.Reg); const MachineInstr *DefMI = MTM.MRI->getVRegDef(LIR.Reg);
// Ignore dependencies outside the current trace. // Ignore dependencies outside the current trace.
const TraceBlockInfo &DefTBI = BlockInfo[DefMI->getParent()->getNumber()]; const TraceBlockInfo &DefTBI = BlockInfo[DefMI->getParent()->getNumber()];
if (!DefTBI.isEarlierInSameTrace(TBI)) if (!DefTBI.isUsefulDominator(TBI))
continue; continue;
unsigned Len = LIR.Height + Cycles[DefMI].Depth; unsigned Len = LIR.Height + Cycles[DefMI].Depth;
MaxLen = std::max(MaxLen, Len); MaxLen = std::max(MaxLen, Len);
@@ -740,7 +740,7 @@ computeInstrDepths(const MachineBasicBlock *MBB) {
const TraceBlockInfo&DepTBI = const TraceBlockInfo&DepTBI =
BlockInfo[Dep.DefMI->getParent()->getNumber()]; BlockInfo[Dep.DefMI->getParent()->getNumber()];
// Ignore dependencies from outside the current trace. // Ignore dependencies from outside the current trace.
if (!DepTBI.isEarlierInSameTrace(TBI)) if (!DepTBI.isUsefulDominator(TBI))
continue; continue;
assert(DepTBI.HasValidInstrDepths && "Inconsistent dependency"); assert(DepTBI.HasValidInstrDepths && "Inconsistent dependency");
unsigned DepCycle = Cycles.lookup(Dep.DefMI).Depth; unsigned DepCycle = Cycles.lookup(Dep.DefMI).Depth;