[MemCpyOpt] Use dereferenceable pointer helper
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 4 Oct 2020 19:03:02 +0000 (21:03 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 6 Oct 2020 16:41:19 +0000 (18:41 +0200)
commit616f5450480214d40dd69a5f5f0f10b41bd4b3e2
tree7e726173755353119960e67e925fbb6d2f5608df
parent6b441ca523cd6be9475106408a60989ad1f5ae55
[MemCpyOpt] Use dereferenceable pointer helper

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.

This allows the destination to be a GEP (among other things), though
the two open TODOs may prevent it from working in practice.

Differential Revision: https://reviews.llvm.org/D88805
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/test/Transforms/MemCpyOpt/callslot.ll