This is an archive of the discontinued LLVM Phabricator instance.

Directly return 0 in memcmp/bcmp when input pointers point to same memory location
AbandonedPublic

Authored by xiongji90 on Jun 9 2023, 2:08 AM.

Details

Reviewers
gchatelet

Diff Detail

Event Timeline

xiongji90 created this revision.Jun 9 2023, 2:08 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 9 2023, 2:08 AM
xiongji90 requested review of this revision.Jun 9 2023, 2:08 AM

Hi, @gchatelet
This patch handles a corner case when memcmp/bcmp is trying to compare same pointers. Could you help review it?
Thanks very much!

Hi @xiongji90 !
We explicitly don't handle this use case because it is in the critical path and we care more about latency in general than rarely occurring calls.
If p1 == p2 is expected to occur it should be handled on the client side.

Thx for the patch though.

Hi @xiongji90 !
We explicitly don't handle this use case because it is in the critical path and we care more about latency in general than rarely occurring calls.
If p1 == p2 is expected to occur it should be handled on the client side.

Thx for the patch though.

Make sense, thanks for the explaination!

xiongji90 abandoned this revision.Jun 11 2023, 5:57 PM