This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyLibCalls] Don't mark memchr() memory as fully dereferenceable
ClosedPublic

Authored by nikic on Apr 13 2022, 2:31 AM.

Details

Summary

C11 specifies memchr() as follows:

The memchr function locates the first occurrence of c (converted to an unsigned
char) in the initial n characters (each interpreted as unsigned char ) of the object
pointed to by s. The implementation shall behave as if it reads the characters sequentially
and stops as soon as a matching character is found.

In particular, it is well-defined to specify a memchr size larger than the underlying object, as long as the character is found before the end of the object.

Diff Detail

Event Timeline

nikic created this revision.Apr 13 2022, 2:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2022, 2:31 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikic requested review of this revision.Apr 13 2022, 2:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2022, 2:31 AM
xbolva00 accepted this revision.Apr 13 2022, 3:41 AM

The implementation shall behave as if it reads the characters sequentially and stops as soon as a matching character is found.

Then LG

This revision is now accepted and ready to land.Apr 13 2022, 3:41 AM
This revision was landed with ongoing or failed builds.Apr 13 2022, 7:46 AM
This revision was automatically updated to reflect the committed changes.