Make the memory dependence queries in the memcpy optimizer nonlocal.
This eliminates 28% of the llvm.memcpy calls in librustc.
Fixes PR28958.
Paths
| Differential D23470
[memcpyopt] Memcpy-memcpy dependence isn't detected across basic blocks Needs ReviewPublic Authored by pcwalton on Aug 12 2016, 3:47 PM.
Details
Diff Detail Event TimelineComment Actions Thanks for the patch! Could you please reduce the testcase? It contains quite a few unnecessary instructions. Something along the lines of the following would be more appropriate: define void @wobble(i8* noalias nocapture sret %arg, i8* nocapture readonly dereferenceable(64) %arg1, i1 zeroext %arg3) local_unnamed_addr #0 { bb: %tmp51 = alloca [64 x i8], align 8 %tmp51.sub = getelementptr inbounds [64 x i8], [64 x i8]* %tmp51, i64 0, i64 0 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp51.sub, i8* nonnull %arg1, i64 64, i32 8, i1 false) br i1 %arg3, label %bb11, label %bb12 bb11: ; preds = %bb tail call void @ham() #3 unreachable bb12: ; preds = %bb call void @llvm.memcpy.p0i8.p0i8.i64(i8* %arg, i8* %tmp51.sub, i64 64, i32 8, i1 false) ret void } ; Function Attrs: argmemonly nounwind declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #1 ; Function Attrs: noreturn nounwind declare void @ham() local_unnamed_addr #2
Comment Actions I posted an updated version of this patch for review here: https://reviews.llvm.org/D38374
Revision Contents
Diff 67929 include/llvm/Analysis/MemoryDependenceAnalysis.h
lib/Analysis/MemDepPrinter.cpp
lib/Analysis/MemoryDependenceAnalysis.cpp
lib/Transforms/Scalar/GVN.cpp
lib/Transforms/Scalar/MemCpyOptimizer.cpp
test/Transforms/MemCpyOpt/nonlocal-memcpy-memcpy.ll
|
I figure you are trying to make the two API's look the same, but the honest truth is: the other API sucks :)
There are a bunch of instructions that affect memory that don't have MemoryLocation's (calls are a good example).
I know you just are pushing the first two lines it does up, and that this means the function will crash on things like fences, etc, but we shouldn't make it worse :)
In any case, if you really want to do this, this should be shoved into a different patch, as it's completely unrelated to your change