This is an archive of the discontinued LLVM Phabricator instance.

[InstCombineCalls] Use isKnownNonNullAt() to check nullness of passing arguments at callsite
ClosedPublic

Authored by chenli on Sep 10 2015, 3:42 PM.

Details

Summary

This patch replaces isKnownNonNull() with isKnownNonNullAt() when checking nullness of passing arguments at callsite. In this way it can handle cases where the argument does not have nonnull attribute but has a dominating null check from the CFG. It also adds assertions in isKnownNonNull() and isKnownNonNullFromDominatingCondition() to make sure the value checked is pointer type (as defined in LLVM document). These assertions might trip failures in things which are not covered under llvm/test, but fixes should be pretty obvious.

Diff Detail

Event Timeline

chenli updated this revision to Diff 34502.Sep 10 2015, 3:42 PM
chenli retitled this revision from to [InstCombineCalls] Use isKnownNonNullAt() to check nullness of passing arguments at callsite.
chenli updated this object.
chenli added a reviewer: reames.
chenli added a subscriber: llvm-commits.
reames accepted this revision.Sep 10 2015, 3:48 PM
reames edited edge metadata.

LGTM w/one minor comment optional.

test/Transforms/InstCombine/call_nonnull_arg.ll
4

Not sure this needs to be it's own file. It could probably just be added to the existing file which contains the previous nonnull attribute tests.

This revision is now accepted and ready to land.Sep 10 2015, 3:48 PM
chenli added inline comments.Sep 10 2015, 3:58 PM
test/Transforms/InstCombine/call_nonnull_arg.ll
4

I dont think there is an existing test case to check nonnull attribute at callsite. I didn't find one under InstCombine/ directory.

chenli closed this revision.Sep 10 2015, 4:06 PM
chenli updated this revision to Diff 34577.Sep 11 2015, 1:19 PM
chenli edited edge metadata.

This update fixed a issue when argument is not pointer type and should not be attached with nonnull attribute.

Revised version w/fix LGTM provided test case added.

I'm a bit concerned that we'll see the assert you added trip in something which doesn't have a unit test, but if we do, the fix should be pretty obvious at the call site. Please call this out specifically in the commit message.

chenli updated this object.

Update test case and summary.