This is an archive of the discontinued LLVM Phabricator instance.

Allow call-slop optzn for destinations with a suitable dereferenceable attribute
ClosedPublic

Authored by dotdash on Oct 16 2014, 12:22 PM.

Details

Summary

Currently, call slot optimization requires that if the destination is an
argument, the argument has the sret attribute. This is to ensure that
the memory access won't trap. In addition to sret, we can also allow the
optimization to happen for arguments that have the new dereferenceable
attribute, which gives the same guarantee.

Diff Detail

Event Timeline

dotdash updated this revision to Diff 15038.Oct 16 2014, 12:22 PM
dotdash retitled this revision from to Allow call-slop optzn for destinations with a suitable dereferenceable attribute.
dotdash updated this object.
dotdash edited the test plan for this revision. (Show Details)
dotdash added a subscriber: Unknown Object (MLST).
hfinkel added inline comments.
lib/Transforms/Scalar/MemCpyOptimizer.cpp
637

But if you do it this way you're now *requiring* the dereferenceable attribute, and we don't want to do that.

What you want to do is keep the existing logic for sret, and just add additional support for dereferenceable.

dotdash added inline comments.Oct 16 2014, 12:43 PM
lib/Transforms/Scalar/MemCpyOptimizer.cpp
637

How so? The new check just skips the sret check if we already know that we have enough deferenceable bytes.

If there is no dereferenceable attribute, getDereferenceableBytes() returns 0, which is < srcSize and so we do the sret check, and only if that fails, false is returned.

hfinkel accepted this revision.Oct 16 2014, 12:49 PM
hfinkel added a reviewer: hfinkel.

LGTM, thanks!

lib/Transforms/Scalar/MemCpyOptimizer.cpp
637

You're right; sorry about that.

This revision is now accepted and ready to land.Oct 16 2014, 12:49 PM
Diffusion closed this revision.Oct 16 2014, 12:53 PM
Diffusion updated this revision to Diff 15040.

Closed by commit rL219950 (authored by bsteinbr).