[llvm] 771c46a - [GlobalOpt] Add tests for memset with non-zero value (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 27 07:36:35 PDT 2022
Author: Nikita Popov
Date: 2022-06-27T16:36:25+02:00
New Revision: 771c46ad291ce4c2265782c8a89a6771055c65d8
URL: https://github.com/llvm/llvm-project/commit/771c46ad291ce4c2265782c8a89a6771055c65d8
DIFF: https://github.com/llvm/llvm-project/commit/771c46ad291ce4c2265782c8a89a6771055c65d8.diff
LOG: [GlobalOpt] Add tests for memset with non-zero value (NFC)
Added:
Modified:
llvm/test/Transforms/GlobalOpt/ctor-memset.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/GlobalOpt/ctor-memset.ll b/llvm/test/Transforms/GlobalOpt/ctor-memset.ll
index 74d93a96d0be3..79ba25fc56cf0 100644
--- a/llvm/test/Transforms/GlobalOpt/ctor-memset.ll
+++ b/llvm/test/Transforms/GlobalOpt/ctor-memset.ll
@@ -1,27 +1,32 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt -S -globalopt < %s | FileCheck %s
- at llvm.global_ctors = appending global [6 x { i32, ptr, ptr }] [
+ at llvm.global_ctors = appending global [8 x { i32, ptr, ptr }] [
{ i32, ptr, ptr } { i32 65535, ptr @ctor0, ptr null },
{ i32, ptr, ptr } { i32 65535, ptr @ctor1, ptr null },
{ i32, ptr, ptr } { i32 65535, ptr @ctor2, ptr null },
{ i32, ptr, ptr } { i32 65535, ptr @ctor3, ptr null },
{ i32, ptr, ptr } { i32 65535, ptr @ctor4, ptr null },
- { i32, ptr, ptr } { i32 65535, ptr @ctor5, ptr null }
+ { i32, ptr, ptr } { i32 65535, ptr @ctor5, ptr null },
+ { i32, ptr, ptr } { i32 65535, ptr @ctor6, ptr null },
+ { i32, ptr, ptr } { i32 65535, ptr @ctor7, ptr null }
]
;.
-; CHECK: @[[LLVM_GLOBAL_CTORS:[a-zA-Z0-9_$"\\.-]+]] = appending global [0 x { i32, ptr, ptr }] zeroinitializer
+; CHECK: @[[LLVM_GLOBAL_CTORS:[a-zA-Z0-9_$"\\.-]+]] = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @ctor6, ptr null }, { i32, ptr, ptr } { i32 65535, ptr @ctor7, ptr null }]
; CHECK: @[[G0:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr global { i32, i32 } zeroinitializer
; CHECK: @[[G1:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr global { i32, i32, i32 } { i32 0, i32 0, i32 1 }
; CHECK: @[[G2:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr global { i32, i32, i32 } { i32 1, i32 0, i32 0 }
; CHECK: @[[G3:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr global { i32, i32 } { i32 0, i32 1 }
; CHECK: @[[G4:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr global { i32, i32 } { i32 0, i32 undef }
; CHECK: @[[G5:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr global { i16, i32 } { i16 0, i32 1 }
+; CHECK: @[[G6:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr global { i32, i32 } { i32 -1, i32 -1 }
+; CHECK: @[[G7:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr global { i32, i32 } { i32 -1, i32 1 }
;.
; memset of all-zero global
@g0 = global { i32, i32 } zeroinitializer
+
define internal void @ctor0() {
call void @llvm.memset.p0.i64(ptr @g0, i8 0, i64 8, i1 false)
ret void
@@ -67,4 +72,31 @@ define internal void @ctor5() {
ret void
}
+; memset of non-zero value (matching initializer)
+ at g6 = global { i32, i32 } { i32 -1, i32 -1 }
+
+define internal void @ctor6() {
+; CHECK-LABEL: @ctor6(
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr @g6, i8 -1, i64 8, i1 false)
+; CHECK-NEXT: ret void
+;
+ call void @llvm.memset.p0.i64(ptr @g6, i8 -1, i64 8, i1 false)
+ ret void
+}
+
+; memset of non-zero value (not matching initializer)
+ at g7 = global { i32, i32 } { i32 -1, i32 1 }
+
+define internal void @ctor7() {
+; CHECK-LABEL: @ctor7(
+; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr @g7, i8 -1, i64 8, i1 false)
+; CHECK-NEXT: ret void
+;
+ call void @llvm.memset.p0.i64(ptr @g7, i8 -1, i64 8, i1 false)
+ ret void
+}
+
declare void @llvm.memset.p0.i64(ptr, i8, i64, i1)
+;.
+; CHECK: attributes #[[ATTR0:[0-9]+]] = { argmemonly nofree nounwind willreturn writeonly }
+;.
More information about the llvm-commits
mailing list