[PATCH] D32187: [CodeGen][ObjC]

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 18 13:48:51 PDT 2017


ahatanak created this revision.

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


https://reviews.llvm.org/D32187

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjC/arc-foreach.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32187.95619.patch
Type: text/x-patch
Size: 9582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170418/a964bd93/attachment.bin>


More information about the cfe-commits mailing list