This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flang][OpenMP][MLIR] Create lifetime markers for allocations only us…
…ed within OpenMP loop regions By creating `llvm.lifetime.start` and `llvm.lifetime.end` markers for outside allocations around the body of the loop produced for `omp.wsloop` and `omp.simdloop` MLIR operations, later uses of the LLVM `CodeExtractor` class to potentially outline the body of these loops into independent functions will be able to see the reduced scope of use of these allocations and sink them into the outlined function's body rather than to unnecessarily pass them as arguments. This can also help later optimization stages to detect cases where allocations for loop indices are redundant.
- Loading branch information
Showing
2 changed files
with
165 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
! This test checks the insertion of lifetime information for loop indices of | ||
! OpenMP loop operations. | ||
! RUN: %flang_fc1 -flang-experimental-hlfir -emit-llvm -fopenmp %s -o - | FileCheck %s | ||
|
||
! CHECK-LABEL: define void @wsloop_i32 | ||
subroutine wsloop_i32() | ||
! CHECK-DAG: %[[LASTITER:.*]] = alloca i32 | ||
! CHECK-DAG: %[[LB:.*]] = alloca i32 | ||
! CHECK-DAG: %[[UB:.*]] = alloca i32 | ||
! CHECK-DAG: %[[STRIDE:.*]] = alloca i32 | ||
! CHECK-DAG: %[[I:.*]] = alloca i32 | ||
integer :: i | ||
|
||
! CHECK: call void @llvm.lifetime.start.p0(i64 4, ptr %[[I]]) | ||
! CHECK-NEXT: br label %[[WSLOOP_BLOCK:.*]] | ||
! CHECK: [[WSLOOP_BLOCK]]: | ||
! CHECK-NOT: {{^.*}}: | ||
! CHECK: br label %[[CONT_BLOCK:.*]] | ||
! CHECK: [[CONT_BLOCK]]: | ||
! CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr %[[I]]) | ||
!$omp do | ||
do i = 1, 10 | ||
print *, i | ||
end do | ||
!$omp end do | ||
end subroutine | ||
|
||
! CHECK-LABEL: define void @wsloop_i64 | ||
subroutine wsloop_i64() | ||
! CHECK-DAG: %[[LASTITER:.*]] = alloca i32 | ||
! CHECK-DAG: %[[LB:.*]] = alloca i64 | ||
! CHECK-DAG: %[[UB:.*]] = alloca i64 | ||
! CHECK-DAG: %[[STRIDE:.*]] = alloca i64 | ||
! CHECK-DAG: %[[I:.*]] = alloca i64 | ||
integer*8 :: i | ||
|
||
! CHECK: call void @llvm.lifetime.start.p0(i64 8, ptr %[[I]]) | ||
! CHECK-NEXT: br label %[[WSLOOP_BLOCK:.*]] | ||
! CHECK: [[WSLOOP_BLOCK]]: | ||
! CHECK-NOT: {{^.*}}: | ||
! CHECK: br label %[[CONT_BLOCK:.*]] | ||
! CHECK: [[CONT_BLOCK]]: | ||
! CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr %[[I]]) | ||
!$omp do | ||
do i = 1, 10 | ||
print *, i | ||
end do | ||
!$omp end do | ||
end subroutine | ||
|
||
! CHECK-LABEL: define void @simdloop_i32 | ||
subroutine simdloop_i32() | ||
! CHECK: %[[I:.*]] = alloca i32 | ||
integer :: i | ||
|
||
! CHECK: call void @llvm.lifetime.start.p0(i64 4, ptr %[[I]]) | ||
! CHECK-NEXT: br label %[[SIMDLOOP_BLOCK:.*]] | ||
! CHECK: [[SIMDLOOP_BLOCK]]: | ||
! CHECK-NOT: {{^.*}}: | ||
! CHECK: br label %[[CONT_BLOCK:.*]] | ||
! CHECK: [[CONT_BLOCK]]: | ||
! CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr %[[I]]) | ||
!$omp simd | ||
do i=1, 9 | ||
print *, i | ||
end do | ||
!$omp end simd | ||
end subroutine | ||
|
||
! CHECK-LABEL: define void @simdloop_i64 | ||
subroutine simdloop_i64() | ||
! CHECK: %[[I:.*]] = alloca i64 | ||
integer*8 :: i | ||
|
||
! CHECK: call void @llvm.lifetime.start.p0(i64 8, ptr %[[I]]) | ||
! CHECK-NEXT: br label %[[SIMDLOOP_BLOCK:.*]] | ||
! CHECK: [[SIMDLOOP_BLOCK]]: | ||
! CHECK-NOT: {{^.*}}: | ||
! CHECK: br label %[[CONT_BLOCK:.*]] | ||
! CHECK: [[CONT_BLOCK]]: | ||
! CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr %[[I]]) | ||
!$omp simd | ||
do i=1, 9 | ||
print *, i | ||
end do | ||
!$omp end simd | ||
end subroutine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters