[lower-aggregate-instrs] Add an additional type lowering style "DeepNoEnum" for use in lowering aggregate memory operations.

The idea here is that the aggregate memory operation is lowered deep recursively
for all types except enums which recieve a shallow lowering. This prevents code
bloat due to the deep lowering of an enum requiring the creation of a bunch of
new basic blocks, code bloat which we do not want.

Another thing to note is that this method is actually not used anywhere else
currently, but in case this behavior was left in on purpose I decided to extend
it by adding the enum class flag rather than just changing the underlying
behavior (i.e. making deep not lower enum values).

Swift SVN r11748
This commit is contained in:
Michael Gottesman
2013-12-30 23:07:32 +00:00
parent 468ead25a6
commit e960091e31
2 changed files with 62 additions and 23 deletions

View File

@@ -228,16 +228,24 @@ public:
virtual void emitDestroyRValue(SILBuilder &B, SILLocation loc,
SILValue value) const = 0;
enum class LoweringStyle {
Shallow,
Deep,
DeepNoEnum
};
/// Emit a lowered 'destroy_value' operation.
///
/// This type must be loadable.
virtual void emitLoweredDestroyValue(SILBuilder &B, SILLocation loc,
SILValue value, bool deep) const = 0;
SILValue value,
LoweringStyle loweringStyle) const = 0;
void emitLoweredDestroyChildValue(SILBuilder &B, SILLocation loc,
SILValue value, bool wasDeep) const {
if (wasDeep) {
return emitLoweredDestroyValue(B, loc, value, true);
SILValue value,
LoweringStyle loweringStyle) const {
if (loweringStyle != LoweringStyle::Shallow) {
return emitLoweredDestroyValue(B, loc, value, loweringStyle);
} else {
return emitDestroyValue(B, loc, value);
}
@@ -248,7 +256,7 @@ public:
/// This type must be loadable.
void emitLoweredDestroyValueShallow(SILBuilder &B, SILLocation loc,
SILValue value) const {
emitLoweredDestroyValue(B, loc, value, false);
emitLoweredDestroyValue(B, loc, value, LoweringStyle::Shallow);
}
/// Emit a lowered 'destroy_value' operation.
@@ -256,7 +264,15 @@ public:
/// This type must be loadable.
void emitLoweredDestroyValueDeep(SILBuilder &B, SILLocation loc,
SILValue value) const {
emitLoweredDestroyValue(B, loc, value, true);
emitLoweredDestroyValue(B, loc, value, LoweringStyle::Deep);
}
/// Emit a lowered 'destroy_value' operation.
///
/// This type must be loadable.
void emitLoweredDestroyValueDeepNoEnum(SILBuilder &B, SILLocation loc,
SILValue value) const {
emitLoweredDestroyValue(B, loc, value, LoweringStyle::DeepNoEnum);
}
/// Given a primitively loaded value of this type (which must be