Skip to content

Commit 0937e1e

Browse files
authored
[Flang][AMDGPU] Add a lit test for Lowering ALLOCATE/DEALLOCATE to runtime calls. (llvm#1631)
2 parents c45aa02 + 6c8878c commit 0937e1e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
! RUN: %flang -target amdgcn-- -mmlir -use-alloc-runtime -S -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
2+
! RUN: %flang -target amdgcn-- -S -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-NO-FLAG
3+
4+
! Test to check if usage of flag -use-alloc-runtime results in runtime calls.
5+
6+
subroutine allocate_deallocate()
7+
real, allocatable :: x
8+
9+
allocate(x)
10+
! CHECK: call i32 @_FortranAAllocatableAllocate
11+
! CHECK-NO-FLAG: call ptr @malloc
12+
13+
deallocate(x)
14+
! CHECK: call i32 @_FortranAAllocatableDeallocate
15+
! CHECK-NO-FLAG: call void @free
16+
end subroutine
17+
18+
subroutine allocate_deallocate_ptr()
19+
integer, pointer :: x
20+
21+
allocate(x)
22+
! CHECK: call i32 @_FortranAPointerAllocate
23+
! CHECK-NO-FLAG: call i32 @_FortranAPointerAllocate
24+
25+
deallocate(x)
26+
! CHECK: call i32 @_FortranAPointerDeallocate
27+
! CHECK-NO-FLAG: call i32 @_FortranAPointerDeallocate
28+
end subroutine

0 commit comments

Comments
 (0)