This fixes a bug in EmitObjCForCollectionStmt which is causing clang to generate malformed IR.
When the following code (which I think is legal, at least when it is not compiled with ARC) is compiled:
$ cat test1.m
@interface Obj @end void bar(void); void foo(Obj *o) { Obj *i; for (i in o) { thing: bar(); } goto thing; }
the compilation terminates with the messages "Instruction does not dominate all uses!".
This patch fixes the bug by using temporary local variables instead of PHI instructions and moving instructions to locations that dominate their uses.
The example I showed still fails to compile (with an assertion) when compiled with -fobjc-arc, but I think that is a separate bug.
rdar://problem/31670637