[llvm] aa89f08 - [BasicAA] Add tests for constant memory with loop phi (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 03:32:31 PDT 2022
Author: Nikita Popov
Date: 2022-10-17T12:32:15+02:00
New Revision: aa89f08afad7ee0581c39638abd8ee0df9ba1c65
URL: https://github.com/llvm/llvm-project/commit/aa89f08afad7ee0581c39638abd8ee0df9ba1c65
DIFF: https://github.com/llvm/llvm-project/commit/aa89f08afad7ee0581c39638abd8ee0df9ba1c65.diff
LOG: [BasicAA] Add tests for constant memory with loop phi (NFC)
Added:
llvm/test/Analysis/BasicAA/constant-memory.ll
Modified:
llvm/test/Transforms/FunctionAttrs/readattrs.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/BasicAA/constant-memory.ll b/llvm/test/Analysis/BasicAA/constant-memory.ll
new file mode 100644
index 0000000000000..a14a1ea4fbbda
--- /dev/null
+++ b/llvm/test/Analysis/BasicAA/constant-memory.ll
@@ -0,0 +1,33 @@
+; RUN: opt < %s -passes=aa-eval -print-all-alias-modref-info 2>&1 | FileCheck %s
+
+ at c = constant [8 x i32] zeroinitializer
+
+declare void @dummy()
+
+; FIXME: This could be NoModRef
+; CHECK-LABEL: Function: basic
+; CHECK: Just Ref: Ptr: i32* @c <-> call void @dummy()
+define void @basic(ptr %p) {
+ call void @dummy()
+ load i32, ptr @c
+ ret void
+}
+
+; FIXME: This should be at least only Ref.
+; CHECK-LABEL: Function: recphi
+; Both ModRef: Ptr: i32* %p <-> call void @dummy()
+define void @recphi() {
+entry:
+ br label %loop
+
+loop:
+ %p = phi ptr [ @c, %entry ], [ %p.next, %loop ]
+ call void @dummy()
+ load i32, ptr %p
+ %p.next = getelementptr i32, ptr %p, i64 1
+ %c = icmp ne ptr %p.next, getelementptr (i32, ptr @c, i64 8)
+ br i1 %c, label %loop, label %exit
+
+exit:
+ ret void
+}
diff --git a/llvm/test/Transforms/FunctionAttrs/readattrs.ll b/llvm/test/Transforms/FunctionAttrs/readattrs.ll
index f1f1c4cc2ea82..ba968ec8e8b7d 100644
--- a/llvm/test/Transforms/FunctionAttrs/readattrs.ll
+++ b/llvm/test/Transforms/FunctionAttrs/readattrs.ll
@@ -287,3 +287,38 @@ define void @fptr_test2c(ptr %p, ptr %f) {
call void %f(ptr readonly %p) readonly
ret void
}
+
+define void @alloca_recphi() {
+; CHECK: Function Attrs: nofree norecurse nosync nounwind
+; CHECK-LABEL: define {{[^@]+}}@alloca_recphi
+; CHECK-SAME: () #[[ATTR14:[0-9]+]] {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[A:%.*]] = alloca [8 x i32], align 4
+; CHECK-NEXT: [[A_END:%.*]] = getelementptr i32, ptr [[A]], i64 8
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[A]], [[ENTRY:%.*]] ], [ [[P_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: store i32 0, ptr [[P]], align 4
+; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[P]], align 4
+; CHECK-NEXT: [[P_NEXT]] = getelementptr i32, ptr [[P]], i64 1
+; CHECK-NEXT: [[C:%.*]] = icmp ne ptr [[P_NEXT]], [[A_END]]
+; CHECK-NEXT: br i1 [[C]], label [[LOOP]], label [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ %a = alloca [8 x i32]
+ %a.end = getelementptr i32, ptr %a, i64 8
+ br label %loop
+
+loop:
+ %p = phi ptr [ %a, %entry ], [ %p.next, %loop ]
+ store i32 0, ptr %p
+ load i32, ptr %p
+ %p.next = getelementptr i32, ptr %p, i64 1
+ %c = icmp ne ptr %p.next, %a.end
+ br i1 %c, label %loop, label %exit
+
+exit:
+ ret void
+}
More information about the llvm-commits
mailing list