Currently writtenBetween can miss clobbers of Loc between End and Clobber
if Loc is not clobbered by End itself. End's defining accesses only have
to contain defs/phis that may clobber memory clobbered by End. But
writtenBetween needs to check for all write-clobbers of Loc.
To guarantee we see all write clobbers of Loc between the found Clobber
and End, I think we have to look at all uses of Clobber between Clobber
and End.
This fixes 2 mis-compiles illustrated in
llvm/test/Transforms/MemCpyOpt/memcpy-byval-forwarding-clobbers.ll
The implementation in this patch may consider write-clobbers on paths
that do not reach End as writes between Clobber and End. There's
potential to improve this as follow-up.
I'd move the getClobberingMemoryAccess() call into the !isa<MemoryUse> branch. Not much point doing it if we're going to discard it.