[llvm-branch-commits] [llvm] bb29e1e - [MemCpyOpt] Combine alias metadatas when replacing byval arguments (#70580)
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Oct 30 02:21:37 PDT 2023
Author: DianQK
Date: 2023-10-30T10:21:23+01:00
New Revision: bb29e1ead22f41921fd0005a9a984a9810b9fef2
URL: https://github.com/llvm/llvm-project/commit/bb29e1ead22f41921fd0005a9a984a9810b9fef2
DIFF: https://github.com/llvm/llvm-project/commit/bb29e1ead22f41921fd0005a9a984a9810b9fef2.diff
LOG: [MemCpyOpt] Combine alias metadatas when replacing byval arguments (#70580)
Fixes #70578.
(cherry picked from commit 0c4f326d8bc97a2fdb0533a68dbe1a7164da3911)
Added:
Modified:
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/test/Transforms/MemCpyOpt/memcpy.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 91dc5018d232ebe..a95d6adf36d6dd2 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -1603,6 +1603,7 @@ bool MemCpyOptPass::processByValArgument(CallBase &CB, unsigned ArgNo) {
<< " " << CB << "\n");
// Otherwise we're good! Update the byval argument.
+ combineAAMetadata(&CB, MDep);
CB.setArgOperand(ArgNo, MDep->getSource());
++NumMemCpyInstr;
return true;
diff --git a/llvm/test/Transforms/MemCpyOpt/memcpy.ll b/llvm/test/Transforms/MemCpyOpt/memcpy.ll
index f7c1c85517ffa32..7488203d5db16dd 100644
--- a/llvm/test/Transforms/MemCpyOpt/memcpy.ll
+++ b/llvm/test/Transforms/MemCpyOpt/memcpy.ll
@@ -393,6 +393,7 @@ declare void @f1(ptr nocapture sret(%struct.big))
declare void @f2(ptr)
declare void @f(ptr)
+declare void @f_byval(ptr byval(i32))
declare void @f_full_readonly(ptr nocapture noalias readonly)
define void @immut_param(ptr align 4 noalias %val) {
@@ -709,6 +710,19 @@ define void @immut_param_noalias_metadata(ptr align 4 byval(i32) %ptr) {
ret void
}
+define void @byval_param_noalias_metadata(ptr align 4 byval(i32) %ptr) {
+; CHECK-LABEL: @byval_param_noalias_metadata(
+; CHECK-NEXT: store i32 1, ptr [[PTR:%.*]], align 4, !noalias !0
+; CHECK-NEXT: call void @f_byval(ptr byval(i32) align 4 [[PTR]])
+; CHECK-NEXT: ret void
+;
+ %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}
More information about the llvm-branch-commits
mailing list