[PATCH] D155571: [MemCpyOpt] add terminator user test for D153453(NFC)

Kohei Asano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 02:57:32 PDT 2023


khei4 created this revision.
khei4 added reviewers: nikic, hoy.
Herald added a subscriber: StephenFan.
Herald added a project: All.
khei4 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

to address https://reviews.llvm.org/D153453#4507237


https://reviews.llvm.org/D155571

Files:
  llvm/test/Transforms/MemCpyOpt/stack-move.ll


Index: llvm/test/Transforms/MemCpyOpt/stack-move.ll
===================================================================
--- llvm/test/Transforms/MemCpyOpt/stack-move.ll
+++ llvm/test/Transforms/MemCpyOpt/stack-move.ll
@@ -381,6 +381,52 @@
   ret void
 }
 
+; TODO: if the last user is terminator, we won't insert lifetime.end.
+; For multi-bb patch, we will insert it for next immidiate post dominator block.
+define void @terminator_lastuse() personality i32 0 {
+; CHECK-LABEL: define void @terminator_lastuse() personality i32 0 {
+; CHECK-NEXT:    [[SRC:%.*]] = alloca [[STRUCT_FOO:%.*]], align 4
+; CHECK-NEXT:    [[DEST:%.*]] = alloca [[STRUCT_FOO]], align 4
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 12, ptr nocapture [[SRC]])
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 12, ptr nocapture [[DEST]])
+; CHECK-NEXT:    store [[STRUCT_FOO]] { i32 10, i32 20, i32 30 }, ptr [[SRC]], align 4
+; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @use_nocapture(ptr nocapture [[SRC]])
+; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[DEST]], ptr align 4 [[SRC]], i64 12, i1 false)
+; CHECK-NEXT:    [[TMP2:%.*]] = call i32 @use_nocapture(ptr nocapture [[DEST]])
+; CHECK-NEXT:    call void @llvm.lifetime.end.p0(i64 12, ptr [[SRC]])
+; CHECK-NEXT:    [[RV:%.*]] = invoke fastcc i32 @use_nocapture(ptr byval([[STRUCT_FOO]]) [[DEST]])
+; CHECK-NEXT:    to label [[SUC:%.*]] unwind label [[UNW:%.*]]
+; CHECK:       unw:
+; CHECK-NEXT:    [[LP:%.*]] = landingpad i32
+; CHECK-NEXT:    cleanup
+; CHECK-NEXT:    br label [[EHCLEANUP:%.*]]
+; CHECK:       ehcleanup:
+; CHECK-NEXT:    resume i32 0
+; CHECK:       suc:
+; CHECK-NEXT:    ret void
+;
+  %src = alloca %struct.Foo, align 4
+  %dest = alloca %struct.Foo, align 4
+  call void @llvm.lifetime.start.p0(i64 12, ptr nocapture %src)
+  call void @llvm.lifetime.start.p0(i64 12, ptr nocapture %dest)
+  store %struct.Foo { i32 10, i32 20, i32 30 }, ptr %src
+  %1 = call i32 @use_nocapture(ptr nocapture %src)
+
+  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %dest, ptr align 4 %src, i64 12, i1 false)
+
+  %2 = call i32 @use_nocapture(ptr nocapture %dest)
+  call void @llvm.lifetime.end.p0(i64 12, ptr %src)
+  %rv = invoke fastcc i32 @use_nocapture(ptr byval(%struct.Foo) %dest)
+  to label %suc unwind label %unw
+unw:
+  %lp = landingpad i32 cleanup
+  br label %ehcleanup
+ehcleanup:
+  resume i32 0
+suc:
+  ret void
+}
+
 ; TODO: merge allocas for bb-separated, but logically straight
 define void @multi_bb_memcpy(i1 %b) {
 ; CHECK-LABEL: define void @multi_bb_memcpy


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155571.541418.patch
Type: text/x-patch
Size: 2561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230718/11536e7a/attachment.bin>


More information about the llvm-commits mailing list