Closed
Description
I tried the following code:
%0 = type { i8, [753 x i8] }
define void @src(ptr nocapture noundef %arg) local_unnamed_addr {
bb:
%i = alloca %0, align 1
call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(754) %i, ptr noundef nonnull align 1 dereferenceable(754) %arg, i64 754, i1 false)
%i1 = getelementptr inbounds i8, ptr %i, i64 1
store i8 1, ptr %arg, align 1
%i2 = getelementptr inbounds i8, ptr %arg, i64 1
call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(753) %i2, ptr noundef nonnull align 1 dereferenceable(753) %i1, i64 753, i1 false)
ret void
}
define void @tgt(ptr nocapture noundef %arg) local_unnamed_addr {
bb:
store i8 1, ptr %arg, align 1
ret void
}
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
We can eliminate all memcpy
.
alive2: https://alive2.llvm.org/ce/z/hCPePV
From: rust-lang/rust#122610 (comment).