mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Thinking about it, we don't need MachineDominatorTree after all. The DomValue
map discovers the iterated dominance frontier for free. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111400 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
#include "VirtRegMap.h"
|
#include "VirtRegMap.h"
|
||||||
#include "llvm/CodeGen/CalcSpillWeights.h"
|
#include "llvm/CodeGen/CalcSpillWeights.h"
|
||||||
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
||||||
#include "llvm/CodeGen/MachineDominators.h"
|
|
||||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||||
#include "llvm/CodeGen/MachineLoopInfo.h"
|
#include "llvm/CodeGen/MachineLoopInfo.h"
|
||||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||||
@@ -423,31 +422,41 @@ VNInfo *LiveIntervalMap::mapValue(const VNInfo *ParentVNI, SlotIndex Idx) {
|
|||||||
// Yes, VNI dominates MBB. Track the path back to IdxMBB, creating phi-defs
|
// Yes, VNI dominates MBB. Track the path back to IdxMBB, creating phi-defs
|
||||||
// as needed along the way.
|
// as needed along the way.
|
||||||
for (unsigned PI = IDFI.getPathLength()-1; PI != 0; --PI) {
|
for (unsigned PI = IDFI.getPathLength()-1; PI != 0; --PI) {
|
||||||
// Start from MBB's immediate successor.
|
// Start from MBB's immediate successor. End at IdxMBB.
|
||||||
MachineBasicBlock *Succ = IDFI.getPath(PI-1);
|
MachineBasicBlock *Succ = IDFI.getPath(PI-1);
|
||||||
std::pair<MBBValueMap::iterator, bool> InsP =
|
std::pair<MBBValueMap::iterator, bool> InsP =
|
||||||
DomValue.insert(MBBValueMap::value_type(Succ, VNI));
|
DomValue.insert(MBBValueMap::value_type(Succ, VNI));
|
||||||
SlotIndex Start = lis_.getMBBStartIdx(Succ);
|
|
||||||
if (InsP.second) {
|
// This is the first time we backtrack to Succ.
|
||||||
// This is the first time we backtrack to Succ. Verify dominance.
|
if (InsP.second)
|
||||||
if (Succ->pred_size() == 1 || dt_.dominates(MBB, Succ))
|
continue;
|
||||||
continue;
|
|
||||||
} else if (InsP.first->second == VNI ||
|
// We reached Succ again with the same VNI. Nothing is going to change.
|
||||||
InsP.first->second->def == Start) {
|
VNInfo *OVNI = InsP.first->second;
|
||||||
// We have previously backtracked VNI to Succ, or Succ already has a
|
if (OVNI == VNI)
|
||||||
// phi-def. No need to backtrack further.
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
// VNI does not dominate Succ, we need a new phi-def.
|
// Succ already has a phi-def. No need to continue.
|
||||||
|
SlotIndex Start = lis_.getMBBStartIdx(Succ);
|
||||||
|
if (OVNI->def == Start)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// We have a collision between the old and new VNI at Succ. That means
|
||||||
|
// neither dominates and we need a new phi-def.
|
||||||
VNI = li_.getNextValue(Start, 0, true, lis_.getVNInfoAllocator());
|
VNI = li_.getNextValue(Start, 0, true, lis_.getVNInfoAllocator());
|
||||||
VNI->setIsPHIDef(true);
|
VNI->setIsPHIDef(true);
|
||||||
InsP.first->second = VNI;
|
InsP.first->second = VNI;
|
||||||
MBB = Succ;
|
|
||||||
|
// Replace OVNI with VNI in the remaining path.
|
||||||
|
for (; PI > 1 ; --PI) {
|
||||||
|
MBBValueMap::iterator I = DomValue.find(IDFI.getPath(PI-2));
|
||||||
|
if (I == DomValue.end() || I->second != OVNI)
|
||||||
|
break;
|
||||||
|
I->second = VNI;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No need to search the children, we found a dominating value.
|
// No need to search the children, we found a dominating value.
|
||||||
// FIXME: We could prune up to the last phi-def we inserted, need df_iterator
|
|
||||||
// for that.
|
|
||||||
IDFI.skipChildren();
|
IDFI.skipChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,6 +477,7 @@ VNInfo *LiveIntervalMap::mapValue(const VNInfo *ParentVNI, SlotIndex Idx) {
|
|||||||
// Don't add full liveness to IdxMBB, stop at Idx.
|
// Don't add full liveness to IdxMBB, stop at Idx.
|
||||||
if (Start != Idx)
|
if (Start != Idx)
|
||||||
li_.addRange(LiveRange(Start, Idx, VNI));
|
li_.addRange(LiveRange(Start, Idx, VNI));
|
||||||
|
// The caller had better add some liveness to IdxVNI, or it leaks.
|
||||||
IdxVNI = VNI;
|
IdxVNI = VNI;
|
||||||
} else
|
} else
|
||||||
li_.addRange(LiveRange(Start, lis_.getMBBEndIdx(MBB), VNI));
|
li_.addRange(LiveRange(Start, lis_.getMBBEndIdx(MBB), VNI));
|
||||||
|
@@ -20,7 +20,6 @@ namespace llvm {
|
|||||||
|
|
||||||
class LiveInterval;
|
class LiveInterval;
|
||||||
class LiveIntervals;
|
class LiveIntervals;
|
||||||
class MachineDominatorTree;
|
|
||||||
class MachineInstr;
|
class MachineInstr;
|
||||||
class MachineLoop;
|
class MachineLoop;
|
||||||
class MachineLoopInfo;
|
class MachineLoopInfo;
|
||||||
@@ -147,7 +146,6 @@ public:
|
|||||||
/// Values in parentli_ may map to any number of openli_ values, including 0.
|
/// Values in parentli_ may map to any number of openli_ values, including 0.
|
||||||
class LiveIntervalMap {
|
class LiveIntervalMap {
|
||||||
LiveIntervals &lis_;
|
LiveIntervals &lis_;
|
||||||
MachineDominatorTree &dt_;
|
|
||||||
|
|
||||||
// The parent interval is never changed.
|
// The parent interval is never changed.
|
||||||
const LiveInterval &parentli_;
|
const LiveInterval &parentli_;
|
||||||
@@ -174,10 +172,9 @@ class LiveIntervalMap {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
LiveIntervalMap(LiveIntervals &lis,
|
LiveIntervalMap(LiveIntervals &lis,
|
||||||
MachineDominatorTree &dt,
|
|
||||||
const LiveInterval &parentli,
|
const LiveInterval &parentli,
|
||||||
LiveInterval &li)
|
LiveInterval &li)
|
||||||
: lis_(lis), dt_(dt), parentli_(parentli), li_(li) {}
|
: lis_(lis), parentli_(parentli), li_(li) {}
|
||||||
|
|
||||||
/// defValue - define a value in li_ from the parentli_ value VNI and Idx.
|
/// defValue - define a value in li_ from the parentli_ value VNI and Idx.
|
||||||
/// Idx does not have to be ParentVNI->def, but it must be contained within
|
/// Idx does not have to be ParentVNI->def, but it must be contained within
|
||||||
|
Reference in New Issue
Block a user