Because memory intrinsics are handled differently than other calls, we need to check them for tail call eligiblity in the legalizer. This allows us to still inline them when it's beneficial to do so, but also tail call when possible.
This adds simple tail calling support for when the intrinsic is followed by a return.
It ports the attribute checks from TargetLowering::isInTailCallPosition into a similarly-named function in LegalizerHelper.cpp. The target-specific isUsedByReturnOnly hook is not ported here.
Update tailcall-mem-intrinsics.ll to show that GlobalISel can now tail call memory intrinsics.
Update legalize-memcpy-et-al.mir to have a case where we don't tail call.
Can you make it clearer in this comment that it's done by the legalizer.