Remove unused deserialized SILFunctions.

The deserializer holds a reference to the deserialized SILFunction, which
prevents Dead Function Elimination from erasing them. 

We have a tradeoff on how often we should clean up the unused deserialized
SILFunctions. If we clean up at every optimization iteration, we may
end up deserializing the same SILFunction multiple times. For now, we clean
up only after we are done with the optimization iteration.

rdar://17046033


Swift SVN r18697
This commit is contained in:
Manman Ren
2014-06-04 00:30:34 +00:00
parent ba182e6679
commit b3e72be9d9
10 changed files with 106 additions and 6 deletions

View File

@@ -163,22 +163,24 @@ public:
/// The deserialized value.
T Value;
/// The offset. Set to 0 when fully deserialized.
/// The offset.
serialization::BitOffset Offset;
unsigned IsFullyDeserialized : 1;
public:
/*implicit*/ PartiallySerialized(serialization::BitOffset offset)
: Value(), Offset(offset) {}
: Value(), Offset(offset), IsFullyDeserialized(0) {}
/*implicit*/ PartiallySerialized(RawBitOffset offset)
: Value(), Offset(offset) {}
: Value(), Offset(offset), IsFullyDeserialized(0) {}
bool isDeserialized() const {
return Value != T();
}
bool isFullyDeserialized() const {
return isDeserialized() && Offset == 0;
return isDeserialized() && IsFullyDeserialized;
}
serialization::BitOffset getOffset() const {
@@ -191,10 +193,15 @@ public:
return Value;
}
void reset() {
IsFullyDeserialized = 0;
Value = T();
}
void set(T value, bool isFullyDeserialized) {
assert(!isDeserialized() || Value == value);
Value = value;
if (isFullyDeserialized) Offset = 0;
IsFullyDeserialized = isFullyDeserialized;
}
};