This is an archive of the discontinued LLVM Phabricator instance.

[deref] Handle byval/byref/sret/inalloc/preallocated arguments for deref-at-point semantics
ClosedPublic

Authored by reames on Mar 24 2021, 5:05 PM.

Details

Summary

All of these are scoped allocations which remain dereferenceable during the lifetime of the callee.

Diff Detail

Event Timeline

reames created this revision.Mar 24 2021, 5:05 PM
reames requested review of this revision.Mar 24 2021, 5:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2021, 5:05 PM
nikic added a subscriber: nikic.Mar 25 2021, 1:38 AM
nikic added inline comments.
llvm/lib/IR/Value.cpp
747

Why is the check for a sized type necessary? For an unsized type there would be no dereferenceable bytes, but I don't think it's something that really affects canBeFreed itself?

reames added inline comments.Mar 25 2021, 7:51 AM
llvm/lib/IR/Value.cpp
747

I don't know. It seemed like enough of a cornercase to preserve the conservative handling from elsewhere. I'm happy to remove it if you are confident doing so is correct.

nikic added inline comments.Mar 25 2021, 10:15 AM
llvm/lib/IR/Value.cpp
747

The check in the getPointerDereferenceableBytes() implementation is present because we're querying the actual type size there, which is going to assert for unsized types. I'm reasonably sure that we don't need the check here.

reames updated this revision to Diff 333420.Mar 25 2021, 2:00 PM

address review comment

nikic accepted this revision.Mar 25 2021, 2:17 PM

LGTM

llvm/lib/IR/Value.cpp
745

This is probably going to warn due to unused variable. hasPointeeInMemoryValueAttr() is the equivalent boolean query.

This revision is now accepted and ready to land.Mar 25 2021, 2:17 PM
This revision was landed with ongoing or failed builds.Mar 25 2021, 2:48 PM
This revision was automatically updated to reflect the committed changes.