[PATCH] D38374: [memcpyopt] Memcpy-memcpy dependence isn't detected across basic blocks

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 11:54:38 PDT 2017


sunfish created this revision.
Herald added a subscriber: aheejin.

This picks up the patch from https://reviews.llvm.org/D23470 and updates it to address the review feedback provided there.

The patch makes the memory dependence queries in the memcpy optimizer nonlocal. This notably allows it to eliminate many llvm.memcpy calls in librustc and Rust code in general.

@majnemer requested <https://reviews.llvm.org/D23470#514468> the testcase be reduced and provided a suggested reduction. I reduced that even further and added it as a testcase. I kept the existing two testcases, because they're testing that memcpyopt works in settings closely resembling the specific real-world usage that motivates this patch, though I did reduce them somewhat.

@dberlin requested <https://reviews.llvm.org/D23470#inline-201149> that the MemoryDependenceAnalysis API not be altered for the worse; I've modified the patch so that it leaves the existing interface in place, and adds a new interface for what this patch needs. Other users of the existing interface don't need to change, and the old interface can be implemented in terms of the new interface, so this means that very little code actually needs to change here.

It might be desirable to use MemorySSA, however MemCpyOpt is currently using MemoryDependenceAnalysis for everything, and it seems desirable to avoid using a mix of both within the same pass, and updating the whole pass to use MemorySSA is a bigger project than I'm hoping to take on here.


Repository:
  rL LLVM

https://reviews.llvm.org/D38374

Files:
  include/llvm/Analysis/MemoryDependenceAnalysis.h
  lib/Analysis/MemoryDependenceAnalysis.cpp
  lib/Transforms/Scalar/MemCpyOptimizer.cpp
  test/Transforms/MemCpyOpt/memcpy-invoke-memcpy.ll
  test/Transforms/MemCpyOpt/nonlocal-memcpy-memcpy.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38374.117025.patch
Type: text/x-patch
Size: 10657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170928/a5e5bb20/attachment.bin>


More information about the llvm-commits mailing list