The attached patch adds a check so that, if we flow off the end of a 
value-returning function, the implicit unreachable will only be emitted if the 
returning block is empty.
For example:

int baz(int x) {
  switch (x) {
    case 1: return 10;
    case 2: return 20;
  }
  // implicit unreachable is inserted
}

int baz2(int x) {
  switch (x) {
    case 1: return 10;
    case 2: return 20;
  }
  foo();
  // no unreachable
}

As a consequence, functions that have no returns, will not get the implicit 
unreachable:

int baz2(int x) {
  foo();
  // no unreachable
}


I believe this allows taking advantage of the optimization opportunities that 
the implicit unreachable intended, in a safer manner.

Please review!

Attachment: unreachable-on-empty.diff
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to