Skip to content

Commit 3be8e3a

Browse files
authored
[flang] translate pure and elemental attribute in FIR (#109954)
Follow-up from a previous patch that turned bind_c into an enum for procedure attribute. This patch carries the elemental and pure Fortran attribute into FIR so that the optimizer can leverage that info in the future (I think debug info may also need to know these aspects since DWARF has DW_AT_elemental and DW_AT_pure nodes). SIMPLE from F2023 will be translated once it is handled in the front-end. NON_RECURSIVE is only meaningful on func.func since we are not guaranteed to know that aspect on the caller side (it is not part of Fortran characteristics). There is a DW_AT_recursive DWARF node. I will do it while dealing with func.func attributes.
1 parent 6fae8b8 commit 3be8e3a

12 files changed

+57
-27
lines changed

flang/include/flang/Lower/CallInterface.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ namespace mlir {
4242
class Location;
4343
}
4444

45+
namespace fir {
46+
class FortranProcedureFlagsEnumAttr;
47+
}
48+
4549
namespace Fortran::lower {
4650
class AbstractConverter;
4751
class SymMap;
@@ -235,6 +239,11 @@ class CallInterface {
235239
return characteristic && characteristic->CanBeCalledViaImplicitInterface();
236240
}
237241

242+
/// Translate Fortran procedure attributes into FIR attribute.
243+
/// Return attribute is nullptr if the procedure has no attributes.
244+
fir::FortranProcedureFlagsEnumAttr
245+
getProcedureAttrs(mlir::MLIRContext *) const;
246+
238247
protected:
239248
CallInterface(Fortran::lower::AbstractConverter &c) : converter{c} {}
240249
/// CRTP handle.

flang/include/flang/Optimizer/Dialect/FIRAttr.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def fir_FortranVariableFlagsAttr : fir_Attr<"FortranVariableFlags"> {
6262
/// Fortran procedure attributes (F2023 15.6.2.1). BIND attribute (18.3.7)
6363
/// is also tracked in the same enum. Recursive (resp. Impure) attribute
6464
/// is implied by the absence of opposite NonRecursive (resp. Pure) attribute.
65+
/// Beware that "elemental" does not implicitly imply "pure" as it does in
66+
/// Fortran, "pure" must be made explicit when generating the FIR attribute.
6567
def FIRfuncNoAttributes : I32BitEnumAttrCaseNone<"none">;
6668
def FIRfuncElemental : I32BitEnumAttrCaseBit<"elemental", 0>;
6769
def FIRfuncPure : I32BitEnumAttrCaseBit<"pure", 1>;

flang/lib/Lower/CallInterface.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,29 @@ Fortran::lower::CallInterface<T>::getResultType() const {
15461546
return types;
15471547
}
15481548

1549+
template <typename T>
1550+
fir::FortranProcedureFlagsEnumAttr
1551+
Fortran::lower::CallInterface<T>::getProcedureAttrs(
1552+
mlir::MLIRContext *mlirContext) const {
1553+
if (characteristic) {
1554+
fir::FortranProcedureFlagsEnum flags = fir::FortranProcedureFlagsEnum::none;
1555+
if (characteristic->IsBindC())
1556+
flags = flags | fir::FortranProcedureFlagsEnum::bind_c;
1557+
if (characteristic->IsPure())
1558+
flags = flags | fir::FortranProcedureFlagsEnum::pure;
1559+
if (characteristic->IsElemental())
1560+
flags = flags | fir::FortranProcedureFlagsEnum::elemental;
1561+
// TODO:
1562+
// - SIMPLE: F2023, not yet handled by semantics.
1563+
// - NON_RECURSIVE: not part of the characteristics. Maybe this should
1564+
// simply not be part of FortranProcedureFlagsEnum since cannot accurately
1565+
// be known on the caller side.
1566+
if (flags != fir::FortranProcedureFlagsEnum::none)
1567+
return fir::FortranProcedureFlagsEnumAttr::get(mlirContext, flags);
1568+
}
1569+
return nullptr;
1570+
}
1571+
15491572
template class Fortran::lower::CallInterface<Fortran::lower::CalleeInterface>;
15501573
template class Fortran::lower::CallInterface<Fortran::lower::CallerInterface>;
15511574

flang/lib/Lower/ConvertCall.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,9 @@ std::pair<fir::ExtendedValue, bool> Fortran::lower::genCallOpAndResult(
631631
if (callNumResults != 0)
632632
callResult = dispatch.getResult(0);
633633
} else {
634-
// TODO: gather other procedure attributes.
635-
fir::FortranProcedureFlagsEnumAttr procAttrs;
636-
if (caller.characterize().IsBindC())
637-
procAttrs = fir::FortranProcedureFlagsEnumAttr::get(
638-
builder.getContext(), fir::FortranProcedureFlagsEnum::bind_c);
639-
640634
// Standard procedure call with fir.call.
635+
fir::FortranProcedureFlagsEnumAttr procAttrs =
636+
caller.getProcedureAttrs(builder.getContext());
641637
auto call = builder.create<fir::CallOp>(
642638
loc, funcType.getResults(), funcSymbolAttr, operands, procAttrs);
643639

flang/test/Lower/HLFIR/array-ctor-as-elemental-nested.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
! CHECK: %[[VAL_21:.*]]:3 = hlfir.associate %[[VAL_22:.*]](%[[VAL_17]]) {adapt.valuebyref} : (!hlfir.expr<2xf32>, !fir.shape<1>) -> (!fir.ref<!fir.array<2xf32>>, !fir.ref<!fir.array<2xf32>>, i1)
3232
! CHECK: %[[VAL_23:.*]] = fir.embox %[[VAL_21]]#0(%[[VAL_17]]) : (!fir.ref<!fir.array<2xf32>>, !fir.shape<1>) -> !fir.box<!fir.array<2xf32>>
3333
! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_23]] : (!fir.box<!fir.array<2xf32>>) -> !fir.box<!fir.array<?xf32>>
34-
! CHECK: %[[VAL_25:.*]] = fir.call @_QPfoo(%[[VAL_24]]) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> f32
34+
! CHECK: %[[VAL_25:.*]] = fir.call @_QPfoo(%[[VAL_24]]) proc_attrs<pure> fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> f32
3535
! CHECK: hlfir.end_associate %[[VAL_21]]#1, %[[VAL_21]]#2 : !fir.ref<!fir.array<2xf32>>, i1
3636
! CHECK: hlfir.destroy %[[VAL_22]] : !hlfir.expr<2xf32>
3737
! CHECK: hlfir.yield_element %[[VAL_25]] : f32

flang/test/Lower/HLFIR/array-ctor-as-elemental.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ integer pure function foo(i)
107107
! CHECK: %[[VAL_13:.*]] = arith.addi %[[VAL_5]], %[[VAL_12]] : index
108108
! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (index) -> i64
109109
! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i64) -> i32
110-
! CHECK: %[[VAL_16:.*]] = fir.call @_QPfoo(%[[VAL_15]]) fastmath<contract> : (i32) -> i32
110+
! CHECK: %[[VAL_16:.*]] = fir.call @_QPfoo(%[[VAL_15]]) proc_attrs<pure> fastmath<contract> : (i32) -> i32
111111
! CHECK: hlfir.yield_element %[[VAL_16]] : i32
112112
! CHECK: }
113113
! CHECK: %[[VAL_17:.*]]:3 = hlfir.associate %[[VAL_18:.*]](%[[VAL_3]]) {adapt.valuebyref} : (!hlfir.expr<4xi32>, !fir.shape<1>) -> (!fir.ref<!fir.array<4xi32>>, !fir.ref<!fir.array<4xi32>>, i1)

