This is an archive of the discontinued LLVM Phabricator instance.

Replace 'isProvablyNonNull' with existing utility llvm::IsKnownNonNull.
ClosedPublic

Authored by nlewycky on Sep 18 2016, 3:06 PM.

Details

Reviewers
rjmccall
Summary

Replace 'isProvablyNonNull' with existing utility llvm::IsKnownNonNull which handles more cases. Noticed by inspection.

It looks like this is only used in 'writeback's which appears to be an obj-c / swift ABI feature. All the existing tests pass, but a testcase for this change is not included, since I'm not sure exactly how to exercise the difference.

Diff Detail

Event Timeline

nlewycky updated this revision to Diff 71761.Sep 18 2016, 3:06 PM
nlewycky retitled this revision from to Replace 'isProvablyNonNull' with existing utility llvm::IsKnownNonNull..
nlewycky updated this object.
nlewycky added a reviewer: rjmccall.
rjmccall edited edge metadata.Sep 19 2016, 3:57 PM

The formation restrictions on ARC writeback conversions probably make this more-or-less impossible to test, but I can try to explain when they happen. They happen when you have an argument of type "id strong *" and pass it as a parameter of type "id autoreleasing *". strong is the default for variables, and autoreleasing is the default for pointer-to-id parameters, so basically you need something like:

void test(int opaque) {
  extern void foo(id*);
  id x;
  id y;
  foo(opaque ? &x : &y);
}

or any other expression that forms a sufficiently complex argument of type "id __strong *" prior to writeback conversion.

Actually, that should demonstrate the difference, assuming the LLVM function looks through selects, since IRGen should generate that as a select.

Oh. One danger with invoking a generic LLVM routine is that they often expect a well-formed function, not something that is plausibly still being emitted.

rjmccall accepted this revision.Sep 20 2016, 6:33 AM
rjmccall edited edge metadata.

In that case, you probably will not be able to test this difference, because the argument is basically required to be the address of a local variable, a parameter, or null (or a various things that propagate such values). And our IR-generation scheme for parameters will never make them just an llvm::Argument.

LGTM, then.

This revision is now accepted and ready to land.Sep 20 2016, 6:33 AM
Eugene.Zelenko closed this revision.Oct 4 2016, 1:54 PM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in rL281979.