[llvm] 22664a3 - [MemCpyOpt] Don't use array allocas in tests (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 4 12:50:37 PDT 2020
Author: Nikita Popov
Date: 2020-10-04T21:50:27+02:00
New Revision: 22664a325167086260aa2d1ff629686020f2b27d
URL: https://github.com/llvm/llvm-project/commit/22664a325167086260aa2d1ff629686020f2b27d
DIFF: https://github.com/llvm/llvm-project/commit/22664a325167086260aa2d1ff629686020f2b27d.diff
LOG: [MemCpyOpt] Don't use array allocas in tests (NFC)
Apparently querying dereferenceability of array allocations is
being intentionally penalized (https://reviews.llvm.org/D41398),
so avoid using them in tests.
Added:
Modified:
llvm/test/Transforms/MemCpyOpt/callslot.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/MemCpyOpt/callslot.ll b/llvm/test/Transforms/MemCpyOpt/callslot.ll
index 4b65fbcf88c2..5268dd9c8da0 100644
--- a/llvm/test/Transforms/MemCpyOpt/callslot.ll
+++ b/llvm/test/Transforms/MemCpyOpt/callslot.ll
@@ -3,86 +3,106 @@
define i8 @read_dest_between_call_and_memcpy() {
; CHECK-LABEL: @read_dest_between_call_and_memcpy(
-; CHECK-NEXT: [[DEST:%.*]] = alloca i8, i64 16, align 1
-; CHECK-NEXT: [[SRC:%.*]] = alloca i8, i64 16, align 1
-; CHECK-NEXT: store i8 1, i8* [[DEST]], align 1
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[SRC]], i8 0, i64 16, i1 false)
-; CHECK-NEXT: [[X:%.*]] = load i8, i8* [[DEST]], align 1
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[DEST]], i8 0, i64 16, i1 false)
+; CHECK-NEXT: [[DEST:%.*]] = alloca [16 x i8], align 1
+; CHECK-NEXT: [[SRC:%.*]] = alloca [16 x i8], align 1
+; CHECK-NEXT: [[DEST_I8:%.*]] = bitcast [16 x i8]* [[DEST]] to i8*
+; CHECK-NEXT: [[SRC_I8:%.*]] = bitcast [16 x i8]* [[SRC]] to i8*
+; CHECK-NEXT: store i8 1, i8* [[DEST_I8]], align 1
+; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[SRC_I8]], i8 0, i64 16, i1 false)
+; CHECK-NEXT: [[X:%.*]] = load i8, i8* [[DEST_I8]], align 1
+; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[DEST_I8]], i8 0, i64 16, i1 false)
; CHECK-NEXT: ret i8 [[X]]
;
- %dest = alloca i8, i64 16
- %src = alloca i8, i64 16
- store i8 1, i8* %dest
- call void @llvm.memset.p0i8.i64(i8* %src, i8 0, i64 16, i1 false)
- %x = load i8, i8* %dest
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest, i8* %src, i64 16, i1 false)
+ %dest = alloca [16 x i8]
+ %src = alloca [16 x i8]
+ %dest.i8 = bitcast [16 x i8]* %dest to i8*
+ %src.i8 = bitcast [16 x i8]* %src to i8*
+ store i8 1, i8* %dest.i8
+ call void @llvm.memset.p0i8.i64(i8* %src.i8, i8 0, i64 16, i1 false)
+ %x = load i8, i8* %dest.i8
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest.i8, i8* %src.i8, i64 16, i1 false)
ret i8 %x
}
define i8 @read_src_between_call_and_memcpy() {
; CHECK-LABEL: @read_src_between_call_and_memcpy(
-; CHECK-NEXT: [[DEST:%.*]] = alloca i8, i64 16, align 1
-; CHECK-NEXT: [[SRC:%.*]] = alloca i8, i64 16, align 1
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[SRC]], i8 0, i64 16, i1 false)
-; CHECK-NEXT: [[X:%.*]] = load i8, i8* [[SRC]], align 1
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST]], i8* [[SRC]], i64 16, i1 false)
+; CHECK-NEXT: [[DEST:%.*]] = alloca [16 x i8], align 1
+; CHECK-NEXT: [[SRC:%.*]] = alloca [16 x i8], align 1
+; CHECK-NEXT: [[DEST_I8:%.*]] = bitcast [16 x i8]* [[DEST]] to i8*
+; CHECK-NEXT: [[SRC_I8:%.*]] = bitcast [16 x i8]* [[SRC]] to i8*
+; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[SRC_I8]], i8 0, i64 16, i1 false)
+; CHECK-NEXT: [[X:%.*]] = load i8, i8* [[SRC_I8]], align 1
+; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST_I8]], i8* [[SRC_I8]], i64 16, i1 false)
; CHECK-NEXT: ret i8 [[X]]
;
- %dest = alloca i8, i64 16
- %src = alloca i8, i64 16
- call void @llvm.memset.p0i8.i64(i8* %src, i8 0, i64 16, i1 false)
- %x = load i8, i8* %src
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest, i8* %src, i64 16, i1 false)
+ %dest = alloca [16 x i8]
+ %src = alloca [16 x i8]
+ %dest.i8 = bitcast [16 x i8]* %dest to i8*
+ %src.i8 = bitcast [16 x i8]* %src to i8*
+ call void @llvm.memset.p0i8.i64(i8* %src.i8, i8 0, i64 16, i1 false)
+ %x = load i8, i8* %src.i8
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest.i8, i8* %src.i8, i64 16, i1 false)
ret i8 %x
}
define void @write_dest_between_call_and_memcpy() {
; CHECK-LABEL: @write_dest_between_call_and_memcpy(
-; CHECK-NEXT: [[DEST:%.*]] = alloca i8, i64 16, align 1
-; CHECK-NEXT: [[SRC:%.*]] = alloca i8, i64 16, align 1
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[SRC]], i8 0, i64 16, i1 false)
-; CHECK-NEXT: store i8 1, i8* [[DEST]], align 1
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[DEST]], i8 0, i64 16, i1 false)
+; CHECK-NEXT: [[DEST:%.*]] = alloca [16 x i8], align 1
+; CHECK-NEXT: [[SRC:%.*]] = alloca [16 x i8], align 1
+; CHECK-NEXT: [[DEST_I8:%.*]] = bitcast [16 x i8]* [[DEST]] to i8*
+; CHECK-NEXT: [[SRC_I8:%.*]] = bitcast [16 x i8]* [[SRC]] to i8*
+; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[SRC_I8]], i8 0, i64 16, i1 false)
+; CHECK-NEXT: store i8 1, i8* [[DEST_I8]], align 1
+; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[DEST_I8]], i8 0, i64 16, i1 false)
; CHECK-NEXT: ret void
;
- %dest = alloca i8, i64 16
- %src = alloca i8, i64 16
- call void @llvm.memset.p0i8.i64(i8* %src, i8 0, i64 16, i1 false)
- store i8 1, i8* %dest
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest, i8* %src, i64 16, i1 false)
+ %dest = alloca [16 x i8]
+ %src = alloca [16 x i8]
+ %dest.i8 = bitcast [16 x i8]* %dest to i8*
+ %src.i8 = bitcast [16 x i8]* %src to i8*
+ call void @llvm.memset.p0i8.i64(i8* %src.i8, i8 0, i64 16, i1 false)
+ store i8 1, i8* %dest.i8
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest.i8, i8* %src.i8, i64 16, i1 false)
ret void
}
define void @write_src_between_call_and_memcpy() {
; CHECK-LABEL: @write_src_between_call_and_memcpy(
-; CHECK-NEXT: [[DEST:%.*]] = alloca i8, i64 16, align 1
-; CHECK-NEXT: [[SRC:%.*]] = alloca i8, i64 16, align 1
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[SRC]], i8 0, i64 16, i1 false)
-; CHECK-NEXT: store i8 1, i8* [[SRC]], align 1
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST]], i8* [[SRC]], i64 16, i1 false)
+; CHECK-NEXT: [[DEST:%.*]] = alloca [16 x i8], align 1
+; CHECK-NEXT: [[SRC:%.*]] = alloca [16 x i8], align 1
+; CHECK-NEXT: [[DEST_I8:%.*]] = bitcast [16 x i8]* [[DEST]] to i8*
+; CHECK-NEXT: [[SRC_I8:%.*]] = bitcast [16 x i8]* [[SRC]] to i8*
+; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[SRC_I8]], i8 0, i64 16, i1 false)
+; CHECK-NEXT: store i8 1, i8* [[SRC_I8]], align 1
+; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST_I8]], i8* [[SRC_I8]], i64 16, i1 false)
; CHECK-NEXT: ret void
;
- %dest = alloca i8, i64 16
- %src = alloca i8, i64 16
- call void @llvm.memset.p0i8.i64(i8* %src, i8 0, i64 16, i1 false)
- store i8 1, i8* %src
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest, i8* %src, i64 16, i1 false)
+ %dest = alloca [16 x i8]
+ %src = alloca [16 x i8]
+ %dest.i8 = bitcast [16 x i8]* %dest to i8*
+ %src.i8 = bitcast [16 x i8]* %src to i8*
+ call void @llvm.memset.p0i8.i64(i8* %src.i8, i8 0, i64 16, i1 false)
+ store i8 1, i8* %src.i8
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest.i8, i8* %src.i8, i64 16, i1 false)
ret void
}
; TODO: This is a miscompile.
-define void @throw_between_call_and_mempy(i8* dereferenceable(16) %dest) {
+define void @throw_between_call_and_mempy(i8* dereferenceable(16) %dest.i8) {
; CHECK-LABEL: @throw_between_call_and_mempy(
-; CHECK-NEXT: [[SRC:%.*]] = alloca i8, i64 16, align 1
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[DEST:%.*]], i8 0, i64 16, i1 false)
+; CHECK-NEXT: [[SRC:%.*]] = alloca [16 x i8], align 1
+; CHECK-NEXT: [[SRC_I8:%.*]] = bitcast [16 x i8]* [[SRC]] to i8*
+; CHECK-NEXT: [[DEST_I81:%.*]] = bitcast i8* [[DEST_I8:%.*]] to [16 x i8]*
+; CHECK-NEXT: [[DEST_I812:%.*]] = bitcast [16 x i8]* [[DEST_I81]] to i8*
+; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[DEST_I812]], i8 0, i64 16, i1 false)
; CHECK-NEXT: call void @may_throw() [[ATTR2:#.*]]
; CHECK-NEXT: ret void
;
- %src = alloca i8, i64 16
- call void @llvm.memset.p0i8.i64(i8* %src, i8 0, i64 16, i1 false)
+ %src = alloca [16 x i8]
+ %src.i8 = bitcast [16 x i8]* %src to i8*
+ call void @llvm.memset.p0i8.i64(i8* %src.i8, i8 0, i64 16, i1 false)
call void @may_throw() readnone
- call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest, i8* %src, i64 16, i1 false)
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest.i8, i8* %src.i8, i64 16, i1 false)
ret void
}
More information about the llvm-commits
mailing list