4
4
; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM
5
5
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM
6
6
7
+ ; FIXME: amdgpu doesn't claim malloc is a thing, so the test is somewhat
8
+ ; useless except the __kmpc_alloc_shared part which now also covers the important
9
+ ; part this test was initially designed for, make sure the "is freed" check is
10
+ ; not sufficient on a GPU.
7
11
target triple = "amdgcn-amd-amdhsa"
12
+ target datalayout = "A5"
8
13
9
14
declare noalias i8* @malloc (i64 )
10
15
@@ -20,6 +25,7 @@ declare void @no_sync_func(i8* nocapture %p) nofree nosync willreturn
20
25
21
26
declare void @nofree_func (i8* nocapture %p ) nofree nosync willreturn
22
27
28
+ declare void @usei8 (i8* %p )
23
29
declare void @foo (i32* %p )
24
30
25
31
declare void @foo_nounw (i32* %p ) nounwind nofree
@@ -663,11 +669,49 @@ define void @test16d(i8 %v, i8** %P) {
663
669
store i8* %1 , i8** %P
664
670
ret void
665
671
}
672
+
673
+ declare i8* @__kmpc_alloc_shared (i64 )
674
+ declare void @__kmpc_free_shared (i8* nocapture , i64 )
675
+
676
+ define void @test17 () {
677
+ ; IS________OPM-LABEL: define {{[^@]+}}@test17() {
678
+ ; IS________OPM-NEXT: [[TMP1:%.*]] = tail call noalias i8* @__kmpc_alloc_shared(i64 noundef 4)
679
+ ; IS________OPM-NEXT: tail call void @usei8(i8* noalias nocapture nofree [[TMP1]]) #[[ATTR6:[0-9]+]]
680
+ ; IS________OPM-NEXT: tail call void @__kmpc_free_shared(i8* noalias nocapture [[TMP1]], i64 noundef 4)
681
+ ; IS________OPM-NEXT: ret void
682
+ ;
683
+ ; IS________NPM-LABEL: define {{[^@]+}}@test17() {
684
+ ; IS________NPM-NEXT: [[TMP1:%.*]] = alloca i8, i64 4, align 1, addrspace(5)
685
+ ; IS________NPM-NEXT: [[MALLOC_CAST:%.*]] = addrspacecast i8 addrspace(5)* [[TMP1]] to i8*
686
+ ; IS________NPM-NEXT: tail call void @usei8(i8* noalias nocapture nofree [[MALLOC_CAST]]) #[[ATTR6:[0-9]+]]
687
+ ; IS________NPM-NEXT: ret void
688
+ ;
689
+ %1 = tail call noalias i8* @__kmpc_alloc_shared (i64 4 )
690
+ tail call void @usei8 (i8* nocapture nofree %1 ) willreturn nounwind nosync
691
+ tail call void @__kmpc_free_shared (i8* %1 , i64 4 )
692
+ ret void
693
+ }
694
+
695
+ define void @test17b () {
696
+ ; CHECK-LABEL: define {{[^@]+}}@test17b() {
697
+ ; CHECK-NEXT: [[TMP1:%.*]] = tail call noalias i8* @__kmpc_alloc_shared(i64 noundef 4)
698
+ ; CHECK-NEXT: tail call void @usei8(i8* nofree [[TMP1]]) #[[ATTR6:[0-9]+]]
699
+ ; CHECK-NEXT: tail call void @__kmpc_free_shared(i8* nocapture [[TMP1]], i64 noundef 4)
700
+ ; CHECK-NEXT: ret void
701
+ ;
702
+ %1 = tail call noalias i8* @__kmpc_alloc_shared (i64 4 )
703
+ tail call void @usei8 (i8* nofree %1 ) willreturn nounwind nosync
704
+ tail call void @__kmpc_free_shared (i8* %1 , i64 4 )
705
+ ret void
706
+ }
707
+
708
+
666
709
;.
667
710
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nounwind willreturn }
668
711
; CHECK: attributes #[[ATTR1:[0-9]+]] = { nofree nosync willreturn }
669
712
; CHECK: attributes #[[ATTR2:[0-9]+]] = { nofree nounwind }
670
713
; CHECK: attributes #[[ATTR3]] = { noreturn }
671
714
; CHECK: attributes #[[ATTR4:[0-9]+]] = { argmemonly nofree nosync nounwind willreturn }
672
715
; CHECK: attributes #[[ATTR5]] = { nounwind }
716
+ ; CHECK: attributes #[[ATTR6]] = { nosync nounwind willreturn }
673
717
;.
0 commit comments