This is an archive of the discontinued LLVM Phabricator instance.

[MemLoc] Support memcmp in MemoryLocation::getForArgument.
ClosedPublic

Authored by fhahn on Aug 27 2020, 9:45 AM.

Details

Summary

This patch adds support for memcmp in MemoryLocation::getForArgument.
memcmp reads from the first 2 arguments up to the number of bytes of the
third argument.

Diff Detail

Event Timeline

fhahn created this revision.Aug 27 2020, 9:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 27 2020, 9:45 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
fhahn requested review of this revision.Aug 27 2020, 9:45 AM
efriedma added inline comments.Aug 27 2020, 12:17 PM
llvm/lib/Analysis/MemoryLocation.cpp
213–235

While you're here, can we switch this to use TLI->getLibFunc(*Call, F)

fhahn updated this revision to Diff 288439.Aug 27 2020, 1:05 PM

Change TLI->getLibFunc(*Call->getCalledFunction(), F) to TLI->getLibFunc(*Call, F)` as suggested, thanks!

efriedma accepted this revision.Aug 27 2020, 1:42 PM

LGTM

llvm/lib/Analysis/MemoryLocation.cpp
213–235

Call->getCalledFunction() is redundant.

This revision is now accepted and ready to land.Aug 27 2020, 1:42 PM
This revision was landed with ongoing or failed builds.Aug 28 2020, 2:30 AM
This revision was automatically updated to reflect the committed changes.
xbolva00 added inline comments.
llvm/lib/Analysis/MemoryLocation.cpp
225

bcmp too?

LLVM transforms memcmp(...) == 0 to bcmp == 0.

fhahn added inline comments.Aug 28 2020, 4:08 AM
llvm/lib/Analysis/MemoryLocation.cpp
225

Yes, there are a lot of cases missing that we could support here. I won't have time to add all those in the near future unfortunately, any help/patches would be very welcome :)

Okey, so as a starting point, bcmo case: https://reviews.llvm.org/D87964

pi 28. 8. 2020 o 13:08 Florian Hahn via Phabricator
<reviews@reviews.llvm.org> napísal(a):

fhahn added inline comments.

Comment at: llvm/lib/Analysis/MemoryLocation.cpp:225
+ break;
+ case LibFunc_memcmp:

+ assert((ArgIdx == 0 || ArgIdx == 1) &&

xbolva00 wrote:

bcmp too?

LLVM transforms memcmp(...) == 0 to bcmp == 0.

Yes, there are a lot of cases missing that we could support here. I won't have time to add all those in the near future unfortunately, any help/patches would be very welcome :)

Repository:

rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION

https://reviews.llvm.org/D86725/new/

https://reviews.llvm.org/D86725