[PATCH] D117679: [MemCpyOpt] Fix metadata merging during call slot optimization

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 20 00:26:37 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd7bff2e9d2e4: [MemCpyOpt] Fix metadata merging during call slot optimization (authored by nikic).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117679/new/

https://reviews.llvm.org/D117679

Files:
  llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
  llvm/test/Transforms/MemCpyOpt/callslot_noalias.ll


Index: llvm/test/Transforms/MemCpyOpt/callslot_noalias.ll
===================================================================
--- llvm/test/Transforms/MemCpyOpt/callslot_noalias.ll
+++ llvm/test/Transforms/MemCpyOpt/callslot_noalias.ll
@@ -3,11 +3,12 @@
 
 declare void @func(i8* %dst)
 
-; TODO: The noalias metadata on the call is currently incorrect.
+; The noalias metadata from the call, the load and the store should be merged,
+; so that no metadata is left on the call.
 define i8 @test(i8* dereferenceable(1) noalias %dst) {
 ; CHECK-LABEL: @test(
 ; CHECK-NEXT:    [[TMP:%.*]] = alloca i8, align 1
-; CHECK-NEXT:    call void @func(i8* nocapture [[DST:%.*]]) #[[ATTR0:[0-9]+]], !noalias !0
+; CHECK-NEXT:    call void @func(i8* nocapture [[DST:%.*]]) #[[ATTR0:[0-9]+]]{{$}}
 ; CHECK-NEXT:    [[V2:%.*]] = load i8, i8* [[DST]], align 1, !alias.scope !0
 ; CHECK-NEXT:    ret i8 [[V2]]
 ;
Index: llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -1022,6 +1022,8 @@
                          LLVMContext::MD_invariant_group,
                          LLVMContext::MD_access_group};
   combineMetadata(C, cpyLoad, KnownIDs, true);
+  if (cpyLoad != cpyStore)
+    combineMetadata(C, cpyStore, KnownIDs, true);
 
   ++NumCallSlot;
   return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117679.401530.patch
Type: text/x-patch
Size: 1422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220120/f48f1024/attachment.bin>


More information about the llvm-commits mailing list