aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-09-01 02:03:17 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-09-01 02:03:17 +0000
commit343013538f72f2202338f57161c0bd92344ca407 (patch)
treef69d838f6da2c14e84a2c498617ec76911907122
parent4e9c473c4d9e0e93da67d6a0e20227e5a1e16543 (diff)
downloadexternal_llvm-343013538f72f2202338f57161c0bd92344ca407.zip
external_llvm-343013538f72f2202338f57161c0bd92344ca407.tar.gz
external_llvm-343013538f72f2202338f57161c0bd92344ca407.tar.bz2
More tweaks to improve compile time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41669 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/LiveInterval.cpp57
-rw-r--r--lib/CodeGen/SimpleRegisterCoalescing.cpp40
2 files changed, 56 insertions, 41 deletions
diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp
index c9e98bc..53ffbe3 100644
--- a/lib/CodeGen/LiveInterval.cpp
+++ b/lib/CodeGen/LiveInterval.cpp
@@ -288,26 +288,24 @@ LiveInterval::FindLiveRangeContaining(unsigned Idx) {
void LiveInterval::join(LiveInterval &Other, int *LHSValNoAssignments,
int *RHSValNoAssignments,
SmallVector<VNInfo*, 16> &NewVNInfo) {
-
- // There might be some dead val#, create VNInfo for them.
- for (unsigned i = 0, e = NewVNInfo.size(); i != e; ++i) {
- VNInfo *VNI = NewVNInfo[i];
- if (!VNI) {
- VNI = new VNInfo(this, i, ~1U, 0);
- NewVNInfo[i] = VNI;
- }
- }
-
// Determine if any of our live range values are mapped. This is uncommon, so
- // we want to avoid the interval scan if not.
+ // we want to avoid the interval scan if not.
bool MustMapCurValNos = false;
- for (vni_iterator i = vni_begin(), e = vni_end(); i != e; ++i) {
- VNInfo *VNI = *i;
- unsigned VN = VNI->id;
- if (VNI->def == ~1U) continue; // tombstone value #
- if (VNI != NewVNInfo[LHSValNoAssignments[VN]]) {
+ unsigned NumVals = getNumValNums();
+ unsigned NumNewVals = NewVNInfo.size();
+ for (unsigned i = 0; i != NumVals; ++i) {
+ unsigned LHSValID = LHSValNoAssignments[i];
+ if (i != LHSValID ||
+ (NewVNInfo[LHSValID] && NewVNInfo[LHSValID]->parent != this))
MustMapCurValNos = true;
- break;
+
+ // There might be some dead val#, create VNInfo for them.
+ if (i < NumNewVals) {
+ VNInfo *VNI = NewVNInfo[i];
+ if (!VNI) {
+ VNI = new VNInfo(this, i, ~1U, 0);
+ NewVNInfo[i] = VNI;
+ }
}
}
@@ -342,19 +340,34 @@ void LiveInterval::join(LiveInterval &Other, int *LHSValNoAssignments,
}
// Remember assignements because val# ids are changing.
- std::vector<unsigned> OtherAssignments;
+ SmallVector<unsigned, 16> OtherAssignments;
for (iterator I = Other.begin(), E = Other.end(); I != E; ++I)
OtherAssignments.push_back(RHSValNoAssignments[I->valno->id]);
// Update val# info. Renumber them and make sure they all belong to this
// LiveInterval now.
- valnos.clear();
- for (unsigned i = 0, e = NewVNInfo.size(); i != e; ++i) {
+ for (unsigned i = 0; i != NumVals; ++i) {
+ if (i == NumNewVals)
+ break;
VNInfo *VNI = NewVNInfo[i];
- VNI->parent = this;
- VNI->id = i; // Renumber val#.
+ if (VNI->parent != this || VNI->id != i) {
+ VNI->parent = this;
+ VNI->id = i; // Renumber val#.
+ valnos[i] = VNI;
+ }
+ }
+ for (unsigned i = NumVals; i < NumNewVals; ++i) {
+ VNInfo *VNI = NewVNInfo[i];
+ if (!VNI)
+ VNI = new VNInfo(this, i, ~1U, 0);
+ else {
+ VNI->parent = this;
+ VNI->id = i; // Renumber val#.
+ }
valnos.push_back(VNI);
}
+ if (NumNewVals < NumVals)
+ valnos.resize(NumNewVals); // shrinkify
// Okay, now insert the RHS live ranges into the LHS.
iterator InsertPos = begin();
diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp
index 052573a..03e416b 100644
--- a/lib/CodeGen/SimpleRegisterCoalescing.cpp
+++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp
@@ -682,8 +682,9 @@ bool SimpleRegisterCoalescing::JoinIntervals(LiveInterval &LHS,
assert(RHSValID != -1 && "Didn't find value #?");
RHSValNoAssignments[0] = RHSValID;
if (RHSVal0DefinedFromLHS != -1) {
- RHSValsDefinedFromLHS[RHSValNoInfo0] =
- LHS.getLiveRangeContaining(RHSValNoInfo0->def-1)->valno;
+ // This path doesn't go through ComputeUltimateVN so just set
+ // it to anything.
+ RHSValsDefinedFromLHS[RHSValNoInfo0] = (VNInfo*)1;
}
} else {
// Loop over the value numbers of the LHS, seeing if any are defined from
@@ -798,31 +799,32 @@ bool SimpleRegisterCoalescing::JoinIntervals(LiveInterval &LHS,
}
}
- // Update kill info. Some live ranges are extended due to copy coalescing.
- for (DenseMap<VNInfo*, VNInfo*>::iterator I = RHSValsDefinedFromLHS.begin(),
- E = RHSValsDefinedFromLHS.end(); I != E; ++I) {
- VNInfo *VNI = I->first;
- unsigned RHSValID = RHSValNoAssignments[VNI->id];
- LiveInterval::removeKill(*NewVNInfo[RHSValID], VNI->def);
- LHS.addKills(*NewVNInfo[RHSValID], VNI->kills);
- }
-
- for (DenseMap<VNInfo*, VNInfo*>::iterator I = LHSValsDefinedFromRHS.begin(),
- E = LHSValsDefinedFromRHS.end(); I != E; ++I) {
- VNInfo *VNI = I->first;
- unsigned LHSValID = LHSValNoAssignments[VNI->id];
- LiveInterval::removeKill(*NewVNInfo[LHSValID], VNI->def);
- RHS.addKills(*NewVNInfo[LHSValID], VNI->kills);
- }
-
// If we get here, we know that we can coalesce the live ranges. Ask the
// intervals to coalesce themselves now.
if ((RHS.ranges.size() > LHS.ranges.size() &&
MRegisterInfo::isVirtualRegister(LHS.reg)) ||
MRegisterInfo::isPhysicalRegister(RHS.reg)) {
+ // Update kill info. Some live ranges are extended due to copy coalescing.
+ for (DenseMap<VNInfo*, VNInfo*>::iterator I = LHSValsDefinedFromRHS.begin(),
+ E = LHSValsDefinedFromRHS.end(); I != E; ++I) {
+ VNInfo *VNI = I->first;
+ unsigned LHSValID = LHSValNoAssignments[VNI->id];
+ LiveInterval::removeKill(*NewVNInfo[LHSValID], VNI->def);
+ RHS.addKills(*NewVNInfo[LHSValID], VNI->kills);
+ }
+
RHS.join(LHS, &RHSValNoAssignments[0], &LHSValNoAssignments[0], NewVNInfo);
Swapped = true;
} else {
+ // Update kill info. Some live ranges are extended due to copy coalescing.
+ for (DenseMap<VNInfo*, VNInfo*>::iterator I = RHSValsDefinedFromLHS.begin(),
+ E = RHSValsDefinedFromLHS.end(); I != E; ++I) {
+ VNInfo *VNI = I->first;
+ unsigned RHSValID = RHSValNoAssignments[VNI->id];
+ LiveInterval::removeKill(*NewVNInfo[RHSValID], VNI->def);
+ LHS.addKills(*NewVNInfo[RHSValID], VNI->kills);
+ }
+
LHS.join(RHS, &LHSValNoAssignments[0], &RHSValNoAssignments[0], NewVNInfo);
Swapped = false;
}