flang/test/Lower/HLFIR/elemental-array-ops.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ end subroutine char_return
182182
! CHECK: %[[VAL_23:.*]] = arith.constant 0 : index
183183
! CHECK: %[[VAL_24:.*]] = arith.cmpi sgt, %[[VAL_22]], %[[VAL_23]] : index
184184
! CHECK: %[[VAL_25:.*]] = arith.select %[[VAL_24]], %[[VAL_22]], %[[VAL_23]] : index
185-
! CHECK: %[[VAL_27:.*]] = fir.call @_QPcallee(%[[VAL_2]], %[[VAL_25]], %[[VAL_20]]) fastmath<contract> : (!fir.ref<!fir.char<1,3>>, index, !fir.boxchar<1>) -> !fir.boxchar<1>
185+
! CHECK: %[[VAL_27:.*]] = fir.call @_QPcallee(%[[VAL_2]], %[[VAL_25]], %[[VAL_20]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.ref<!fir.char<1,3>>, index, !fir.boxchar<1>) -> !fir.boxchar<1>
186186
! CHECK: %[[VAL_28:.*]]:2 = hlfir.declare %[[VAL_2]] typeparams %[[VAL_25]] {uniq_name = ".tmp.func_result"} : (!fir.ref<!fir.char<1,3>>, index) -> (!fir.ref<!fir.char<1,3>>, !fir.ref<!fir.char<1,3>>)
187187
! CHECK: %[[MustFree:.*]] = arith.constant false
188188
! CHECK: %[[ResultTemp:.*]] = hlfir.as_expr %[[VAL_28]]#0 move %[[MustFree]] : (!fir.ref<!fir.char<1,3>>, i1) -> !hlfir.expr<!fir.char<1,3>>

flang/test/Lower/HLFIR/elemental-user-procedure-ref.f90

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ real elemental function elem(a, b)
1818
! CHECK: %[[VAL_6:.*]] = hlfir.elemental %[[VAL_4]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xf32> {
1919
! CHECK: ^bb0(%[[VAL_7:.*]]: index):
2020
! CHECK: %[[VAL_8:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_7]]) : (!fir.ref<!fir.array<100xf32>>, index) -> !fir.ref<f32>
21-
! CHECK: %[[VAL_9:.*]] = fir.call @_QPelem(%[[VAL_2]]#1, %[[VAL_8]]) fastmath<contract> : (!fir.ref<i32>, !fir.ref<f32>) -> f32
21+
! CHECK: %[[VAL_9:.*]] = fir.call @_QPelem(%[[VAL_2]]#1, %[[VAL_8]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.ref<i32>, !fir.ref<f32>) -> f32
2222
! CHECK: hlfir.yield_element %[[VAL_9]] : f32
2323
! CHECK: }
2424
! CHECK: fir.call
@@ -43,7 +43,7 @@ real elemental function elem_val(a, b)
4343
! CHECK: ^bb0(%[[VAL_9:.*]]: index, %[[VAL_10:.*]]: index):
4444
! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_9]], %[[VAL_10]]) : (!fir.ref<!fir.array<10x20xf32>>, index, index) -> !fir.ref<f32>
4545
! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_11]] : !fir.ref<f32>
46-
! CHECK: %[[VAL_13:.*]] = fir.call @_QPelem_val(%[[VAL_7]], %[[VAL_12]]) fastmath<contract> : (i32, f32) -> f32
46+
! CHECK: %[[VAL_13:.*]] = fir.call @_QPelem_val(%[[VAL_7]], %[[VAL_12]]) proc_attrs<elemental, pure> fastmath<contract> : (i32, f32) -> f32
4747
! CHECK: hlfir.yield_element %[[VAL_13]] : f32
4848
! CHECK: }
4949
! CHECK: fir.call
@@ -67,7 +67,7 @@ real elemental function char_elem(a, b)
6767
! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xf32> {
6868
! CHECK: ^bb0(%[[VAL_10:.*]]: index):
6969
! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_8]]#0 (%[[VAL_10]]) typeparams %[[VAL_4]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
70-
! CHECK: %[[VAL_12:.*]] = fir.call @_QPchar_elem(%[[VAL_3]]#0, %[[VAL_11]]) fastmath<contract> : (!fir.boxchar<1>, !fir.boxchar<1>) -> f32
70+
! CHECK: %[[VAL_12:.*]] = fir.call @_QPchar_elem(%[[VAL_3]]#0, %[[VAL_11]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.boxchar<1>) -> f32
7171
! CHECK: hlfir.yield_element %[[VAL_12]] : f32
7272
! CHECK: }
7373
! CHECK: fir.call
@@ -93,7 +93,7 @@ elemental subroutine elem_sub(a, b)
9393
! CHECK: fir.do_loop %[[VAL_8:.*]] = %[[VAL_7]] to %[[VAL_4]] step %[[VAL_7]] unordered {
9494
! CHECK: fir.do_loop %[[VAL_9:.*]] = %[[VAL_7]] to %[[VAL_3]] step %[[VAL_7]] unordered {
9595
! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_9]], %[[VAL_8]]) : (!fir.ref<!fir.array<10x20xf32>>, index, index) -> !fir.ref<f32>
96-
! CHECK: fir.call @_QPelem_sub(%[[VAL_2]]#1, %[[VAL_10]]) fastmath<contract> : (!fir.ref<i32>, !fir.ref<f32>) -> ()
96+
! CHECK: fir.call @_QPelem_sub(%[[VAL_2]]#1, %[[VAL_10]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.ref<i32>, !fir.ref<f32>) -> ()
9797
! CHECK: }
9898
! CHECK: }
9999

