If the memcpy libfunc is marked as not being available (e.g. via the -fno-builtin flag), we shouldn't lower intrinsic memcpy into an actual memcpy function call.
The same should probably be done for other intrinsics (that can be spontaneously generated by e.g. clang without the functions being explicitly mentioned) that can end up lowered into a function call, but this is the one I've run into in practice.
Adding a test for this that runs on AArch64, as the patch requires separate changes to all of SelectionDAG, FastISel and GlobalISel.
This needs to be dropped. D85199 switches these to using proper legalizeable instructions. It may make more sense for the libcall action to fail if the libraryinfo does not have memcpy