Skip to content

Commit bb8bf85

Browse files
authored
[flang] add internal_assoc flag to mark variable captured in internal procedure (#117161)
This patch adds a flag to mark hlfir.declare of host variables that are captured in some internal procedure. It enables implementing a simple fir.call handling in fir::AliasAnalysis::getModRef leveraging Fortran language specifications and without a data flow analysis. This will allow implementing an optimization for "array = array_function()" where array storage is passed directly into the hidden result argument to "array_function" when it can be proven that arraY_function does not reference "array". Captured host variables are very tricky because they may be accessed indirectly in any calls if the internal procedure address was captured via some global procedure pointer. Without flagging them, there is no way around doing a complex inter procedural data flow analysis: - checking that the call is not made to an internal procedure is not enough because of the possibility of indirect calls made to internal procedures inside the callee. - checking that the current func.func has no internal procedure is not enough because this would be invalid with inlining when an procedure with internal procedures is inlined inside a procedure without internal procedure.
1 parent 1b2c8f1 commit bb8bf85

File tree

10 files changed

+80
-12
lines changed

10 files changed

+80
-12
lines changed

flang/include/flang/Lower/AbstractConverter.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class SymMap;
6161
struct SymbolBox;
6262
namespace pft {
6363
struct Variable;
64+
struct FunctionLikeUnit;
6465
}
6566

6667
using SomeExpr = Fortran::evaluate::Expr<Fortran::evaluate::SomeType>;
@@ -233,6 +234,10 @@ class AbstractConverter {
233234
virtual bool
234235
isRegisteredDummySymbol(Fortran::semantics::SymbolRef symRef) const = 0;
235236

237+
/// Returns the FunctionLikeUnit being lowered, if any.
238+
virtual const Fortran::lower::pft::FunctionLikeUnit *
239+
getCurrentFunctionUnit() const = 0;
240+
236241
//===--------------------------------------------------------------------===//
237242
// Types
238243
//===--------------------------------------------------------------------===//

flang/include/flang/Lower/PFTBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ struct FunctionLikeUnit : public ProgramUnit {
693693
/// Return the host associations for this function like unit. The list of host
694694
/// associations are kept in the host procedure.
695695
HostAssociations &getHostAssoc() { return hostAssociations; }
696+
const HostAssociations &getHostAssoc() const { return hostAssociations; };
696697

697698
LLVM_DUMP_METHOD void dump() const;
698699

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ def FIRpointer : I32BitEnumAttrCaseBit<"pointer", 9>;
3232
def FIRtarget : I32BitEnumAttrCaseBit<"target", 10>;
3333
def FIRvalue : I32BitEnumAttrCaseBit<"value", 11>;
3434
def FIRvolatile : I32BitEnumAttrCaseBit<"fortran_volatile", 12, "volatile">;
35+
// Used inside internal procedure to flag variables host associated from parent procedure.
3536
def FIRHostAssoc : I32BitEnumAttrCaseBit<"host_assoc", 13>;
37+
// Used inside parent procedure to flag variables host associated in internal procedure.
38+
def FIRInternalAssoc : I32BitEnumAttrCaseBit<"internal_assoc", 14>;
3639

3740
def fir_FortranVariableFlagsEnum : I32BitEnumAttr<
3841
"FortranVariableFlagsEnum",
3942
"Fortran variable attributes",
4043
[FIRnoAttributes, FIRallocatable, FIRasynchronous, FIRbind_c, FIRcontiguous,
4144
FIRintent_in, FIRintent_inout, FIRintent_out, FIRoptional, FIRparameter,
42-
FIRpointer, FIRtarget, FIRvalue, FIRvolatile, FIRHostAssoc]> {
45+
FIRpointer, FIRtarget, FIRvalue, FIRvolatile, FIRHostAssoc, FIRInternalAssoc]> {
4346
let separator = ", ";
4447
let cppNamespace = "::fir";
4548
let printBitEnumPrimaryGroups = 1;

flang/lib/Lower/Bridge.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,11 @@ class FirConverter : public Fortran::lower::AbstractConverter {
10581058
return registeredDummySymbols.contains(sym);
10591059
}
10601060

1061+
const Fortran::lower::pft::FunctionLikeUnit *
1062+
getCurrentFunctionUnit() const override final {
1063+
return currentFunctionUnit;
1064+
}
1065+
10611066
void registerTypeInfo(mlir::Location loc,
10621067
Fortran::lower::SymbolRef typeInfoSym,
10631068
const Fortran::semantics::DerivedTypeSpec &typeSpec,
@@ -5595,6 +5600,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
55955600
/// Lower a procedure (nest).
55965601
void lowerFunc(Fortran::lower::pft::FunctionLikeUnit &funit) {
55975602
setCurrentPosition(funit.getStartingSourceLoc());
5603+
setCurrentFunctionUnit(&funit);
55985604
for (int entryIndex = 0, last = funit.entryPointList.size();
55995605
entryIndex < last; ++entryIndex) {
56005606
funit.setActiveEntry(entryIndex);
@@ -5604,6 +5610,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
56045610
endNewFunction(funit);
56055611
}
56065612
funit.setActiveEntry(0);
5613+
setCurrentFunctionUnit(nullptr);
56075614
for (Fortran::lower::pft::ContainedUnit &unit : funit.containedUnitList)
56085615
if (auto *f = std::get_if<Fortran::lower::pft::FunctionLikeUnit>(&unit))
56095616
lowerFunc(*f); // internal procedure
@@ -5967,12 +5974,17 @@ class FirConverter : public Fortran::lower::AbstractConverter {
59675974
/// Reset all registered dummy symbols.
59685975
void resetRegisteredDummySymbols() { registeredDummySymbols.clear(); }
59695976

5977+
void setCurrentFunctionUnit(Fortran::lower::pft::FunctionLikeUnit *unit) {
5978+
currentFunctionUnit = unit;
5979+
}
5980+
59705981
//===--------------------------------------------------------------------===//
59715982

59725983
Fortran::lower::LoweringBridge &bridge;
59735984
Fortran::evaluate::FoldingContext foldingContext;
59745985
fir::FirOpBuilder *builder = nullptr;
59755986
Fortran::lower::pft::Evaluation *evalPtr = nullptr;
5987+
Fortran::lower::pft::FunctionLikeUnit *currentFunctionUnit = nullptr;
59765988
Fortran::lower::SymMap localSymbols;
59775989
Fortran::parser::CharBlock currentPosition;
59785990
TypeInfoConverter typeInfoConverter;

flang/lib/Lower/ConvertVariable.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,25 @@ cuf::DataAttributeAttr Fortran::lower::translateSymbolCUFDataAttribute(
16701670
return cuf::getDataAttribute(mlirContext, cudaAttr);
16711671
}
16721672

1673+
static bool
1674+
isCapturedInInternalProcedure(Fortran::lower::AbstractConverter &converter,
1675+
const Fortran::semantics::Symbol &sym) {
1676+
const Fortran::lower::pft::FunctionLikeUnit *funit =
1677+
converter.getCurrentFunctionUnit();
1678+
if (!funit || funit->getHostAssoc().empty())
1679+
return false;
1680+
if (funit->getHostAssoc().isAssociated(sym))
1681+
return true;
1682+
// Consider that any capture of a variable that is in an equivalence with the
1683+
// symbol implies that the storage of the symbol may also be accessed inside
1684+
// the internal procedure and flag it as captured.
1685+
if (const auto *equivSet = Fortran::semantics::FindEquivalenceSet(sym))
1686+
for (const Fortran::semantics::EquivalenceObject &eqObj : *equivSet)
1687+
if (funit->getHostAssoc().isAssociated(eqObj.symbol))
1688+
return true;
1689+
return false;
1690+
}
1691+
16731692
/// Map a symbol to its FIR address and evaluated specification expressions.
16741693
/// Not for symbols lowered to fir.box.
16751694
/// Will optionally create fir.declare.
@@ -1705,8 +1724,12 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,
17051724
if (len)
17061725
lenParams.emplace_back(len);
17071726
auto name = converter.mangleName(sym);
1727+
fir::FortranVariableFlagsEnum extraFlags = {};
1728+
if (isCapturedInInternalProcedure(converter, sym))
1729+
extraFlags = extraFlags | fir::FortranVariableFlagsEnum::internal_assoc;
17081730
fir::FortranVariableFlagsAttr attributes =
1709-
Fortran::lower::translateSymbolAttributes(builder.getContext(), sym);
1731+
Fortran::lower::translateSymbolAttributes(builder.getContext(), sym,
1732+
extraFlags);
17101733
cuf::DataAttributeAttr dataAttr =
17111734
Fortran::lower::translateSymbolCUFDataAttribute(builder.getContext(),
17121735
sym);
@@ -1793,6 +1816,8 @@ void Fortran::lower::genDeclareSymbol(
17931816
!sym.detailsIf<Fortran::semantics::CommonBlockDetails>()) {
17941817
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
17951818
const mlir::Location loc = genLocation(converter, sym);
1819+
if (isCapturedInInternalProcedure(converter, sym))
1820+
extraFlags = extraFlags | fir::FortranVariableFlagsEnum::internal_assoc;
17961821
// FIXME: Using the ultimate symbol for translating symbol attributes will
17971822
// lead to situations where the VOLATILE/ASYNCHRONOUS attributes are not
17981823
// propagated to the hlfir.declare (these attributes can be added when

flang/test/Lower/HLFIR/assumed-rank-internal-proc.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ subroutine internal()
1717
! CHECK-LABEL: func.func @_QPtest_assumed_rank(
1818
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) {
1919
! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
20-
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {uniq_name = "_QFtest_assumed_rankEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
20+
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFtest_assumed_rankEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
2121
! CHECK: %[[VAL_3:.*]] = fir.alloca tuple<!fir.box<!fir.array<*:f32>>>
2222
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i32
2323
! CHECK: %[[VAL_5:.*]] = fir.coordinate_of %[[VAL_3]], %[[VAL_4]] : (!fir.ref<tuple<!fir.box<!fir.array<*:f32>>>>, i32) -> !fir.ref<!fir.box<!fir.array<*:f32>>>
@@ -55,7 +55,7 @@ subroutine internal()
5555
! CHECK-LABEL: func.func @_QPtest_assumed_rank_optional(
5656
! CHECK-SAME: %[[VAL_0:.*]]: !fir.class<!fir.array<*:none>> {fir.bindc_name = "x", fir.optional}) {
5757
! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
58-
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<optional>, uniq_name = "_QFtest_assumed_rank_optionalEx"} : (!fir.class<!fir.array<*:none>>, !fir.dscope) -> (!fir.class<!fir.array<*:none>>, !fir.class<!fir.array<*:none>>)
58+
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<optional, internal_assoc>, uniq_name = "_QFtest_assumed_rank_optionalEx"} : (!fir.class<!fir.array<*:none>>, !fir.dscope) -> (!fir.class<!fir.array<*:none>>, !fir.class<!fir.array<*:none>>)
5959
! CHECK: %[[VAL_3:.*]] = fir.alloca tuple<!fir.class<!fir.array<*:none>>>
6060
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i32
6161
! CHECK: %[[VAL_5:.*]] = fir.coordinate_of %[[VAL_3]], %[[VAL_4]] : (!fir.ref<tuple<!fir.class<!fir.array<*:none>>>>, i32) -> !fir.ref<!fir.class<!fir.array<*:none>>>
@@ -107,7 +107,7 @@ subroutine internal()
107107
! CHECK-LABEL: func.func @_QPtest_assumed_rank_ptr(
108108
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>> {fir.bindc_name = "x"}) {
109109
! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
110-
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFtest_assumed_rank_ptrEx"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>)
110+
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<pointer, internal_assoc>, uniq_name = "_QFtest_assumed_rank_ptrEx"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>)
111111
! CHECK: %[[VAL_3:.*]] = fir.alloca tuple<!fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>>
112112
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i32
113113
! CHECK: %[[VAL_5:.*]] = fir.coordinate_of %[[VAL_3]], %[[VAL_4]] : (!fir.ref<tuple<!fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>>>, i32) -> !fir.llvm_ptr<!fir.ref<!fir.box<!fir.ptr<!fir.array<*:f32>>>>>

flang/test/Lower/HLFIR/cray-pointers.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,12 @@ subroutine internal()
381381
! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.char<1,?>>>
382382
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFtest_craypointer_captureEn"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)
383383
! CHECK: %[[VAL_3:.*]] = fir.alloca i64 {bindc_name = "cray_pointer", uniq_name = "_QFtest_craypointer_captureEcray_pointer"}
384-
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]] {uniq_name = "_QFtest_craypointer_captureEcray_pointer"} : (!fir.ref<i64>) -> (!fir.ref<i64>, !fir.ref<i64>)
384+
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFtest_craypointer_captureEcray_pointer"} : (!fir.ref<i64>) -> (!fir.ref<i64>, !fir.ref<i64>)
385385
! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_2]]#0 : !fir.ref<i32>
386386
! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i32
387387
! CHECK: %[[VAL_7:.*]] = arith.cmpi sgt, %[[VAL_5]], %[[VAL_6]] : i32
388388
! CHECK: %[[VAL_8:.*]] = arith.select %[[VAL_7]], %[[VAL_5]], %[[VAL_6]] : i32
389-
! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_1]] typeparams %[[VAL_8]] {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFtest_craypointer_captureEcray_pointee"} : (!fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>, i32) -> (!fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>)
389+
! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_1]] typeparams %[[VAL_8]] {fortran_attrs = #fir.var_attrs<pointer, internal_assoc>, uniq_name = "_QFtest_craypointer_captureEcray_pointee"} : (!fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>, i32) -> (!fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>)
390390
! CHECK: %[[VAL_10:.*]] = fir.zero_bits !fir.ptr<!fir.char<1,?>>
391391
! CHECK: %[[VAL_11:.*]] = fir.embox %[[VAL_10]] typeparams %[[VAL_8]] : (!fir.ptr<!fir.char<1,?>>, i32) -> !fir.box<!fir.ptr<!fir.char<1,?>>>
392392
! CHECK: fir.store %[[VAL_11]] to %[[VAL_9]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,?>>>>

flang/test/Lower/HLFIR/internal-procedures.f90

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ subroutine internal
99
call takes_array(x)
1010
end subroutine
1111
end subroutine
12+
! CHECK-LABEL: func.func @_QPtest_explicit_shape_array(
13+
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare {{.*}} {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFtest_explicit_shape_arrayEx"}
14+
1215
! CHECK-LABEL: func.func private @_QFtest_explicit_shape_arrayPinternal(
1316
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<!fir.box<!fir.array<?xf32>>>> {fir.host_assoc}) attributes {fir.host_symbol = {{.*}}, llvm.linkage = #llvm.linkage<internal>} {
1417
! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32
@@ -27,6 +30,9 @@ subroutine internal
2730
call takes_array(x)
2831
end subroutine
2932
end subroutine
33+
! CHECK-LABEL: func.func @_QPtest_assumed_shape(
34+
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare {{.*}} {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFtest_assumed_shapeEx"}
35+
3036
! CHECK-LABEL: func.func private @_QFtest_assumed_shapePinternal(
3137
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<tuple<!fir.box<!fir.array<?xf32>>>> {fir.host_assoc}) attributes {fir.host_symbol = {{.*}}, llvm.linkage = #llvm.linkage<internal>} {
3238
! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32
@@ -64,7 +70,7 @@ subroutine internal()
6470
end subroutine
6571
! CHECK-LABEL: func.func @_QPtest_proc_pointer(
6672
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.boxproc<() -> ()>>) {
67-
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFtest_proc_pointerEp"} : (!fir.ref<!fir.boxproc<() -> ()>>, !fir.dscope) -> (!fir.ref<!fir.boxproc<() -> ()>>, !fir.ref<!fir.boxproc<() -> ()>>)
73+
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %{{[0-9]+}} {fortran_attrs = #fir.var_attrs<pointer, internal_assoc>, uniq_name = "_QFtest_proc_pointerEp"} : (!fir.ref<!fir.boxproc<() -> ()>>, !fir.dscope) -> (!fir.ref<!fir.boxproc<() -> ()>>, !fir.ref<!fir.boxproc<() -> ()>>)
6874
! CHECK: %[[VAL_2:.*]] = fir.alloca tuple<!fir.ref<!fir.boxproc<() -> ()>>>
6975
! CHECK: %[[VAL_3:.*]] = arith.constant 0 : i32
7076
! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_3]] : (!fir.ref<tuple<!fir.ref<!fir.boxproc<() -> ()>>>>, i32) -> !fir.llvm_ptr<!fir.ref<!fir.boxproc<() -> ()>>>
@@ -79,3 +85,19 @@ subroutine internal()
7985
! CHECK: %[[VAL_2:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_1]] : (!fir.ref<tuple<!fir.ref<!fir.boxproc<() -> ()>>>>, i32) -> !fir.llvm_ptr<!fir.ref<!fir.boxproc<() -> ()>>>
8086
! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_2]] : !fir.llvm_ptr<!fir.ref<!fir.boxproc<() -> ()>>>
8187
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]] {fortran_attrs = #fir.var_attrs<pointer, host_assoc>, uniq_name = "_QFtest_proc_pointerEp"} : (!fir.ref<!fir.boxproc<() -> ()>>) -> (!fir.ref<!fir.boxproc<() -> ()>>, !fir.ref<!fir.boxproc<() -> ()>>)
88+
89+
90+
! Verify that all equivalence members gets the internal_assoc flag set if one
91+
! of them is captured in an internal procedure.
92+
subroutine test_captured_equiv()
93+
real :: x, y
94+
equivalence(x,y)
95+
call internal()
96+
contains
97+
subroutine internal()
98+
y = 0.
99+
end subroutine
100+
end subroutine
101+
! CHECK-LABEL: func.func @_QPtest_captured_equiv() {
102+
! CHECK: hlfir.declare %{{.*}} {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFtest_captured_equivEx"}
103+
! CHECK: hlfir.declare %{{.*}} {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFtest_captured_equivEy"}

flang/test/Lower/OpenMP/threadprivate-host-association-2.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
!CHECK: func.func @_QQmain() attributes {fir.bindc_name = "main"} {
77
!CHECK: %[[A:.*]] = fir.alloca i32 {bindc_name = "a", uniq_name = "_QFEa"}
8-
!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A]] {uniq_name = "_QFEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
8+
!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
99
!CHECK: %[[A_ADDR:.*]] = fir.address_of(@_QFEa) : !fir.ref<i32>
1010
!CHECK: %[[TP_A:.*]] = omp.threadprivate %[[A_ADDR]] : !fir.ref<i32> -> !fir.ref<i32>
11-
!CHECK: %[[TP_A_DECL:.*]]:2 = hlfir.declare %[[TP_A]] {uniq_name = "_QFEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
11+
!CHECK: %[[TP_A_DECL:.*]]:2 = hlfir.declare %[[TP_A]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
1212
!CHECK: fir.call @_QFPsub() fastmath<contract> : () -> ()
1313
!CHECK: return
1414
!CHECK: }

flang/test/Lower/OpenMP/threadprivate-host-association.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
!CHECK: func.func @_QQmain() attributes {fir.bindc_name = "main"} {
77
!CHECK: %[[A:.*]] = fir.address_of(@_QFEa) : !fir.ref<i32>
8-
!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A]] {uniq_name = "_QFEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
8+
!CHECK: %[[A_DECL:.*]]:2 = hlfir.declare %[[A]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
99
!CHECK: %[[TP_A:.*]] = omp.threadprivate %[[A_DECL]]#1 : !fir.ref<i32> -> !fir.ref<i32>
10-
!CHECK: %[[TP_A_DECL:.*]]:2 = hlfir.declare %[[TP_A]] {uniq_name = "_QFEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
10+
!CHECK: %[[TP_A_DECL:.*]]:2 = hlfir.declare %[[TP_A]] {fortran_attrs = #fir.var_attrs<internal_assoc>, uniq_name = "_QFEa"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
1111
!CHECK: fir.call @_QFPsub() fastmath<contract> : () -> ()
1212
!CHECK: return
1313
!CHECK: }

0 commit comments

Comments
 (0)