[memcpyopt] Teach memcpyopt to optimize across basic blocks
authorDan Gohman <dan433584@gmail.com>
Wed, 20 Dec 2017 01:36:25 +0000 (01:36 +0000)
committerDan Gohman <dan433584@gmail.com>
Wed, 20 Dec 2017 01:36:25 +0000 (01:36 +0000)
commitaa3922819e1e80ccf7cf7e8bf61e86cd240b056b
treec6ffcd1acc31d099209cb806ad09855822edb34a
parentb1ae03fd6141a5511b6de6bc600b29a476b7ee70
[memcpyopt] Teach memcpyopt to optimize across basic blocks

This teaches memcpyopt to make a non-local memdep query when a local query
indicates that the dependency is non-local. This notably allows it to
eliminate many more llvm.memcpy calls in common Rust code, often by 20-30%.

This is r319482 and r319483, along with fixes for PR35519: fix the
optimization that merges stores into memsets to preserve cached memdep
info, and fix memdep's non-local caching strategy to not assume that larger
queries are always more conservative than smaller ones.

Fixes PR28958 and PR35519.

Differential Revision: https://reviews.llvm.org/D40802

llvm-svn: 321138
llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/test/Transforms/MemCpyOpt/memcpy-invoke-memcpy.ll [new file with mode: 0644]
llvm/test/Transforms/MemCpyOpt/merge-into-memset.ll [new file with mode: 0644]
llvm/test/Transforms/MemCpyOpt/mixed-sizes.ll [new file with mode: 0644]
llvm/test/Transforms/MemCpyOpt/nonlocal-memcpy-memcpy.ll [new file with mode: 0644]