Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MemCpyOpt] The store instruction should not be removed by DSE. #70578

Closed
DianQK opened this issue Oct 29, 2023 · 3 comments · Fixed by #70580 or llvm/llvm-project-release-prs#757
Closed

Comments

@DianQK
Copy link
Member

DianQK commented 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.

@DianQK
Copy link
Member Author

DianQK commented Oct 29, 2023

/cherry-pick 0c4f326

@DianQK DianQK reopened this Oct 29, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 29, 2023

/branch llvm/llvm-project-release-prs/issue70578

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 29, 2023

/pull-request llvm/llvm-project-release-prs#757

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment