This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Remove dereferenceable_or_null when nonull is present
ClosedPublic

Authored by uenoku on Nov 27 2019, 8:48 AM.

Details

Summary

This patch prevents the simultaneous presence of dereferenceable and dereferenceable_or_null attribute

Diff Detail

Event Timeline

uenoku created this revision.Nov 27 2019, 8:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 27 2019, 8:48 AM

This was a problem for a while now:
Can we have a test case to make sure we do not lose information, e.g. deref_or_null(100) nonnull deref(4) should not remove the deref_or_null(100).

llvm/test/Transforms/FunctionAttrs/dereferenceable.ll
32–33

FIXME can be removed.

This was a problem for a while now:
Can we have a test case to make sure we do not lose information, e.g. deref_or_null(100) nonnull deref(4) should not remove the deref_or_null(100).

In my understanding, deref_or_null(100) and nonnull imply deref(100) so deref_or_null(100) can be deleted safely, correct?

uenoku updated this revision to Diff 231351.Nov 27 2019, 10:37 PM

Remove fixme

jdoerfert accepted this revision.Nov 28 2019, 10:16 AM

LGTM.

This was a problem for a while now:
Can we have a test case to make sure we do not lose information, e.g. deref_or_null(100) nonnull deref(4) should not remove the deref_or_null(100).

In my understanding, deref_or_null(100) and nonnull imply deref(100) so deref_or_null(100) can be deleted safely, correct?

Yes.

This revision is now accepted and ready to land.Nov 28 2019, 10:16 AM

LGTM.

This was a problem for a while now:
Can we have a test case to make sure we do not lose information, e.g. deref_or_null(100) nonnull deref(4) should not remove the deref_or_null(100).

More generally, we do already merge deref_or_null(x) deref(y) -> deref(max(x, y)) ?

uenoku marked an inline comment as done.EditedNov 28 2019, 11:01 AM

LGTM.

This was a problem for a while now:
Can we have a test case to make sure we do not lose information, e.g. deref_or_null(100) nonnull deref(4) should not remove the deref_or_null(100).

More generally, we do already merge deref_or_null(x) deref(y) -> deref(max(x, y)) ?

Yes, please see the comment

llvm/lib/Transforms/IPO/Attributor.cpp
2944–2947

The max of deref(x) and deref_or_null(y) is taken here.

lebedev.ri added inline comments.Nov 28 2019, 11:04 AM
llvm/lib/Transforms/IPO/Attributor.cpp
2944–2947

Cool, thanks, just checking :)

This revision was automatically updated to reflect the committed changes.