Page MenuHomePhabricator

[MemCpyOpt] Use dereferenceable pointer helper

Authored by nikic on Oct 4 2020, 1:37 PM.



The call slot optimization has some home-grown code for checking whether the destination is dereferenceable. Replace this with the generic isDereferenceableAndAlignedPointer() helper.

I'm not checking alignment here, because that is currently handled separately and may be an enforced alignment for allocas. The clean way of integrating that part would probably be to accept a callback in isDereferenceableAndAlignedPointer() for the actual isAligned check, which would then have a chance to use an enforced alignment instead.

Diff Detail

Event Timeline

nikic created this revision.Oct 4 2020, 1:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 4 2020, 1:37 PM
nikic requested review of this revision.Oct 4 2020, 1:37 PM
nikic added inline comments.Oct 4 2020, 1:47 PM

By the way, is there any existing API for this? That is, to move an instruction and its dependencies up, for trivially speculatable cases. I've seen CodeMoverUtils, but that's a very big hammer (even requiring PDT).

efriedma accepted this revision.Oct 4 2020, 2:26 PM


We could probably clean up the alignment handling in this pass now that the src and dest alignment of memcpy are separate.


Not really related to this patch, but is mayThrow actually the right check? Do we need willreturn instead?

This revision is now accepted and ready to land.Oct 4 2020, 2:26 PM
efriedma added inline comments.Oct 4 2020, 2:28 PM

I can't think of anything off the top of my head. You wouldn't usually want to speculate an arbitrary number of instructions without some cost model, anyway, and then it gets really complicated.

This revision was landed with ongoing or failed builds.Oct 6 2020, 9:45 AM
This revision was automatically updated to reflect the committed changes.