@@ -116,7 +116,7 @@ impure elemental subroutine impure_elem(a)
116116
! CHECK: fir.do_loop %[[VAL_6:.*]] = %[[VAL_5]] to %[[VAL_2]] step %[[VAL_5]] {
117117
! CHECK: fir.do_loop %[[VAL_7:.*]] = %[[VAL_5]] to %[[VAL_1]] step %[[VAL_5]] {
118118
! CHECK: %[[VAL_8:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_7]], %[[VAL_6]]) : (!fir.ref<!fir.array<10x20xf32>>, index, index) -> !fir.ref<f32>
119-
! CHECK: fir.call @_QPimpure_elem(%[[VAL_8]]) fastmath<contract> : (!fir.ref<f32>) -> ()
119+
! CHECK: fir.call @_QPimpure_elem(%[[VAL_8]]) proc_attrs<elemental> fastmath<contract> : (!fir.ref<f32>) -> ()
120120
! CHECK: }
121121
! CHECK: }
122122
! CHECK: return
@@ -141,7 +141,7 @@ elemental subroutine ordered_elem(a)
141141
! CHECK: fir.do_loop %[[VAL_6:.*]] = %[[VAL_5]] to %[[VAL_2]] step %[[VAL_5]] {
142142
! CHECK: fir.do_loop %[[VAL_7:.*]] = %[[VAL_5]] to %[[VAL_1]] step %[[VAL_5]] {
143143
! CHECK: %[[VAL_8:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_7]], %[[VAL_6]]) : (!fir.ref<!fir.array<10x20xf32>>, index, index) -> !fir.ref<f32>
144-
! CHECK: fir.call @_QPordered_elem(%[[VAL_8]]) fastmath<contract> : (!fir.ref<f32>) -> ()
144+
! CHECK: fir.call @_QPordered_elem(%[[VAL_8]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.ref<f32>) -> ()
145145
! CHECK: }
146146
! CHECK: }
147147
! CHECK: return
@@ -174,7 +174,7 @@ impure elemental subroutine impure_elem(a)
174174
! CHECK: fir.do_loop %[[VAL_14:.*]] = %[[VAL_13]] to %[[VAL_2]] step %[[VAL_13]] {
175175
! CHECK: fir.do_loop %[[VAL_15:.*]] = %[[VAL_13]] to %[[VAL_1]] step %[[VAL_13]] {
176176
! CHECK: %[[VAL_16:.*]] = hlfir.designate %[[VAL_11]]#0 (%[[VAL_15]], %[[VAL_14]]) : (!fir.ref<!fir.array<10x20xf32>>, index, index) -> !fir.ref<f32>
177-
! CHECK: fir.call @_QPimpure_elem(%[[VAL_16]]) fastmath<contract> : (!fir.ref<f32>) -> ()
177+
! CHECK: fir.call @_QPimpure_elem(%[[VAL_16]]) proc_attrs<elemental> fastmath<contract> : (!fir.ref<f32>) -> ()
178178
! CHECK: }
179179
! CHECK: }
180180
! CHECK: hlfir.end_associate %[[VAL_11]]#1, %[[VAL_11]]#2 : !fir.ref<!fir.array<10x20xf32>>, i1

