[Openmp-commits] [openmp] 81a02b0 - [Attributor][NFC] Precommit test

Johannes Doerfert via Openmp-commits openmp-commits at lists.llvm.org
Wed Aug 23 11:48:30 PDT 2023


Author: Johannes Doerfert
Date: 2023-08-23T11:48:18-07:00
New Revision: 81a02b0767965d0d7312d3d27ca02a66414dc58c

URL: https://github.com/llvm/llvm-project/commit/81a02b0767965d0d7312d3d27ca02a66414dc58c
DIFF: https://github.com/llvm/llvm-project/commit/81a02b0767965d0d7312d3d27ca02a66414dc58c.diff

LOG: [Attributor][NFC] Precommit test

Added: 
    

Modified: 
    llvm/test/Transforms/Attributor/value-simplify-reachability.ll
    openmp/libomptarget/test/jit/type_punning.c

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/Attributor/value-simplify-reachability.ll b/llvm/test/Transforms/Attributor/value-simplify-reachability.ll
index 10a0db986848b8..c25201d5d8cec9 100644
--- a/llvm/test/Transforms/Attributor/value-simplify-reachability.ll
+++ b/llvm/test/Transforms/Attributor/value-simplify-reachability.ll
@@ -19,6 +19,7 @@ declare noalias ptr @calloc(i64, i64) allockind("alloc,zeroed") allocsize(0, 1)
 ; CHECK: @[[GINT3:[a-zA-Z0-9_$"\\.-]+]] = internal global i32 undef, align 4
 ; CHECK: @[[GINT4:[a-zA-Z0-9_$"\\.-]+]] = internal global i32 0, align 4
 ; CHECK: @[[GINT5:[a-zA-Z0-9_$"\\.-]+]] = internal global i32 undef, align 4
+; CHECK: @[[B:[a-zA-Z0-9_$"\\.-]+]] = global i32 0
 ;.
 define internal void @write1ToGInt1() {
 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
@@ -48,7 +49,7 @@ define void @entry1(i1 %c, i32 %v) {
 ; TUNIT-SAME: (i1 [[C:%.*]], i32 [[V:%.*]]) #[[ATTR5:[0-9]+]] {
 ; TUNIT-NEXT:    [[L0:%.*]] = load i32, ptr @GInt1, align 4
 ; TUNIT-NEXT:    call void @useI32(i32 [[L0]])
-; TUNIT-NEXT:    call void @write1ToGInt1() #[[ATTR10:[0-9]+]]
+; TUNIT-NEXT:    call void @write1ToGInt1() #[[ATTR11:[0-9]+]]
 ; TUNIT-NEXT:    [[L1:%.*]] = load i32, ptr @GInt1, align 4
 ; TUNIT-NEXT:    call void @useI32(i32 [[L1]])
 ; TUNIT-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
@@ -60,7 +61,7 @@ define void @entry1(i1 %c, i32 %v) {
 ; TUNIT:       F:
 ; TUNIT-NEXT:    [[L3:%.*]] = load i32, ptr @GInt1, align 4
 ; TUNIT-NEXT:    call void @useI32(i32 [[L3]])
-; TUNIT-NEXT:    call void @write1ToGInt1() #[[ATTR10]]
+; TUNIT-NEXT:    call void @write1ToGInt1() #[[ATTR11]]
 ; TUNIT-NEXT:    [[L4:%.*]] = load i32, ptr @GInt1, align 4
 ; TUNIT-NEXT:    call void @useI32(i32 [[L4]])
 ; TUNIT-NEXT:    ret void
@@ -70,7 +71,7 @@ define void @entry1(i1 %c, i32 %v) {
 ; CGSCC-SAME: (i1 [[C:%.*]], i32 [[V:%.*]]) #[[ATTR5:[0-9]+]] {
 ; CGSCC-NEXT:    [[L0:%.*]] = load i32, ptr @GInt1, align 4
 ; CGSCC-NEXT:    call void @useI32(i32 [[L0]])
-; CGSCC-NEXT:    call void @write1ToGInt1() #[[ATTR10:[0-9]+]]
+; CGSCC-NEXT:    call void @write1ToGInt1() #[[ATTR13:[0-9]+]]
 ; CGSCC-NEXT:    [[L1:%.*]] = load i32, ptr @GInt1, align 4
 ; CGSCC-NEXT:    call void @useI32(i32 [[L1]])
 ; CGSCC-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
@@ -82,7 +83,7 @@ define void @entry1(i1 %c, i32 %v) {
 ; CGSCC:       F:
 ; CGSCC-NEXT:    [[L3:%.*]] = load i32, ptr @GInt1, align 4
 ; CGSCC-NEXT:    call void @useI32(i32 [[L3]])
-; CGSCC-NEXT:    call void @write1ToGInt1() #[[ATTR10]]
+; CGSCC-NEXT:    call void @write1ToGInt1() #[[ATTR13]]
 ; CGSCC-NEXT:    [[L4:%.*]] = load i32, ptr @GInt1, align 4
 ; CGSCC-NEXT:    call void @useI32(i32 [[L4]])
 ; CGSCC-NEXT:    ret void
@@ -113,7 +114,7 @@ define void @entry2(i1 %c, i32 %v) {
 ; TUNIT-SAME: (i1 [[C:%.*]], i32 [[V:%.*]]) #[[ATTR5]] {
 ; TUNIT-NEXT:    [[L0:%.*]] = load i32, ptr @GInt2, align 4
 ; TUNIT-NEXT:    call void @useI32(i32 [[L0]])
-; TUNIT-NEXT:    call void @write1ToGInt2() #[[ATTR10]]
+; TUNIT-NEXT:    call void @write1ToGInt2() #[[ATTR11]]
 ; TUNIT-NEXT:    [[L1:%.*]] = load i32, ptr @GInt2, align 4
 ; TUNIT-NEXT:    call void @useI32(i32 [[L1]])
 ; TUNIT-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
@@ -125,7 +126,7 @@ define void @entry2(i1 %c, i32 %v) {
 ; TUNIT:       F:
 ; TUNIT-NEXT:    [[L3:%.*]] = load i32, ptr @GInt2, align 4
 ; TUNIT-NEXT:    call void @useI32(i32 [[L3]])
-; TUNIT-NEXT:    call void @write1ToGInt2() #[[ATTR10]]
+; TUNIT-NEXT:    call void @write1ToGInt2() #[[ATTR11]]
 ; TUNIT-NEXT:    [[L4:%.*]] = load i32, ptr @GInt2, align 4
 ; TUNIT-NEXT:    call void @useI32(i32 [[L4]])
 ; TUNIT-NEXT:    ret void
@@ -135,7 +136,7 @@ define void @entry2(i1 %c, i32 %v) {
 ; CGSCC-SAME: (i1 [[C:%.*]], i32 [[V:%.*]]) #[[ATTR5]] {
 ; CGSCC-NEXT:    [[L0:%.*]] = load i32, ptr @GInt2, align 4
 ; CGSCC-NEXT:    call void @useI32(i32 [[L0]])
-; CGSCC-NEXT:    call void @write1ToGInt2() #[[ATTR10]]
+; CGSCC-NEXT:    call void @write1ToGInt2() #[[ATTR13]]
 ; CGSCC-NEXT:    [[L1:%.*]] = load i32, ptr @GInt2, align 4
 ; CGSCC-NEXT:    call void @useI32(i32 [[L1]])
 ; CGSCC-NEXT:    br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
@@ -147,7 +148,7 @@ define void @entry2(i1 %c, i32 %v) {
 ; CGSCC:       F:
 ; CGSCC-NEXT:    [[L3:%.*]] = load i32, ptr @GInt2, align 4
 ; CGSCC-NEXT:    call void @useI32(i32 [[L3]])
-; CGSCC-NEXT:    call void @write1ToGInt2() #[[ATTR10]]
+; CGSCC-NEXT:    call void @write1ToGInt2() #[[ATTR13]]
 ; CGSCC-NEXT:    [[L4:%.*]] = load i32, ptr @GInt2, align 4
 ; CGSCC-NEXT:    call void @useI32(i32 [[L4]])
 ; CGSCC-NEXT:    ret void
@@ -790,6 +791,75 @@ define i32 @exclusion_set3(i1 %c) {
   ret i32 %final
 }
 
+ at B = global i32 0
+
+define internal i32 @readI32(ptr %a) {
+; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none)
+; TUNIT-LABEL: define {{[^@]+}}@readI32
+; TUNIT-SAME: () #[[ATTR9:[0-9]+]] {
+; TUNIT-NEXT:    store i32 1, ptr @B, align 4
+; TUNIT-NEXT:    ret i32 undef
+;
+; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
+; CGSCC-LABEL: define {{[^@]+}}@readI32
+; CGSCC-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR9:[0-9]+]] {
+; CGSCC-NEXT:    [[R:%.*]] = load i32, ptr [[A]], align 4
+; CGSCC-NEXT:    store i32 1, ptr @B, align 4
+; CGSCC-NEXT:    ret i32 [[R]]
+;
+  %r = load i32, ptr %a
+  store i32 1, ptr @B
+  ret i32 %r
+}
+
+define internal i32 @broker(ptr %a) {
+; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none)
+; TUNIT-LABEL: define {{[^@]+}}@broker
+; TUNIT-SAME: () #[[ATTR9]] {
+; TUNIT-NEXT:    [[R:%.*]] = call i32 @readI32() #[[ATTR12:[0-9]+]]
+; TUNIT-NEXT:    ret i32 undef
+;
+; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(readwrite, argmem: none)
+; CGSCC-LABEL: define {{[^@]+}}@broker
+; CGSCC-SAME: (i32 [[TMP0:%.*]]) #[[ATTR10:[0-9]+]] {
+; CGSCC-NEXT:    [[A_PRIV:%.*]] = alloca i32, align 4
+; CGSCC-NEXT:    store i32 [[TMP0]], ptr [[A_PRIV]], align 4
+; CGSCC-NEXT:    [[R:%.*]] = call i32 @readI32(ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A_PRIV]]) #[[ATTR14:[0-9]+]]
+; CGSCC-NEXT:    ret i32 [[R]]
+;
+  %r = call i32 @readI32(ptr %a)
+  ret i32 %r
+}
+
+; FIXME: This function should return 1, not 0
+define i32 @two_calls() {
+; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
+; TUNIT-LABEL: define {{[^@]+}}@two_calls
+; TUNIT-SAME: () #[[ATTR4]] {
+; TUNIT-NEXT:    [[A:%.*]] = alloca i32, align 4
+; TUNIT-NEXT:    [[D:%.*]] = call i32 @broker() #[[ATTR12]]
+; TUNIT-NEXT:    [[R:%.*]] = call i32 @broker() #[[ATTR12]]
+; TUNIT-NEXT:    ret i32 0
+;
+; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn
+; CGSCC-LABEL: define {{[^@]+}}@two_calls
+; CGSCC-SAME: () #[[ATTR11:[0-9]+]] {
+; CGSCC-NEXT:    [[A:%.*]] = alloca i32, align 4
+; CGSCC-NEXT:    store i32 0, ptr [[A]], align 4
+; CGSCC-NEXT:    [[TMP1:%.*]] = load i32, ptr [[A]], align 4
+; CGSCC-NEXT:    [[D:%.*]] = call i32 @broker(i32 noundef [[TMP1]]) #[[ATTR14]]
+; CGSCC-NEXT:    store i32 1, ptr [[A]], align 4
+; CGSCC-NEXT:    [[R:%.*]] = call i32 @broker(i32 noundef 1) #[[ATTR14]]
+; CGSCC-NEXT:    ret i32 [[R]]
+;
+  %a = alloca i32
+  store i32 0, ptr %a
+  %d = call i32 @broker(ptr %a)
+  store i32 1, ptr %a
+  %r = call i32 @broker(ptr %a)
+  ret i32 %r
+}
+
 ;.
 ; TUNIT: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
 ; TUNIT: attributes #[[ATTR1:[0-9]+]] = { nocallback nosync }
@@ -800,8 +870,10 @@ define i32 @exclusion_set3(i1 %c) {
 ; TUNIT: attributes #[[ATTR6]] = { nocallback }
 ; TUNIT: attributes #[[ATTR7]] = { norecurse }
 ; TUNIT: attributes #[[ATTR8]] = { nosync }
-; TUNIT: attributes #[[ATTR9:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: write) }
-; TUNIT: attributes #[[ATTR10]] = { nosync nounwind memory(write) }
+; TUNIT: attributes #[[ATTR9]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none) }
+; TUNIT: attributes #[[ATTR10:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: write) }
+; TUNIT: attributes #[[ATTR11]] = { nosync nounwind memory(write) }
+; TUNIT: attributes #[[ATTR12]] = { nofree nosync nounwind willreturn memory(write) }
 ;.
 ; CGSCC: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
 ; CGSCC: attributes #[[ATTR1:[0-9]+]] = { nocallback nosync }
@@ -812,6 +884,10 @@ define i32 @exclusion_set3(i1 %c) {
 ; CGSCC: attributes #[[ATTR6]] = { norecurse nosync }
 ; CGSCC: attributes #[[ATTR7]] = { nocallback }
 ; CGSCC: attributes #[[ATTR8]] = { norecurse }
-; CGSCC: attributes #[[ATTR9:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: write) }
-; CGSCC: attributes #[[ATTR10]] = { nounwind memory(write) }
+; CGSCC: attributes #[[ATTR9]] = { mustprogress nofree norecurse nosync nounwind willreturn }
+; CGSCC: attributes #[[ATTR10]] = { mustprogress nofree nosync nounwind willreturn memory(readwrite, argmem: none) }
+; CGSCC: attributes #[[ATTR11]] = { mustprogress nofree nosync nounwind willreturn }
+; CGSCC: attributes #[[ATTR12:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: write) }
+; CGSCC: attributes #[[ATTR13]] = { nounwind memory(write) }
+; CGSCC: attributes #[[ATTR14]] = { nofree nounwind willreturn }
 ;.

diff  --git a/openmp/libomptarget/test/jit/type_punning.c b/openmp/libomptarget/test/jit/type_punning.c
index c8af8eec502acd..23aa69bba7b952 100644
--- a/openmp/libomptarget/test/jit/type_punning.c
+++ b/openmp/libomptarget/test/jit/type_punning.c
@@ -20,6 +20,8 @@
 // CHECK-NOT: define
 
 #include <omp.h>
+#include <stdio.h>
+
 void f(long *A, int N) {
   long i = 0;
 #pragma omp target map(A[ : N])
@@ -34,5 +36,6 @@ void f(long *A, int N) {
 int main() {
   long A[1];
   f(&A[0], 1);
-  return A[0];
+  printf("%li\n", A[0]);
+  return 0;
 }


        


More information about the Openmp-commits mailing list