-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[flang][NFC] Characterize allocation based on MemAlloc effect instead of pattern matching #166806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
05e4d39
0295bd1
4e64702
d4ffa26
163cda5
538424c
3e21642
fb74ffd
7c380e1
99228e3
caa0cde
1382cee
42fced2
704be71
df464d8
a37b956
d807d66
b9b30f5
c47e2a2
a3158e2
45f03bb
ce3cbaf
a0ce784
ca2e56d
80be520
92e11da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ omp.declare_reduction @test_reduction : !fir.ref<!fir.box<i32>> init { | |
| ^bb0(%arg0: !fir.ref<!fir.box<i32>>): | ||
| %0 = fir.alloca !fir.box<i32> | ||
| %1 = fir.alloca i32 | ||
| %c0 = arith.constant 0 : i32 | ||
| fir.store %c0 to %1 : !fir.ref<i32> | ||
|
||
| %2 = fir.embox %1 : (!fir.ref<i32>) -> !fir.box<i32> | ||
|
|
||
| // use the embox for something so it isn't removed | ||
|
|
@@ -28,9 +30,11 @@ func.func @_QQmain() attributes {fir.bindc_name = "reduce"} { | |
| omp.parallel reduction(byref @test_reduction %4 -> %arg0 : !fir.ref<!fir.box<i32>>) { | ||
| omp.terminator | ||
| } | ||
| func.call @__use_box_i32(%4) : (!fir.ref<!fir.box<i32>>) -> () | ||
| return | ||
| } | ||
|
|
||
| func.func private @__use_box_i32(!fir.ref<!fir.box<i32>>) -> () | ||
| // basically we are testing that there isn't a crash | ||
| // CHECK-LABEL: define void @_QQmain | ||
| // CHECK-NEXT: alloca { ptr, i64, i32, i8, i8, i8, i8 }, i64 1, align 8 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,9 @@ func.func private @_test_inline_copy_in(%arg0: !fir.box<!fir.array<?x?x?xf64>> { | |
| fir.call @_QFPsb(%18, %19#0) fastmath<contract> : (!fir.ref<!fir.array<?xf64>>, !fir.ref<i32>) -> () | ||
| hlfir.copy_out %0, %17#1 : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>, i1) -> () | ||
| hlfir.end_associate %19#1, %19#2 : !fir.ref<i32>, i1 | ||
| // Keep %0 live to avoid DCE after inlining when no copy_out is needed. | ||
|
||
| %zb0 = fir.zero_bits !fir.box<!fir.heap<!fir.array<?xf64>>> | ||
| fir.store %zb0 to %0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>> | ||
| return | ||
| } | ||
|
|
||
|
|
@@ -110,6 +113,9 @@ func.func private @_test_no_inline_copy_in(%arg0: !fir.box<!fir.array<?x?x?xf64> | |
| fir.call @_QFPsb(%18, %19#1) fastmath<contract> : (!fir.ref<!fir.array<?xf64>>, !fir.ref<i32>) -> () | ||
| hlfir.copy_out %0, %17#1 to %16 : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>>, i1, !fir.box<!fir.array<?xf64>>) -> () | ||
| hlfir.end_associate %19#1, %19#2 : !fir.ref<i32>, i1 | ||
| // Keep %0 live to avoid DCE after inlining. | ||
|
||
| %zb1 = fir.zero_bits !fir.box<!fir.heap<!fir.array<?xf64>>> | ||
| fir.store %zb1 to %0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf64>>>> | ||
| return | ||
| } | ||
|
|
||
|
|
@@ -160,6 +166,9 @@ func.func @_QPoptional_copy_in_out(%arg0: !fir.box<!fir.array<?xf32>> {fir.bindc | |
| } | ||
| fir.call @_QPtakes_optional_explicit(%4#0) fastmath<contract> : (!fir.ref<!fir.array<?xf32>>) -> () | ||
| hlfir.copy_out %0, %4#1 : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>, i1) -> () | ||
| // Keep %0 live to avoid DCE after inlining. | ||
|
||
| %zb2 = fir.zero_bits !fir.box<!fir.heap<!fir.array<?xf32>>> | ||
| fir.store %zb2 to %0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>> | ||
| return | ||
| } | ||
|
|
||
|
|
@@ -191,6 +200,9 @@ func.func @_QPtest_copy_in_out_2(%arg0: !fir.box<!fir.array<*:f32>> {fir.bindc_n | |
| %3:2 = hlfir.copy_in %2#0 to %0 : (!fir.box<!fir.array<*:f32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>) -> (!fir.box<!fir.array<*:f32>>, i1) | ||
| fir.call @_QPtakes_contiguous_intentin(%3#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> () | ||
| hlfir.copy_out %0, %3#1 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, i1) -> () | ||
| // Keep %0 live to avoid DCE after inlining. | ||
|
||
| %zb3 = fir.zero_bits !fir.box<!fir.heap<!fir.array<*:f32>>> | ||
| fir.store %zb3 to %0 : !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>> | ||
| return | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,8 +31,6 @@ subroutine derived_dummy(some_r, some_c2) | |
|
|
||
| ! CHECK-LABEL: func @_QMdPlocal_derived( | ||
| subroutine local_derived() | ||
| ! CHECK-DAG: fir.alloca !fir.type<_QMdTc2{ch_array:!fir.array<20x30x!fir.char<1,10>>}> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to keep these checks by adding fake uses.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed! please check the most updated commit. for some the llvm diff doesn't show this being outdated |
||
| ! CHECK-DAG: fir.alloca !fir.type<_QMdTr{x:f32}> | ||
| type(r) :: some_r | ||
| type(c2) :: some_c2 | ||
| end subroutine | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -244,9 +244,5 @@ subroutine unstructured_do_concurrent | |
| ! CHECK: ^[[HEADER]]: | ||
| ! CHECK: %{{.*}} = fir.load %[[ITER_VAR]] : !fir.ref<i32> | ||
| ! CHECK: cf.cond_br %{{.*}}, ^[[BODY:.*]], ^[[EXIT:.*]] | ||
|
|
||
| ! CHECK: ^[[BODY]]: | ||
| ! CHECK-NEXT: %{{.*}} = fir.alloca !fir.logical<4> {bindc_name = "success", {{.*}}} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need some fake use here (e.g. a store into
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed! please check the most updated commit. for some the llvm diff doesn't show this being outdated |
||
|
|
||
| ! CHECK: ^[[EXIT]]: | ||
| ! CHECK-NEXT: return | ||
| ! CHECK: return | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please use
fir.callinstead?