summaryrefslogtreecommitdiff
path: root/lib/CodeGen/ExecutionDepsFix.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-11-08 21:57:44 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-11-08 21:57:44 +0000
commit35e932483a86a2b417d874648b903f6290ec3157 (patch)
treeefe949fecbb9d984202cc0a99556305035a0b644 /lib/CodeGen/ExecutionDepsFix.cpp
parent74d8a87f40dd89ec263071c0af4d77104b166f4a (diff)
downloadllvm-35e932483a86a2b417d874648b903f6290ec3157.tar.gz
llvm-35e932483a86a2b417d874648b903f6290ec3157.tar.bz2
llvm-35e932483a86a2b417d874648b903f6290ec3157.tar.xz
Handle reference counts in one function: release().
This new function will decrement the reference count, and collapse a domain value when the last reference is gone. This simplifies DomainValue reference counting, and decouples it from the LiveRegs array. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144131 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/ExecutionDepsFix.cpp')
-rw-r--r--lib/CodeGen/ExecutionDepsFix.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/lib/CodeGen/ExecutionDepsFix.cpp b/lib/CodeGen/ExecutionDepsFix.cpp
index 5aa80f9a06..b4f99b98a2 100644
--- a/lib/CodeGen/ExecutionDepsFix.cpp
+++ b/lib/CodeGen/ExecutionDepsFix.cpp
@@ -139,7 +139,7 @@ private:
// DomainValue allocation.
DomainValue *Alloc(int domain = -1);
- void Recycle(DomainValue*);
+ void release(DomainValue*);
// LiveRegs manipulations.
void SetLiveReg(int rx, DomainValue *DV);
@@ -176,10 +176,19 @@ DomainValue *ExeDepsFix::Alloc(int domain) {
return dv;
}
-void ExeDepsFix::Recycle(DomainValue *dv) {
- assert(dv && "Cannot recycle NULL");
- dv->clear();
- Avail.push_back(dv);
+/// release - Release a reference to DV. When the last reference is released,
+/// collapse if needed.
+void ExeDepsFix::release(DomainValue *DV) {
+ assert(DV && DV->Refs && "Bad DomainValue");
+ if (--DV->Refs)
+ return;
+
+ // There are no more DV references. Collapse any contained instructions.
+ if (DV->AvailableDomains && !DV->isCollapsed())
+ Collapse(DV, DV->getFirstDomain());
+
+ DV->clear();
+ Avail.push_back(DV);
}
/// Set LiveRegs[rx] = dv, updating reference counts.
@@ -192,10 +201,8 @@ void ExeDepsFix::SetLiveReg(int rx, DomainValue *dv) {
if (LiveRegs[rx] == dv)
return;
- if (LiveRegs[rx]) {
- assert(LiveRegs[rx]->Refs && "Bad refcount");
- if (--LiveRegs[rx]->Refs == 0) Recycle(LiveRegs[rx]);
- }
+ if (LiveRegs[rx])
+ release(LiveRegs[rx]);
LiveRegs[rx] = dv;
if (dv) ++dv->Refs;
}
@@ -205,12 +212,8 @@ void ExeDepsFix::Kill(int rx) {
assert(unsigned(rx) < NumRegs && "Invalid index");
if (!LiveRegs || !LiveRegs[rx]) return;
- // Before killing the last reference to an open DomainValue, collapse it to
- // the first available domain.
- if (LiveRegs[rx]->Refs == 1 && !LiveRegs[rx]->isCollapsed())
- Collapse(LiveRegs[rx], LiveRegs[rx]->getFirstDomain());
- else
- SetLiveReg(rx, 0);
+ release(LiveRegs[rx]);
+ LiveRegs[rx] = 0;
}
/// Force register rx into domain.