This is an archive of the discontinued LLVM Phabricator instance.

Make the memory dependence queries in the memcpy optimizer nonlocal
AbandonedPublic

Authored by mehdi_amini on Aug 12 2016, 3:43 PM.

Details

Summary

Make the memory dependence queries in the memcpy optimizer nonlocal.

This eliminates 28% of the llvm.memcpy calls in librustc.

Fixes PR28958.

Diff Detail

Repository
rL LLVM

Event Timeline

pcwalton updated this revision to Diff 67925.Aug 12 2016, 3:43 PM
pcwalton retitled this revision from to Make the memory dependence queries in the memcpy optimizer nonlocal.
pcwalton updated this object.
pcwalton set the repository for this revision to rL LLVM.
pcwalton updated this object.
mehdi_amini commandeered this revision.Aug 12 2016, 3:45 PM
mehdi_amini added a reviewer: pcwalton.
mehdi_amini added a subscriber: mehdi_amini.

Please add llvm-commits as a subscriber from the beginning, otherwise the mailing list lacking context. We have to close this one.

mehdi_amini abandoned this revision.Aug 12 2016, 3:45 PM
majnemer edited edge metadata.Aug 12 2016, 3:48 PM

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