[MemCpyOpt] The store instruction should not be removed by DSE. #70578
Description
opened on Oct 29, 2023
This IR is reduced from rust-lang/rust#116976.
declare void @f_byval(ptr byval(i32))
declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1)
define void @byval_param_noalias_metadata(ptr align 4 byval(i32) %ptr) {
%tmp = alloca i32, align 4
store i32 1, ptr %ptr, !noalias !2
call void @llvm.memcpy.p0.p0.i64(ptr align 4 %tmp, ptr align 4 %ptr, i64 4, i1 false)
call void @f_byval(ptr align 4 byval(i32) %tmp), !alias.scope !2
ret void
}
!0 = !{!0}
!1 = !{!1, !0}
!2 = !{!1}
The DSE removed the store instruction because MemCpyOpt did not update the alias information.
declare void @f_byval(ptr byval(i32))
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0
define void @byval_param_noalias_metadata(ptr byval(i32) align 4 %ptr) {
call void @f_byval(ptr byval(i32) align 4 %ptr), !alias.scope !0
ret void
}
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
!0 = !{!1}
!1 = distinct !{!1, !2}
!2 = distinct !{!2}
godbolt: https://llvm.godbolt.org/z/qMncEEseK
Similar to #67539.
Metadata
Assignees
Type
Projects
Status
Done
Activity