Commits

Nadav Rotem committed 30927d34595
Implement CSE of the trio open_ext + witness_method + apply. When we emit calls to existential methods silgen produces a sequence of the three instructions below: open_existential_addr %0 : $*Pingable to $*@opened("1E467EB8-...") Pingable witness_method $@opened("1E467EB8-...") Pingable, #Pingable.ping!1 apply %3<@opened("1E467EB8-...") Pingable>(%2) This commit adds a new CSE-like pass that finds sequences of calls to protocol methods and reuses the first two instructions open_existential_addr and witness_method. The optimization finds arguments that must not alias and may not escape and combines all of the existential method calls to use the same method lookup. The optimization handles control flow by finding the top dominating open_existential instruction, and uses that instruction. related to rdar://22704464.