Add a data dependence between opened existential values and method_inst that 'use' them.

Before this patch there was no dependence visible to the optimizer between a
open_existential and the witness_method allowing the optimizer to reorder the
two instruction. The dependence was implicit in the opened archetype but this
is not a concept model by the SIL optimizer.

  %2 = open_existential %0 : $*FooProto to $*@opened("...") FooProto
  %3 = witness_method $@opened("...") FooProto,
                      #FooProto.bar!1 : $@cc(...)
  %4 = apply %3<...>(%2)

This patch changes the SIL representation such that witness_methods on opened
archetypes take the open_existential (or the producer of the opened existential)
as an operand preventing the optimizer from reordering them.

  %2 = open_existential %0 : $*FooProto to $*@opened("...") FooProto
  %3 = witness_method $@opened("...") FooProto,
                      #FooProto.bar!1,
                      %2 : $*@opened("...") FooProto : $@cc(...)
  %4 = apply %3<...>(%2)

rdar://18984526

Swift SVN r23438
This commit is contained in:
Arnold Schwaighofer
2014-11-19 17:22:22 +00:00
parent e9e1666ab0
commit c322b3592d
17 changed files with 130 additions and 64 deletions

View File

@@ -645,12 +645,14 @@ public:
ProtocolConformance *Conformance,
SILDeclRef Member,
SILType MethodTy,
SILValue OptionalOpenedExistential,
bool Volatile = false)
{
return insert(WitnessMethodInst::create(Loc, LookupTy, Conformance, Member,
MethodTy, &F, Volatile));
return insert(
WitnessMethodInst::create(Loc, LookupTy, Conformance, Member, MethodTy,
&F, OptionalOpenedExistential, Volatile));
}
DynamicMethodInst *createDynamicMethod(SILLocation Loc, SILValue Operand,
SILDeclRef Member, SILType MethodTy,
bool Volatile = false) {