[PATCH] D155179: [MemCpyOpt] precommit tests to add multi-BB stack-move optimization to check crash for D153453 (NFC)
Kohei Asano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 13 04:36:46 PDT 2023
khei4 created this revision.
Herald added a subscriber: tpr.
Herald added a project: All.
khei4 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, jplehr, sstefan1.
Herald added a project: LLVM.
Once https://reviews.llvm.org/D153453 landed, some clang and openmp tests crashed with assertion failure
clang-17: /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/llvm/lib/IR/Instruction.cpp:126: bool llvm::Instruction::comesBefore(const llvm::Instruction*) const: Assertion `Parent == Other->Parent && "cross-BB instruction order comparison"' failed.
to avoid this, add multi-BB load/store separated tests
https://reviews.llvm.org/D155179
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,10 +381,92 @@
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
+; CHECK-SAME: (i1 [[B:%.*]]) {
+; CHECK-NEXT: [[SRC:%.*]] = alloca i32, align 4
+; CHECK-NEXT: [[DEST:%.*]] = alloca i32, align 4
+; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nocapture [[SRC]])
+; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nocapture [[DEST]])
+; CHECK-NEXT: store i32 42, ptr [[SRC]], align 4
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @use_nocapture(ptr nocapture [[SRC]])
+; CHECK-NEXT: br label [[BB0:%.*]]
+; CHECK: bb0:
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[DEST]], ptr align 4 [[SRC]], i64 4, i1 false)
+; CHECK-NEXT: br label [[BB1:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[TMP2:%.*]] = call i32 @use_nocapture(ptr nocapture [[DEST]])
+; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr nocapture [[SRC]])
+; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr nocapture [[DEST]])
+; CHECK-NEXT: ret void
+;
+ %src = alloca i32, align 4
+ %dest = alloca i32, align 4
+ call void @llvm.lifetime.start.p0(i64 4, ptr nocapture %src)
+ call void @llvm.lifetime.start.p0(i64 4, ptr nocapture %dest)
+ store i32 42, ptr %src
+ %1 = call i32 @use_nocapture(ptr nocapture %src)
+ br label %bb0
+
+bb0:
+ call void @llvm.memcpy.p0.p0.i64(ptr align 4 %dest, ptr align 4 %src, i64 4, i1 false)
+ br label %bb1
+
+bb1:
+ %2 = call i32 @use_nocapture(ptr nocapture %dest)
+ call void @llvm.lifetime.end.p0(i64 4, ptr nocapture %src)
+ call void @llvm.lifetime.end.p0(i64 4, ptr nocapture %dest)
+ ret void
+}
+
+
+; TODO: merge allocas for bb-separated, but logically straight
+define void @multi_bb_load_store(i1 %b) {
+; CHECK-LABEL: define void @multi_bb_load_store
+; CHECK-SAME: (i1 [[B:%.*]]) {
+; CHECK-NEXT: [[SRC:%.*]] = alloca i32, align 4
+; CHECK-NEXT: [[DEST:%.*]] = alloca i32, align 4
+; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nocapture [[SRC]])
+; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nocapture [[DEST]])
+; CHECK-NEXT: store i32 42, ptr [[SRC]], align 4
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @use_nocapture(ptr nocapture [[SRC]])
+; CHECK-NEXT: [[SRC_VAL:%.*]] = load i32, ptr [[SRC]], align 4
+; CHECK-NEXT: br label [[BB0:%.*]]
+; CHECK: bb0:
+; CHECK-NEXT: store i32 [[SRC_VAL]], ptr [[DEST]], align 4
+; CHECK-NEXT: br label [[BB1:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: [[TMP2:%.*]] = call i32 @use_nocapture(ptr nocapture [[DEST]])
+; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr nocapture [[SRC]])
+; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr nocapture [[DEST]])
+; CHECK-NEXT: ret void
+;
+ %src = alloca i32, align 4
+ %dest = alloca i32, align 4
+ call void @llvm.lifetime.start.p0(i64 4, ptr nocapture %src)
+ call void @llvm.lifetime.start.p0(i64 4, ptr nocapture %dest)
+ store i32 42, ptr %src
+ %1 = call i32 @use_nocapture(ptr nocapture %src)
+
+ %src.val = load i32, ptr %src
+ br label %bb0
+
+bb0:
+ store i32 %src.val, ptr %dest
+ br label %bb1
+
+bb1:
+ %2 = call i32 @use_nocapture(ptr nocapture %dest)
+ call void @llvm.lifetime.end.p0(i64 4, ptr nocapture %src)
+ call void @llvm.lifetime.end.p0(i64 4, ptr nocapture %dest)
+ ret void
+}
+
; TODO: merge allocas for multi basicblocks, s.t. all copy-dominated
; uses are satisfy the condition.
-define void @multi_bb(i1 %b) {
-; CHECK-LABEL: define void @multi_bb
+define void @multi_bb_simple_br(i1 %b) {
+; CHECK-LABEL: define void @multi_bb_simple_br
; CHECK-SAME: (i1 [[B:%.*]]) {
; CHECK-NEXT: [[SRC:%.*]] = alloca [[STRUCT_FOO:%.*]], align 4
; CHECK-NEXT: [[DEST:%.*]] = alloca [[STRUCT_FOO]], align 4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155179.539947.patch
Type: text/x-patch
Size: 4070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230713/f73ae80d/attachment.bin>
More information about the llvm-commits
mailing list