Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Standalone View
flang/test/Transforms/stack-arrays.f90
! RUN: %flang_fc1 -emit-fir %s -o - | fir-opt --array-value-copy | fir-opt --stack-arrays | FileCheck %s | ! RUN: %flang_fc1 -emit-fir %s -o - | fir-opt --array-value-copy | fir-opt --stack-arrays | FileCheck %s | ||||||||||||||||||
! We have to check llvm ir here to force flang to run the whole mlir pipeline | |||||||||||||||||||
awarzynski: Also, I don't quite follow this comment:
> We have to check llvm ir here to force flang to… | |||||||||||||||||||
tblahAuthorUnsubmitted Just running flang-new -fc1 -emit-fir outputs the FIR before all of the transformation passes run (which is why I have to pipe the result through fir-opt to run the array value copy and stack arrays passes on the first line). Outputting LLVM IR requires all of the MLIR transformation passes to be run to transform all of the higher level dialects into the LLVM dialect. Stack arrays is run as part of that same pipeline (fir::createMLIRToLLVMPassPipeline). I want to test that -fstack-arrays does cause the stack arrays pass to run as part of that pipeline, which is why I am checking the LLVM-IR. One alternative would be to print out which passes have run and check that, but I felt this way fits more with the spirit of the other tests. tblah: Just running `flang-new -fc1 -emit-fir` outputs the FIR before all of the transformation passes… | |||||||||||||||||||
awarzynskiUnsubmitted Thanks for the explanation. So you want to verify this functionality by investigating two pipelines:
You could convey that by using CHECK-FIR and CHECK-LLVM-IR (or just FIR and LLVM-IR). I "complained", because this is unclear:
Perhaps:
awarzynski: Thanks for the explanation. So you want to verify this functionality by investigating two… | |||||||||||||||||||
! this is just to check that -fstack-arrays enables the stack-arrays pass so | |||||||||||||||||||
! only check the first example | |||||||||||||||||||
! RUN: %flang_fc1 -emit-llvm -o - -fstack-arrays %s | FileCheck --check-prefix=CHECK-LLVM %s | |||||||||||||||||||
awarzynskiUnsubmitted
awarzynski: | |||||||||||||||||||
tblahAuthorUnsubmitted Lots of other tests do not follow this convention. It would change the FileCheck comments to look like ! LLVM: array_value_copy_simple. I think it is good to require CHECK-FEATURE: so that any mention of FEATURE in comments does not confuse FileCheck. Especially for a name like LLVM which is likely to be written in capitals. tblah: Lots of other tests do not follow this convention. It would change the FileCheck comments to… | |||||||||||||||||||
awarzynskiUnsubmitted
I think that we would easily find examples for either approach.
Well, LLVM is not a feature ;-) Also, most folks working with LLVM are familiar with the LIT syntax - the presence of CHECK in CHECK-FEATURE is just unnecessary noise to me. But I am happy either way. But I would appreciate replacing with LLVM with something a bit more meaningful - perhaps LLVM-IR? awarzynski: > Lots of other tests do not follow this convention.
I think that we would easily find… | |||||||||||||||||||
! check simple array value copy case | ! check simple array value copy case | ||||||||||||||||||
subroutine array_value_copy_simple(arr) | subroutine array_value_copy_simple(arr) | ||||||||||||||||||
integer, intent(inout) :: arr(4) | integer, intent(inout) :: arr(4) | ||||||||||||||||||
arr(3:4) = arr(1:2) | arr(3:4) = arr(1:2) | ||||||||||||||||||
end subroutine | end subroutine | ||||||||||||||||||
! CHECK-LABEL: func.func @_QParray_value_copy_simple(%arg0: !fir.ref<!fir.array<4xi32>> | ! CHECK-LABEL: func.func @_QParray_value_copy_simple(%arg0: !fir.ref<!fir.array<4xi32>> | ||||||||||||||||||
! CHECK-NOT: fir.allocmem | ! CHECK-NOT: fir.allocmem | ||||||||||||||||||
! CHECK-NOT: fir.freemem | ! CHECK-NOT: fir.freemem | ||||||||||||||||||
! CHECK: fir.alloca !fir.array<4xi32> | ! CHECK: fir.alloca !fir.array<4xi32> | ||||||||||||||||||
! CHECK-NOT: fir.allocmem | ! CHECK-NOT: fir.allocmem | ||||||||||||||||||
! CHECK-NOT: fir.freemem | ! CHECK-NOT: fir.freemem | ||||||||||||||||||
! CHECK: return | ! CHECK: return | ||||||||||||||||||
! CHECK-NEXT: } | ! CHECK-NEXT: } | ||||||||||||||||||
! CHECK-LLVM: array_value_copy_simple | |||||||||||||||||||
! CHECK-LLVM-NOT: malloc | |||||||||||||||||||
! CHECK-LLVM-NOT: free | |||||||||||||||||||
! CHECK-LLVM: alloca [4 x i32] | |||||||||||||||||||
! CHECK-LLVM-NOT: malloc | |||||||||||||||||||
! CHECK-LLVM-NOT: free | |||||||||||||||||||
! CHECK-LLVM: ret void | |||||||||||||||||||
! CHECK-LLVM-NEXT: } | |||||||||||||||||||
Not Done ReplyInline Actions
Hopefully I got this right, it's been a while :) https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive awarzynski: Hopefully I got this right, it's been a while :) https://llvm.org/docs/CommandGuide/FileCheck. | |||||||||||||||||||
! check complex array value copy case | ! check complex array value copy case | ||||||||||||||||||
module stuff | module stuff | ||||||||||||||||||
type DerivedWithAllocatable | type DerivedWithAllocatable | ||||||||||||||||||
integer, dimension(:), allocatable :: dat | integer, dimension(:), allocatable :: dat | ||||||||||||||||||
end type | end type | ||||||||||||||||||
contains | contains | ||||||||||||||||||
subroutine array_value_copy_complex(arr) | subroutine array_value_copy_complex(arr) | ||||||||||||||||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |
Also, I don't quite follow this comment:
Why is checking LLVM IR going to force Flang to run anything?