Fix a iteration invalidation bug
Fix a iteration invalidation bug

Separate collecting the applies and devirtualizing them into two loops.
We run into an issue on a huge test case where we end up devirtualizing a call-site over and over again.

I have not been able to reduce a test case.

rdar://29785529

karwa/swift,JaSpa/swift,nathawes/swift,jmgc/swift,alblue/swift,tardieu/swift,jmgc/swift,rudkx/swift,zisko/swift,gribozavr/swift,rudkx/swift,milseman/swift,brentdax/swift,OscarSwanros/swift,tardieu/swift,natecook1000/swift,huonw/swift,lorentey/swift,lorentey/swift,apple/swift,roambotics/swift,allevato/swift,djwbrown/swift,bitjammer/swift,felix91gr/swift,natecook1000/swift,tkremenek/swift,tjw/swift,sschiau/swift,karwa/swift,xedin/swift,practicalswift/swift,shahmishal/swift,jtbandes/swift,practicalswift/swift,codestergit/swift,benlangmuir/swift,hughbe/swift,jmgc/swift,frootloops/swift,airspeedswift/swift,milseman/swift,stephentyrone/swift,parkera/swift,manavgabhawala/swift,codestergit/swift,benlangmuir/swift,airspeedswift/swift,gottesmm/swift,xedin/swift,jopamer/swift,calebd/swift,lorentey/swift,sschiau/swift,atrick/swift,hooman/swift,xwu/swift,ahoppen/swift,JaSpa/swift,tinysun212/swift-windows,xedin/swift,benlangmuir/swift,atrick/swift,arvedviehweger/swift,jckarter/swift,austinzheng/swift,devincoughlin/swift,codestergit/swift,brentdax/swift,parkera/swift,tjw/swift,milseman/swift,arvedviehweger/swift,allevato/swift,jckarter/swift,harlanhaskins/swift,Jnosh/swift,airspeedswift/swift,aschwaighofer/swift,xedin/swift,swiftix/swift,return/swift,shahmishal/swift,bitjammer/swift,amraboelela/swift,huonw/swift,felix91gr/swift,frootloops/swift,hooman/swift,roambotics/swift,Jnosh/swift,gribozavr/swift,OscarSwanros/swift,arvedviehweger/swift,frootloops/swift,JaSpa/swift,jckarter/swift,parkera/swift,shahmishal/swift,calebd/swift,austinzheng/swift,devincoughlin/swift,gregomni/swift,alblue/swift,shajrawi/swift,shajrawi/swift,frootloops/swift,uasys/swift,codestergit/swift,djwbrown/swift,tinysun212/swift-windows,JGiola/swift,gregomni/swift,aschwaighofer/swift,nathawes/swift,natecook1000/swift,return/swift,natecook1000/swift,gribozavr/swift,ahoppen/swift,tardieu/swift,shajrawi/swift,return/swift,harlanhaskins/swift,roambotics/swift,lorentey/swift,uasys/swift,jtbandes/swift,jtbandes/swift,practicalswift/swift,stephentyrone/swift,uasys/swift,codestergit/swift,glessard/swift,xwu/swift,calebd/swift,xedin/swift,arvedviehweger/swift,jopamer/swift,JaSpa/swift,deyton/swift,aschwaighofer/swift,jopamer/swift,gottesmm/swift,manavgabhawala/swift,glessard/swift,lorentey/swift,harlanhaskins/swift,tkremenek/swift,sschiau/swift,apple/swift,hughbe/swift,hughbe/swift,nathawes/swift,natecook1000/swift,ahoppen/swift,felix91gr/swift,karwa/swift,danielmartin/swift,djwbrown/swift,alblue/swift,bitjammer/swift,OscarSwanros/swift,alblue/swift,karwa/swift,huonw/swift,devincoughlin/swift,uasys/swift,shahmishal/swift,bitjammer/swift,gottesmm/swift,airspeedswift/swift,hooman/swift,aschwaighofer/swift,return/swift,huonw/swift,bitjammer/swift,jopamer/swift,jopamer/swift,JGiola/swift,airspeedswift/swift,xedin/swift,austinzheng/swift,brentdax/swift,swiftix/swift,xwu/swift,zisko/swift,natecook1000/swift,benlangmuir/swift,codestergit/swift,shajrawi/swift,danielmartin/swift,milseman/swift,tjw/swift,CodaFi/swift,atrick/swift,uasys/swift,glessard/swift,devincoughlin/swift,calebd/swift,jmgc/swift,karwa/swift,devincoughlin/swift,CodaFi/swift,amraboelela/swift,roambotics/swift,return/swift,uasys/swift,manavgabhawala/swift,aschwaighofer/swift,tinysun212/swift-windows,tinysun212/swift-windows,aschwaighofer/swift,deyton/swift,jckarter/swift,allevato/swift,swiftix/swift,lorentey/swift,shahmishal/swift,JaSpa/swift,deyton/swift,djwbrown/swift,tkremenek/swift,JGiola/swift,stephentyrone/swift,parkera/swift,felix91gr/swift,CodaFi/swift,tkremenek/swift,atrick/swift,tjw/swift,aschwaighofer/swift,tardieu/swift,amraboelela/swift,deyton/swift,sschiau/swift,tardieu/swift,xwu/swift,OscarSwanros/swift,austinzheng/swift,hooman/swift,OscarSwanros/swift,allevato/swift,hughbe/swift,arvedviehweger/swift,manavgabhawala/swift,jopamer/swift,lorentey/swift,hughbe/swift,amraboelela/swift,calebd/swift,OscarSwanros/swift,tardieu/swift,allevato/swift,sschiau/swift,Jnosh/swift,djwbrown/swift,atrick/swift,djwbrown/swift,tkremenek/swift,parkera/swift,felix91gr/swift,tardieu/swift,rudkx/swift,airspeedswift/swift,Jnosh/swift,xwu/swift,gregomni/swift,shajrawi/swift,alblue/swift,gribozavr/swift,lorentey/swift,return/swift,bitjammer/swift,JaSpa/swift,swiftix/swift,danielmartin/swift,jopamer/swift,glessard/swift,zisko/swift,huonw/swift,karwa/swift,brentdax/swift,practicalswift/swift,glessard/swift,atrick/swift,shajrawi/swift,codestergit/swift,airspeedswift/swift,huonw/swift,devincoughlin/swift,austinzheng/swift,practicalswift/swift,huonw/swift,austinzheng/swift,jtbandes/swift,gottesmm/swift,manavgabhawala/swift,tinysun212/swift-windows,apple/swift,gottesmm/swift,hooman/swift,Jnosh/swift,amraboelela/swift,jckarter/swift,shajrawi/swift,devincoughlin/swift,gregomni/swift,rudkx/swift,zisko/swift,ahoppen/swift,shajrawi/swift,jmgc/swift,JGiola/swift,alblue/swift,apple/swift,shahmishal/swift,practicalswift/swift,frootloops/swift,allevato/swift,nathawes/swift,gribozavr/swift,arvedviehweger/swift,stephentyrone/swift,shahmishal/swift,apple/swift,apple/swift,JaSpa/swift,frootloops/swift,zisko/swift,hooman/swift,gribozavr/swift,CodaFi/swift,karwa/swift,deyton/swift,benlangmuir/swift,gottesmm/swift,xwu/swift,roambotics/swift,jtbandes/swift,gribozavr/swift,hooman/swift,CodaFi/swift,jckarter/swift,xedin/swift,sschiau/swift,hughbe/swift,swiftix/swift,sschiau/swift,brentdax/swift,sschiau/swift,frootloops/swift,alblue/swift,shahmishal/swift,austinzheng/swift,tjw/swift,tinysun212/swift-windows,tkremenek/swift,OscarSwanros/swift,djwbrown/swift,Jnosh/swift,jmgc/swift,harlanhaskins/swift,brentdax/swift,deyton/swift,milseman/swift,jtbandes/swift,rudkx/swift,glessard/swift,tkremenek/swift,stephentyrone/swift,roambotics/swift,karwa/swift,danielmartin/swift,uasys/swift,arvedviehweger/swift,jmgc/swift,return/swift,manavgabhawala/swift,tjw/swift,calebd/swift,nathawes/swift,milseman/swift,tinysun212/swift-windows,harlanhaskins/swift,felix91gr/swift,parkera/swift,ahoppen/swift,Jnosh/swift,CodaFi/swift,practicalswift/swift,ahoppen/swift,parkera/swift,zisko/swift,gregomni/swift,swiftix/swift,gregomni/swift,xwu/swift,danielmartin/swift,hughbe/swift,practicalswift/swift,brentdax/swift,amraboelela/swift,manavgabhawala/swift,nathawes/swift,gribozavr/swift,rudkx/swift,zisko/swift,tjw/swift,CodaFi/swift,bitjammer/swift,deyton/swift,stephentyrone/swift,jtbandes/swift,amraboelela/swift,parkera/swift,jckarter/swift,devincoughlin/swift,benlangmuir/swift,swiftix/swift,calebd/swift,harlanhaskins/swift,danielmartin/swift,xedin/swift,natecook1000/swift,felix91gr/swift,danielmartin/swift,harlanhaskins/swift,allevato/swift,JGiola/swift,nathawes/swift,stephentyrone/swift,JGiola/swift,gottesmm/swift,milseman/swift