SILGen unconditional dynamic casts using the new

unconditional_dynamic_cast_addr instruction.

Also, fix some major semantic problems with the
existing specialization of unconditional dynamic
casts by handling optional types and being much
more conservative about deciding that a cast is
infeasible.

This commit regresses specialization slightly by
failing to turn indirect dynamic casts into scalar
ones when possible; we can fix that easily enough
in a follow-up.

Swift SVN r19044
This commit is contained in:
John McCall
2014-06-20 07:47:03 +00:00
parent 47427ccc5a
commit 48d6a833a5
11 changed files with 842 additions and 207 deletions

View File

@@ -1272,6 +1272,19 @@ SILGenFunction::emitSubstToOrigValue(SILLocation loc, ManagedValue v,
substFormalType, ctxt);
}
ManagedValue
SILGenFunction::emitRValueAsOrig(Expr *expr, AbstractionPattern origFormalType,
const TypeLowering &origTL, SGFContext ctxt) {
auto substFormalType = expr->getType()->getCanonicalType();
auto &substTL = getTypeLowering(substFormalType);
if (substTL.getLoweredType() == origTL.getLoweredType())
return emitRValueAsSingleValue(expr, ctxt);
ManagedValue temp = emitRValueAsSingleValue(expr);
return emitSubstToOrigValue(expr, temp, origFormalType,
substFormalType, ctxt);
}
ManagedValue RValueSource::materialize(SILGenFunction &SGF,
AbstractionPattern origFormalType,
SILType destType) && {