This extends stack-move optimization https://reviews.llvm.org/D155406 in a more forward dataflow-sensitive way. This patch enables the merging of the following cases.
- Memory locations are fully overwritten(called a Def) and read from the same alias.
- Conflicts never happen for any execution path, although both the src and dest are used after the copy.
The implementation difference from https://reviews.llvm.org/D155406 is
- Add ModState, which represents which of src or dest finally modify the memory location in the dataflow.
- Propagate it on the CFG, only seeing the same memory location users collected by User tracking on CaptureTracking.
- Remove reachability or Dominator relations checks on the ModRef checks.
This patch is expected to cover all stack move cases originally covered by pcwalton's patch.
There seem to be almost no compile-time regressions. https://llvm-compile-time-tracker.com/compare.php?from=f61ed5180ebb0dfe840722c6c99244f90d3183f9&to=c0c251970ef118ce15b012ea3d45deab862396c9&stat=instructions:u
This should be in an anonymous namespace.