Page MenuHomePhabricator

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

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



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.

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

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

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



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.