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.
Details
- Reviewers
reames - Commits
- rG0d043b52eb79: [InstCombineCalls] Use isKnownNonNullAt() to check nullness of passing…
rGa29c612ddd84: [InstCombineCalls] Use isKnownNonNullAt() to check nullness of passing…
rL247587: [InstCombineCalls] Use isKnownNonNullAt() to check nullness of passing…
rL247356: [InstCombineCalls] Use isKnownNonNullAt() to check nullness of passing…
Diff Detail
Event Timeline
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. |
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. |
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.
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.