flang/test/Lower/HLFIR/forall.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ subroutine test_forall_mask()
8686
! CHECK: } (%[[VAL_9:.*]]: i64) {
8787
! CHECK: %[[VAL_10:.*]] = hlfir.forall_index "i" %[[VAL_9]] : (i64) -> !fir.ref<i64>
8888
! CHECK: hlfir.forall_mask {
89-
! CHECK: %[[VAL_11:.*]] = fir.call @_QPpredicate(%[[VAL_10]]) fastmath<contract> : (!fir.ref<i64>) -> !fir.logical<4>
89+
! CHECK: %[[VAL_11:.*]] = fir.call @_QPpredicate(%[[VAL_10]]) proc_attrs<pure> fastmath<contract> : (!fir.ref<i64>) -> !fir.logical<4>
9090
! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.logical<4>) -> i1
9191
! CHECK: hlfir.yield %[[VAL_12]] : i1
9292
! CHECK: } do {
@@ -113,8 +113,8 @@ subroutine test_forall_several_indices()
113113
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare {{.*}}Ey
114114
! CHECK: %[[VAL_7:.*]] = fir.call @_QPibar() fastmath<contract> : () -> i32
115115
! CHECK: %[[VAL_8:.*]] = fir.call @_QPifoo() fastmath<contract> : () -> i32
116-
! CHECK: %[[VAL_9:.*]] = fir.call @_QPjfoo() fastmath<contract> : () -> i64
117-
! CHECK: %[[VAL_10:.*]] = fir.call @_QPjbar() fastmath<contract> : () -> i64
116+
! CHECK: %[[VAL_9:.*]] = fir.call @_QPjfoo() proc_attrs<pure> fastmath<contract> : () -> i64
117+
! CHECK: %[[VAL_10:.*]] = fir.call @_QPjbar() proc_attrs<pure> fastmath<contract> : () -> i64
118118
! CHECK: hlfir.forall lb {
119119
! CHECK: hlfir.yield %[[VAL_7]] : i32
120120
! CHECK: } ub {
@@ -126,7 +126,7 @@ subroutine test_forall_several_indices()
126126
! CHECK: hlfir.yield %[[VAL_10]] : i64
127127
! CHECK: } (%[[VAL_12:.*]]: i64) {
128128
! CHECK: hlfir.region_assign {
129-
! CHECK: %[[VAL_13:.*]] = fir.call @_QPifoo2(%[[VAL_11]], %[[VAL_12]]) fastmath<contract> : (i64, i64) -> i64
129+
! CHECK: %[[VAL_13:.*]] = fir.call @_QPifoo2(%[[VAL_11]], %[[VAL_12]]) proc_attrs<pure> fastmath<contract> : (i64, i64) -> i64
130130
! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_13]]) : (!fir.ref<!fir.array<10xi32>>, i64) -> !fir.ref<i32>
131131
! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_14]] : !fir.ref<i32>
132132
! CHECK: hlfir.yield %[[VAL_15]] : i32
@@ -169,10 +169,10 @@ subroutine test_nested_foralls()
169169
! CHECK: hlfir.yield %[[VAL_12]] : !fir.ref<i32>
170170
! CHECK: }
171171
! CHECK: hlfir.forall lb {
172-
! CHECK: %[[VAL_13:.*]] = fir.call @_QPjfoo() fastmath<contract> : () -> i64
172+
! CHECK: %[[VAL_13:.*]] = fir.call @_QPjfoo() proc_attrs<pure> fastmath<contract> : () -> i64
173173
! CHECK: hlfir.yield %[[VAL_13]] : i64
174174
! CHECK: } ub {
175-
! CHECK: %[[VAL_14:.*]] = fir.call @_QPjbar() fastmath<contract> : () -> i64
175+
! CHECK: %[[VAL_14:.*]] = fir.call @_QPjbar() proc_attrs<pure> fastmath<contract> : () -> i64
176176
! CHECK: hlfir.yield %[[VAL_14]] : i64
177177
! CHECK: } (%[[VAL_15:.*]]: i64) {
178178
! CHECK: hlfir.region_assign {

flang/test/Lower/HLFIR/where-nonelemental.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ integer pure function pure_ifoo()
125125
! CHECK: hlfir.where {
126126
! CHECK: %[[VAL_21:.*]] = llvm.intr.stacksave : !llvm.ptr
127127
! CHECK-NOT: hlfir.exactly_once
128-
! CHECK: %[[VAL_23:.*]] = fir.call @_QPpure_logical_func1() fastmath<contract> : () -> !fir.array<100x!fir.logical<4>>
128+
! CHECK: %[[VAL_23:.*]] = fir.call @_QPpure_logical_func1() proc_attrs<pure> fastmath<contract> : () -> !fir.array<100x!fir.logical<4>>
129129
! CHECK: hlfir.yield %{{.*}} : !hlfir.expr<100x!fir.logical<4>> cleanup {
130130
! CHECK: llvm.intr.stackrestore %[[VAL_21]] : !llvm.ptr
131131
! CHECK: }
@@ -173,7 +173,7 @@ integer pure function pure_ifoo()
173173
! CHECK: hlfir.elsewhere mask {
174174
! CHECK: %[[VAL_129:.*]] = hlfir.exactly_once : !hlfir.expr<100x!fir.logical<4>> {
175175
! CHECK: %[[VAL_139:.*]] = llvm.intr.stacksave : !llvm.ptr
176-
! CHECK: %[[VAL_141:.*]] = fir.call @_QPpure_logical_func2() fastmath<contract> : () -> !fir.array<100x!fir.logical<4>>
176+
! CHECK: %[[VAL_141:.*]] = fir.call @_QPpure_logical_func2() proc_attrs<pure> fastmath<contract> : () -> !fir.array<100x!fir.logical<4>>
177177
! CHECK: hlfir.yield %{{.*}} : !hlfir.expr<100x!fir.logical<4>> cleanup {
178178
! CHECK: llvm.intr.stackrestore %[[VAL_139]] : !llvm.ptr
179179
! CHECK: }
@@ -185,7 +185,7 @@ integer pure function pure_ifoo()
185185
! CHECK: hlfir.yield %{{.*}} : !fir.box<!fir.array<?xf32>>
186186
! CHECK: } to {
187187
! CHECK: %[[VAL_165:.*]] = hlfir.exactly_once : i32 {
188-
! CHECK: %[[VAL_166:.*]] = fir.call @_QPpure_ifoo() fastmath<contract> : () -> i32
188+
! CHECK: %[[VAL_166:.*]] = fir.call @_QPpure_ifoo() proc_attrs<pure> fastmath<contract> : () -> i32
189189
! CHECK: hlfir.yield %[[VAL_166]] : i32
190190
! CHECK: }
191191
! CHECK: hlfir.designate

flang/test/Lower/array-elemental-calls-char.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ subroutine foo2b(i, j, c)
123123
! CHECK: %[[VAL_13:.*]] = fir.emboxchar %[[VAL_7]], %[[VAL_3]] : (!fir.ref<!fir.char<1,10>>, index) -> !fir.boxchar<1>
124124
! CHECK: %[[VAL_14:.*]] = arith.addi %[[VAL_9]], %[[VAL_5]] : index
125125
! CHECK: %[[VAL_15:.*]] = fir.array_coor %[[VAL_1]](%[[VAL_8]]) %[[VAL_14]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
126-
! CHECK: %[[VAL_16:.*]] = fir.call @_QPelem2(%[[VAL_13]], %[[VAL_15]]) fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
126+
! CHECK: %[[VAL_16:.*]] = fir.call @_QPelem2(%[[VAL_13]], %[[VAL_15]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
127127
! CHECK: %[[VAL_17:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_8]]) %[[VAL_14]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
128128
! CHECK: fir.store %[[VAL_16]] to %[[VAL_17]] : !fir.ref<i32>
129129
! CHECK: %[[VAL_18:.*]] = arith.subi %[[VAL_10]], %[[VAL_5]] : index

flang/test/Lower/array-user-def-assignments.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ elemental subroutine sto_char(a,b)
442442
! CHECK: %[[V_6:[0-9]+]] = fir.do_loop %arg2 = %[[V_2]] to %[[V_3]] step %[[C_1]] unordered iter_args(%arg3 = %[[V_5]]) -> (!fir.array<10x!fir.logical<4>>) {
443443
! CHECK: %[[V_7:[0-9]+]] = fir.convert %arg2 : (index) -> i32
444444
! CHECK: fir.store %[[V_7]] to %[[V_1:[0-9]+]] : !fir.ref<i32>
445-
! CHECK: %[[V_8:[0-9]+]] = fir.call @_QPreturns_alloc(%[[V_1]]) fastmath<contract> : (!fir.ref<i32>) -> !fir.box<!fir.heap<f32>>
445+
! CHECK: %[[V_8:[0-9]+]] = fir.call @_QPreturns_alloc(%[[V_1]]) proc_attrs<pure> fastmath<contract> : (!fir.ref<i32>) -> !fir.box<!fir.heap<f32>>
446446
! CHECK: fir.save_result %[[V_8]] to %[[V_0:[0-9]+]] : !fir.box<!fir.heap<f32>>, !fir.ref<!fir.box<!fir.heap<f32>>>
447447
! CHECK: %[[V_9:[0-9]+]] = fir.load %[[V_0:[0-9]+]] : !fir.ref<!fir.box<!fir.heap<f32>>>
448448
! CHECK: %[[V_10:[0-9]+]] = fir.box_addr %[[V_9:[0-9]+]] : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>

0 commit comments

Comments
 (0)