This is an archive of the discontinued LLVM Phabricator instance.

Make the allocsize attribute useful in LLVM
ClosedPublic

Authored by george.burgess.iv on Apr 11 2016, 11:23 AM.

Details

Summary

This is the part of the allocsize patch that makes llvm.objectsize recognize the allocsize attribute introduced by D14933.

This is intended to be committed with D14933, but is split out to hopefully make this easier to review.

(Also, this diff is made assuming D14933 has already landed, so if you want to use this locally, you'll need to apply it on top of the diff in D14933)

Diff Detail

Event Timeline

george.burgess.iv retitled this revision from to Make the allocsize attribute useful in LLVM.
george.burgess.iv updated this object.
george.burgess.iv updated this object.
george.burgess.iv added subscribers: llvm-commits, ab, sanjoy and 2 others.
mehdi_amini accepted this revision.Apr 11 2016, 3:49 PM
mehdi_amini added a reviewer: mehdi_amini.
This revision is now accepted and ready to land.Apr 11 2016, 3:49 PM
mehdi_amini requested changes to this revision.Apr 11 2016, 3:50 PM
mehdi_amini edited edge metadata.

Oops (tm)

This revision now requires changes to proceed.Apr 11 2016, 3:50 PM
mehdi_amini added inline comments.Apr 11 2016, 4:11 PM
lib/Analysis/MemoryBuiltins.cpp
53–76

Is this related to your attribute change? If it just cleanup, commit separately now.

98–103

Remove the brief :)

113

Why requires MallocLike here?

george.burgess.iv edited edge metadata.
george.burgess.iv marked 2 inline comments as done.

Addressed all feedback.

lib/Analysis/MemoryBuiltins.cpp
53–76

Is this related to your attribute change?

This patch depends on this change, but the change isn't dependent on the rest of the patch.

If it just cleanup, commit separately now

I don't think it's strictly a cleanup, because it really doesn't simplify anything or add value, aside from enabling us to make new AllocFnsTy structs at runtime, which is only useful for allocsize.

If you still feel that I should check it in separately, I'm happy to do so.

113

Our choices here are OpNewLike, MallocLike, CallocLike, ReallocLike, StrDupLike, AllocLike (which is Malloc|Calloc|StrDup), and AnyAlloc (which is AllocLike|ReallocLike).

  • CallocLike won't work, because it requires the function to return zeroed memory. allocsize makes no such guarantee, so, AllocLike, AnyAlloc, and CallocLike are out.
  • StrDupLike isn't correct either, because we only deal in integer sizes.
  • ReallocLike isn't guaranteed, because we may have this on malloc.
  • allocsize makes no guarantees about the result of the function it's tagged on being non-null, so OpNewLike is out.

...So we're left with MallocLike. :)

Added a comment addressing why MallocLike was chosen.

mehdi_amini accepted this revision.Apr 11 2016, 5:56 PM
mehdi_amini edited edge metadata.

LGTM.

lib/Analysis/MemoryBuiltins.cpp
53–76

OK it wasn't clear to me that this was needed, I see now that you are instantiating an AllocFnsTy and you don't have a LibFunc::Func to put in.
Either way is fine.

113

OK, I misread the API contract the first time, here the client is requesting the "allocationData" for a specific type of allocation.

This revision is now accepted and ready to land.Apr 11 2016, 5:56 PM

r266032. Thanks again!