diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp index 4c381e85d1fdc..a21f231d21f16 100644 --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -4813,32 +4813,14 @@ class FirConverter : public Fortran::lower::AbstractConverter { // Generate pointer assignment with possibly empty bounds-spec. R1035: a // bounds-spec is a lower bound value. - void genPointerAssignment( + void genNoHLFIRPointerAssignment( mlir::Location loc, const Fortran::evaluate::Assignment &assign, const Fortran::evaluate::Assignment::BoundsSpec &lbExprs) { Fortran::lower::StatementContext stmtCtx; - if (!lowerToHighLevelFIR() && - Fortran::evaluate::IsProcedureDesignator(assign.rhs)) + assert(!lowerToHighLevelFIR() && "code should not be called with HFLIR"); + if (Fortran::evaluate::IsProcedureDesignator(assign.rhs)) TODO(loc, "procedure pointer assignment"); - if (Fortran::evaluate::IsProcedurePointer(assign.lhs)) { - hlfir::Entity lhs = Fortran::lower::convertExprToHLFIR( - loc, *this, assign.lhs, localSymbols, stmtCtx); - if (Fortran::evaluate::UnwrapExpr( - assign.rhs)) { - // rhs is null(). rhs being null(pptr) is handled in genNull. - auto boxTy{ - Fortran::lower::getUntypedBoxProcType(builder->getContext())}; - hlfir::Entity rhs( - fir::factory::createNullBoxProc(*builder, loc, boxTy)); - builder->createStoreWithConvert(loc, rhs, lhs); - return; - } - hlfir::Entity rhs(getBase(Fortran::lower::convertExprToAddress( - loc, *this, assign.rhs, localSymbols, stmtCtx))); - builder->createStoreWithConvert(loc, rhs, lhs); - return; - } std::optional lhsType = assign.lhs.GetType(); @@ -4846,7 +4828,7 @@ class FirConverter : public Fortran::lower::AbstractConverter { // to the runtime. element size, type code, attribute and of // course base_addr might need to be updated. if (lhsType && lhsType->IsPolymorphic()) { - if (!lowerToHighLevelFIR() && explicitIterationSpace()) + if (explicitIterationSpace()) TODO(loc, "polymorphic pointer assignment in FORALL"); llvm::SmallVector lbounds; for (const Fortran::evaluate::ExtentExpr &lbExpr : lbExprs) @@ -4873,7 +4855,7 @@ class FirConverter : public Fortran::lower::AbstractConverter { llvm::SmallVector lbounds; for (const Fortran::evaluate::ExtentExpr &lbExpr : lbExprs) lbounds.push_back(fir::getBase(genExprValue(toEvExpr(lbExpr), stmtCtx))); - if (!lowerToHighLevelFIR() && explicitIterationSpace()) { + if (explicitIterationSpace()) { // Pointer assignment in FORALL context. Copy the rhs box value // into the lhs box variable. genArrayAssignment(assign, stmtCtx, lbounds); @@ -4884,6 +4866,21 @@ class FirConverter : public Fortran::lower::AbstractConverter { stmtCtx); } + void genPointerAssignment(mlir::Location loc, + const Fortran::evaluate::Assignment &assign) { + if (isInsideHlfirForallOrWhere()) { + // Generate Pointer assignment as hlfir.region_assign. + genForallPointerAssignment(loc, assign); + return; + } + Fortran::lower::StatementContext stmtCtx; + hlfir::Entity lhs = Fortran::lower::convertExprToHLFIR( + loc, *this, assign.lhs, localSymbols, stmtCtx); + mlir::Value rhs = genPointerAssignmentRhs(loc, lhs, assign, stmtCtx); + builder->createStoreWithConvert(loc, rhs, lhs); + cuf::genPointerSync(lhs, *builder); + } + void genForallPointerAssignment(mlir::Location loc, const Fortran::evaluate::Assignment &assign) { // Lower pointer assignment inside forall with hlfir.region_assign with @@ -4904,8 +4901,7 @@ class FirConverter : public Fortran::lower::AbstractConverter { // Lower RHS in its own region. builder->createBlock(®ionAssignOp.getRhsRegion()); Fortran::lower::StatementContext rhsContext; - mlir::Value rhs = - genForallPointerAssignmentRhs(loc, lhs, assign, rhsContext); + mlir::Value rhs = genPointerAssignmentRhs(loc, lhs, assign, rhsContext); auto rhsYieldOp = hlfir::YieldOp::create(*builder, loc, rhs); Fortran::lower::genCleanUpInRegionIfAny( loc, *builder, rhsYieldOp.getCleanup(), rhsContext); @@ -4921,9 +4917,9 @@ class FirConverter : public Fortran::lower::AbstractConverter { } mlir::Value - genForallPointerAssignmentRhs(mlir::Location loc, mlir::Value lhs, - const Fortran::evaluate::Assignment &assign, - Fortran::lower::StatementContext &rhsContext) { + genPointerAssignmentRhs(mlir::Location loc, hlfir::Entity lhs, + const Fortran::evaluate::Assignment &assign, + Fortran::lower::StatementContext &rhsContext) { if (Fortran::evaluate::IsProcedureDesignator(assign.lhs)) { if (Fortran::evaluate::UnwrapExpr( assign.rhs)) @@ -4935,11 +4931,34 @@ class FirConverter : public Fortran::lower::AbstractConverter { // Data target. auto lhsBoxType = llvm::cast(fir::unwrapRefType(lhs.getType())); - // For NULL, create disassociated descriptor whose dynamic type is - // the static type of the LHS. + // For NULL, create disassociated descriptor whose dynamic type is the + // static type of the LHS (fulfills 7.3.2.3 requirements that the dynamic + // type of a deallocated polymorphic pointer is its static type). if (Fortran::evaluate::UnwrapExpr( - assign.rhs)) - return fir::factory::createUnallocatedBox(*builder, loc, lhsBoxType, {}); + assign.rhs)) { + llvm::SmallVector nonDeferredLenParams; + if (auto lhsVar = + llvm::dyn_cast_if_present( + lhs.getDefiningOp())) + nonDeferredLenParams = lhsVar.getExplicitTypeParams(); + if (isInsideHlfirForallOrWhere()) { + // Inside FORALL, the non deferred type parameters may only be + // accessible in the hlfir.region_assign lhs region if they were + // computed there. + for (mlir::Value ¶m : nonDeferredLenParams) + if (!param.getParentRegion()->isAncestor( + builder->getBlock()->getParent())) { + if (llvm::isa_and_nonnull( + param.getDefiningOp())) + param = builder->clone(*param.getDefiningOp())->getResult(0); + else + TODO(loc, "Pointer assignment with non deferred type parameter " + "inside FORALL"); + } + } + return fir::factory::createUnallocatedBox(*builder, loc, lhsBoxType, + nonDeferredLenParams); + } hlfir::Entity rhs = Fortran::lower::convertExprToHLFIR( loc, *this, assign.rhs, localSymbols, rhsContext); auto rhsBoxType = rhs.getBoxType(); @@ -5032,9 +5051,10 @@ class FirConverter : public Fortran::lower::AbstractConverter { // Pointer assignment with bounds-remapping. R1036: a bounds-remapping is a // pair, lower bound and upper bound. - void genPointerAssignment( + void genNoHLFIRPointerAssignment( mlir::Location loc, const Fortran::evaluate::Assignment &assign, const Fortran::evaluate::Assignment::BoundsRemapping &boundExprs) { + assert(!lowerToHighLevelFIR() && "code should not be called with HFLIR"); Fortran::lower::StatementContext stmtCtx; llvm::SmallVector lbounds; llvm::SmallVector ubounds; @@ -5053,7 +5073,7 @@ class FirConverter : public Fortran::lower::AbstractConverter { // Polymorphic lhs/rhs need more care. See F2018 10.2.2.3. if ((lhsType && lhsType->IsPolymorphic()) || (rhsType && rhsType->IsPolymorphic())) { - if (!lowerToHighLevelFIR() && explicitIterationSpace()) + if (explicitIterationSpace()) TODO(loc, "polymorphic pointer assignment in FORALL"); fir::MutableBoxValue lhsMutableBox = genExprMutableBox(loc, assign.lhs); @@ -5071,7 +5091,7 @@ class FirConverter : public Fortran::lower::AbstractConverter { rhsType->IsPolymorphic()); return; } - if (!lowerToHighLevelFIR() && explicitIterationSpace()) { + if (explicitIterationSpace()) { // Pointer assignment in FORALL context. Copy the rhs box value // into the lhs box variable. genArrayAssignment(assign, stmtCtx, lbounds, ubounds); @@ -5083,13 +5103,6 @@ class FirConverter : public Fortran::lower::AbstractConverter { fir::factory::disassociateMutableBox(*builder, loc, lhs); return; } - if (lowerToHighLevelFIR()) { - fir::ExtendedValue rhs = genExprAddr(assign.rhs, stmtCtx); - fir::factory::associateMutableBoxWithRemap(*builder, loc, lhs, rhs, - lbounds, ubounds); - return; - } - // Legacy lowering below. // Do not generate a temp in case rhs is an array section. fir::ExtendedValue rhs = Fortran::lower::isArraySectionWithoutVectorSubscript(assign.rhs) @@ -5479,18 +5492,10 @@ class FirConverter : public Fortran::lower::AbstractConverter { dirs); }, [&](const Fortran::evaluate::Assignment::BoundsSpec &lbExprs) { - if (isInsideHlfirForallOrWhere()) - genForallPointerAssignment(loc, assign); - else - genPointerAssignment(loc, assign, lbExprs); + genPointerAssignment(loc, assign); }, [&](const Fortran::evaluate::Assignment::BoundsRemapping - &boundExprs) { - if (isInsideHlfirForallOrWhere()) - genForallPointerAssignment(loc, assign); - else - genPointerAssignment(loc, assign, boundExprs); - }, + &boundExprs) { genPointerAssignment(loc, assign); }, }, assign.u); return; @@ -5692,11 +5697,11 @@ class FirConverter : public Fortran::lower::AbstractConverter { }, [&](const Fortran::evaluate::Assignment::BoundsSpec &lbExprs) { - return genPointerAssignment(loc, assign, lbExprs); + return genNoHLFIRPointerAssignment(loc, assign, lbExprs); }, [&](const Fortran::evaluate::Assignment::BoundsRemapping &boundExprs) { - return genPointerAssignment(loc, assign, boundExprs); + return genNoHLFIRPointerAssignment(loc, assign, boundExprs); }, }, assign.u); diff --git a/flang/lib/Optimizer/Builder/HLFIRTools.cpp b/flang/lib/Optimizer/Builder/HLFIRTools.cpp index b435ae15cff58..a345dcb86e3d6 100644 --- a/flang/lib/Optimizer/Builder/HLFIRTools.cpp +++ b/flang/lib/Optimizer/Builder/HLFIRTools.cpp @@ -402,9 +402,9 @@ hlfir::Entity hlfir::genVariableBox(mlir::Location loc, fir::BoxType::get(var.getElementOrSequenceType(), isVolatile); if (forceBoxType) { boxType = forceBoxType; - mlir::Type baseType = - fir::ReferenceType::get(fir::unwrapRefType(forceBoxType.getEleTy())); - addr = builder.createConvert(loc, baseType, addr); + mlir::Type baseType = fir::ReferenceType::get( + fir::unwrapRefType(forceBoxType.getEleTy()), forceBoxType.isVolatile()); + addr = builder.createConvertWithVolatileCast(loc, baseType, addr); } auto embox = fir::EmboxOp::create(builder, loc, boxType, addr, shape, /*slice=*/mlir::Value{}, typeParams); diff --git a/flang/test/Lower/HLFIR/allocatable-and-pointer-status-change.f90 b/flang/test/Lower/HLFIR/allocatable-and-pointer-status-change.f90 index 9d77516a3fd38..0c57b201b4646 100644 --- a/flang/test/Lower/HLFIR/allocatable-and-pointer-status-change.f90 +++ b/flang/test/Lower/HLFIR/allocatable-and-pointer-status-change.f90 @@ -34,7 +34,7 @@ subroutine pointer_assignment(p, ziel) ! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_1:[a-z0-9]*]](%[[VAL_5:[a-z0-9]*]]) dummy_scope %{{[0-9]+}} arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, {{.*}}Eziel p => ziel ! CHECK: %[[VAL_7:.*]] = fir.shift %[[VAL_4:.*]] : (index) -> !fir.shift<1> -! CHECK: %[[VAL_8:.*]] = fir.rebox %[[VAL_6]]#1(%[[VAL_7]]) : (!fir.box>, !fir.shift<1>) -> !fir.box>> +! CHECK: %[[VAL_8:.*]] = fir.rebox %[[VAL_6]]#0(%[[VAL_7]]) : (!fir.box>, !fir.shift<1>) -> !fir.box>> ! CHECK: fir.store %[[VAL_8]] to %[[VAL_2]]#0 : !fir.ref>>> p => ziel(42:77:3) ! CHECK: %[[VAL_14:.*]] = hlfir.designate %{{.*}}#0 (%{{.*}}:%{{.*}}:%{{.*}}) shape %{{.*}} : (!fir.box>, index, index, index, !fir.shape<1>) -> !fir.box> @@ -49,27 +49,29 @@ subroutine pointer_remapping(p, ziel) ! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] dummy_scope %{{[0-9]+}} arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, {{.*}}Ep ! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_1:[a-z0-9]*]](%[[VAL_6:[a-z0-9]*]]) dummy_scope %{{[0-9]+}} arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, {{.*}}Eziel p(2:7, 3:102) => ziel -! CHECK: %[[VAL_8:.*]] = arith.constant 2 : i64 -! CHECK: %[[VAL_9:.*]] = arith.constant 7 : i64 -! CHECK: %[[VAL_10:.*]] = arith.constant 3 : i64 -! CHECK: %[[VAL_11:.*]] = arith.constant 102 : i64 -! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index -! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_8]] : (i64) -> index -! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_9]] : (i64) -> index -! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_14]], %[[VAL_13]] : index -! CHECK: %[[VAL_16:.*]] = arith.addi %[[VAL_15]], %[[VAL_12]] : index -! CHECK: %[[cmp0:.*]] = arith.cmpi sgt, %[[VAL_16]], %c0{{.*}} : index -! CHECK: %[[ext0:.*]] = arith.select %[[cmp0]], %[[VAL_16]], %c0{{.*}} : index -! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_10]] : (i64) -> index -! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_11]] : (i64) -> index -! CHECK: %[[VAL_19:.*]] = arith.subi %[[VAL_18]], %[[VAL_17]] : index -! CHECK: %[[VAL_20:.*]] = arith.addi %[[VAL_19]], %[[VAL_12]] : index -! CHECK: %[[cmp1:.*]] = arith.cmpi sgt, %[[VAL_20]], %c0{{.*}} : index -! CHECK: %[[ext1:.*]] = arith.select %[[cmp1]], %[[VAL_20]], %c0{{.*}} : index -! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_7]]#0 : (!fir.ref>) -> !fir.ref> -! CHECK: %[[VAL_22:.*]] = fir.shape_shift %[[VAL_8]], %[[ext0]], %[[VAL_10]], %[[ext1]] : (i64, index, i64, index) -> !fir.shapeshift<2> -! CHECK: %[[VAL_23:.*]] = fir.embox %[[VAL_21]](%[[VAL_22]]) : (!fir.ref>, !fir.shapeshift<2>) -> !fir.box>> -! CHECK: fir.store %[[VAL_23]] to %[[VAL_2]]#0 : !fir.ref>>> +! CHECK: %[[CONVERT_0:.*]] = fir.convert %[[VAL_7]]#0 : (!fir.ref>) -> !fir.ref> +! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[CONVERT_0]](%[[VAL_6]]) : (!fir.ref>, !fir.shape<3>) -> !fir.box>> +! CHECK: %[[CONSTANT_3:.*]] = arith.constant 0 : index +! CHECK: %[[CONSTANT_4:.*]] = arith.constant 1 : index +! CHECK: %[[CONSTANT_5:.*]] = arith.constant 2 : i64 +! CHECK: %[[CONVERT_1:.*]] = fir.convert %[[CONSTANT_5]] : (i64) -> index +! CHECK: %[[CONSTANT_6:.*]] = arith.constant 7 : i64 +! CHECK: %[[CONVERT_2:.*]] = fir.convert %[[CONSTANT_6]] : (i64) -> index +! CHECK: %[[SUBI_0:.*]] = arith.subi %[[CONVERT_2]], %[[CONVERT_1]] : index +! CHECK: %[[ADDI_0:.*]] = arith.addi %[[SUBI_0]], %[[CONSTANT_4]] : index +! CHECK: %[[CMPI_0:.*]] = arith.cmpi sgt, %[[ADDI_0]], %[[CONSTANT_3]] : index +! CHECK: %[[SELECT_0:.*]] = arith.select %[[CMPI_0]], %[[ADDI_0]], %[[CONSTANT_3]] : index +! CHECK: %[[CONSTANT_7:.*]] = arith.constant 3 : i64 +! CHECK: %[[CONVERT_3:.*]] = fir.convert %[[CONSTANT_7]] : (i64) -> index +! CHECK: %[[CONSTANT_8:.*]] = arith.constant 102 : i64 +! CHECK: %[[CONVERT_4:.*]] = fir.convert %[[CONSTANT_8]] : (i64) -> index +! CHECK: %[[SUBI_1:.*]] = arith.subi %[[CONVERT_4]], %[[CONVERT_3]] : index +! CHECK: %[[ADDI_1:.*]] = arith.addi %[[SUBI_1]], %[[CONSTANT_4]] : index +! CHECK: %[[CMPI_1:.*]] = arith.cmpi sgt, %[[ADDI_1]], %[[CONSTANT_3]] : index +! CHECK: %[[SELECT_1:.*]] = arith.select %[[CMPI_1]], %[[ADDI_1]], %[[CONSTANT_3]] : index +! CHECK: %[[SHAPE_SHIFT_0:.*]] = fir.shape_shift %[[CONVERT_1]], %[[SELECT_0]], %[[CONVERT_3]], %[[SELECT_1]] : (index, index, index, index) -> !fir.shapeshift<2> +! CHECK: %[[REBOX_0:.*]] = fir.rebox %[[EMBOX_0]](%[[SHAPE_SHIFT_0]]) : (!fir.box>>, !fir.shapeshift<2>) -> !fir.box>> +! CHECK: fir.store %[[REBOX_0]] to %[[VAL_2]]#0 : !fir.ref>>> end subroutine subroutine alloc_comp(x) @@ -109,7 +111,7 @@ subroutine ptr_comp_assign(x, ziel) ! CHECK: %[[VAL_8:.*]] = arith.constant 9 : index ! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_8]]) : (!fir.ref>>}>>>, index) -> !fir.ref>>}>> ! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_9]]{"p"} {fortran_attrs = #fir.var_attrs} : (!fir.ref>>}>>) -> !fir.ref>>> -! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1> -! CHECK: %[[VAL_12:.*]] = fir.embox %[[VAL_7]]#0(%[[VAL_11]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box>> +! CHECK: %[[CAST:.*]] = fir.convert %[[VAL_7]]#0 : (!fir.ref>) -> !fir.ref> +! CHECK: %[[VAL_12:.*]] = fir.embox %[[CAST]](%[[VAL_6]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box>> ! CHECK: fir.store %[[VAL_12]] to %[[VAL_10]] : !fir.ref>>> end subroutine diff --git a/flang/test/Lower/HLFIR/issue80884.f90 b/flang/test/Lower/HLFIR/issue80884.f90 index a5a51782ae735..063f371b1efbc 100644 --- a/flang/test/Lower/HLFIR/issue80884.f90 +++ b/flang/test/Lower/HLFIR/issue80884.f90 @@ -14,21 +14,22 @@ subroutine issue80884(p, targ) ! CHECK-LABEL: func.func @_QPissue80884( ! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %{{.*}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFissue80884Ep"} : (!fir.ref>>>, !fir.dscope) -> (!fir.ref>>>, !fir.ref>>>) ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFissue80884Etarg"} : (!fir.ref}>}>>, !fir.dscope) -> (!fir.ref}>}>>, !fir.ref}>}>>) -! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i64 -! CHECK: %[[VAL_5:.*]] = arith.constant 100 : i64 ! CHECK: %[[VAL_6:.*]] = hlfir.designate %[[VAL_3]]#0{"t0"} : (!fir.ref}>}>>) -> !fir.ref}>> ! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index ! CHECK: %[[VAL_8:.*]] = arith.constant 10 : index ! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_7]], %[[VAL_8]] : (index, index) -> !fir.shape<2> ! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_6]]{"array"} shape %[[VAL_9]] : (!fir.ref}>>, !fir.shape<2>) -> !fir.ref> +! CHECK: %[[CAST:.*]] = fir.convert %[[VAL_10]] : (!fir.ref>) -> !fir.ref> +! CHECK: %[[BOX:.*]] = fir.embox %[[CAST]](%[[VAL_9]]) : (!fir.ref>, !fir.shape<2>) -> !fir.box>> ! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index +! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i64 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_4]] : (i64) -> index +! CHECK: %[[VAL_5:.*]] = arith.constant 100 : i64 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_5]] : (i64) -> index ! CHECK: %[[VAL_14:.*]] = arith.subi %[[VAL_13]], %[[VAL_12]] : index ! CHECK: %[[VAL_15:.*]] = arith.addi %[[VAL_14]], %[[VAL_11]] : index ! CHECK: %[[cmp0:.*]] = arith.cmpi sgt, %[[VAL_15]], %c0{{.*}} : index ! CHECK: %[[ext0:.*]] = arith.select %[[cmp0]], %[[VAL_15]], %c0{{.*}} : index -! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_10]] : (!fir.ref>) -> !fir.ref> -! CHECK: %[[VAL_17:.*]] = fir.shape_shift %[[VAL_4]], %[[ext0]] : (i64, index) -> !fir.shapeshift<1> -! CHECK: %[[VAL_18:.*]] = fir.embox %[[VAL_16]](%[[VAL_17]]) : (!fir.ref>, !fir.shapeshift<1>) -> !fir.box>> +! CHECK: %[[VAL_17:.*]] = fir.shape_shift %[[VAL_12]], %[[ext0]] : (index, index) -> !fir.shapeshift<1> +! CHECK: %[[VAL_18:.*]] = fir.rebox %[[BOX]](%[[VAL_17]]) : (!fir.box>>, !fir.shapeshift<1>) -> !fir.box>> ! CHECK: fir.store %[[VAL_18]] to %[[VAL_2]]#0 : !fir.ref>>> diff --git a/flang/test/Lower/HLFIR/proc-pointer-comp-nopass.f90 b/flang/test/Lower/HLFIR/proc-pointer-comp-nopass.f90 index 206b6e4e9b797..594b6e9698b2f 100644 --- a/flang/test/Lower/HLFIR/proc-pointer-comp-nopass.f90 +++ b/flang/test/Lower/HLFIR/proc-pointer-comp-nopass.f90 @@ -57,10 +57,9 @@ subroutine test3(x) ! CHECK-LABEL: func.func @_QPtest3( ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]] {{.*}}Ex ! CHECK: %[[VAL_2:.*]] = hlfir.designate %[[VAL_1]]#0{"p"} {fortran_attrs = #fir.var_attrs} : (!fir.ref) -> f32>}>>) -> !fir.ref) -> f32>> -! CHECK: %[[VAL_3:.*]] = fir.zero_bits () -> () -! CHECK: %[[VAL_4:.*]] = fir.emboxproc %[[VAL_3]] : (() -> ()) -> !fir.boxproc<() -> ()> -! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.boxproc<() -> ()>) -> !fir.boxproc<(!fir.ref) -> f32> -! CHECK: fir.store %[[VAL_5]] to %[[VAL_2]] : !fir.ref) -> f32>> +! CHECK: %[[VAL_3:.*]] = fir.zero_bits (!fir.ref) -> f32 +! CHECK: %[[VAL_4:.*]] = fir.emboxproc %[[VAL_3]] : ((!fir.ref) -> f32) -> !fir.boxproc<(!fir.ref) -> f32> +! CHECK: fir.store %[[VAL_4]] to %[[VAL_2]] : !fir.ref) -> f32>> subroutine test4(x) use proc_comp_defs, only : t diff --git a/flang/test/Lower/HLFIR/procedure-pointer.f90 b/flang/test/Lower/HLFIR/procedure-pointer.f90 index 75e81c165d25b..23e4e8424350f 100644 --- a/flang/test/Lower/HLFIR/procedure-pointer.f90 +++ b/flang/test/Lower/HLFIR/procedure-pointer.f90 @@ -26,6 +26,7 @@ subroutine foo2(q) end module m !!! Testing declaration and initialization +! CHECK-LABEL: sub1 subroutine sub1() use m procedure(real_func), pointer :: p1 @@ -71,6 +72,7 @@ end subroutine sub1 !!! Testing pointer assignment and invocation +! CHECK-LABEL: sub2 subroutine sub2() use m procedure(real_func), pointer :: p1 @@ -81,12 +83,12 @@ subroutine sub2() ! CHECK: %[[VAL_2:.*]] = fir.emboxproc %[[VAL_1]] : ((!fir.ref) -> f32) -> !fir.boxproc<(!fir.ref) -> f32> ! CHECK: fir.store %[[VAL_2]] to %[[VAL_0]] : !fir.ref) -> f32>> ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFsub2Ep1"} : (!fir.ref) -> f32>>) -> (!fir.ref) -> f32>>, !fir.ref) -> f32>>) -! CHECK: %[[VAL_4:.*]] = fir.zero_bits () -> () -! CHECK: %[[VAL_5:.*]] = fir.emboxproc %[[VAL_4]] : (() -> ()) -> !fir.boxproc<() -> ()> -! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (!fir.boxproc<() -> ()>) -> !fir.boxproc<(!fir.ref) -> f32> -! CHECK: fir.store %[[VAL_6]] to %[[VAL_3]]#0 : !fir.ref) -> f32>> +! CHECK: %[[VAL_4:.*]] = fir.zero_bits (!fir.ref) -> f32 +! CHECK: %[[VAL_5:.*]] = fir.emboxproc %[[VAL_4]] : ((!fir.ref) -> f32) -> !fir.boxproc<(!fir.ref) -> f32> +! CHECK: fir.store %[[VAL_5]] to %[[VAL_3]]#0 : !fir.ref) -> f32>> end subroutine +! CHECK-LABEL: sub3 subroutine sub3() use m procedure(real_func), pointer :: p1 diff --git a/flang/test/Lower/OpenMP/parallel-private-clause.f90 b/flang/test/Lower/OpenMP/parallel-private-clause.f90 index 393443512c6eb..3a7fc22c0289b 100644 --- a/flang/test/Lower/OpenMP/parallel-private-clause.f90 +++ b/flang/test/Lower/OpenMP/parallel-private-clause.f90 @@ -231,14 +231,14 @@ end subroutine increment_list_items !FIRDialect-DAG: %[[Z1:.*]] = fir.alloca i32 {bindc_name = "z1", fir.target, uniq_name = "_QFparallel_pointerEz1"} !FIRDialect-DAG: %[[Z1_DECL:.*]]:2 = hlfir.declare %[[Z1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFparallel_pointerEz1"} : (!fir.ref) -> (!fir.ref, !fir.ref) !FIRDialect-DAG: %[[Z2:.*]] = fir.alloca !fir.array<10xi32> {bindc_name = "z2", fir.target, uniq_name = "_QFparallel_pointerEz2"} -!FIRDialect-DAG: %[[Z2_DECL:.*]]:2 = hlfir.declare %[[Z2]](%{{.*}}) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFparallel_pointerEz2"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) +!FIRDialect-DAG: %[[Z2_DECL:.*]]:2 = hlfir.declare %[[Z2]](%[[Z2_SHAPE:.*]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFparallel_pointerEz2"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) !FIRDialect: omp.parallel private(@{{.*}} %{{.*}}#0 -> %[[Y1_PVT:.*]], @{{.*}} %{{.*}}#0 -> %[[Y2_PVT:.*]] : {{.*}}) { !FIRDialect-DAG: %[[Y1_PVT_DECL:.*]]:2 = hlfir.declare %[[Y1_PVT]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFparallel_pointerEy1"} : (!fir.ref>>) -> (!fir.ref>>, !fir.ref>>) !FIRDialect-DAG: %[[Y2_PVT_DECL:.*]]:2 = hlfir.declare %[[Y2_PVT]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFparallel_pointerEy2"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) !FIRDialect-DAG: %[[PP18:.*]] = fir.embox %[[Z1_DECL]]#0 : (!fir.ref) -> !fir.box> !FIRDialect: fir.store %[[PP18]] to %[[Y1_PVT_DECL]]#0 : !fir.ref>> -!FIRDialect-DAG: %[[PP19:.*]] = fir.shape %c10 : (index) -> !fir.shape<1> -!FIRDialect-DAG: %[[PP20:.*]] = fir.embox %[[Z2_DECL]]#0(%[[PP19]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box>> +!FIRDialect: %[[Z2_CAST:.*]] = fir.convert %[[Z2_DECL]]#0 : (!fir.ref>) -> !fir.ref> +!FIRDialect-DAG: %[[PP20:.*]] = fir.embox %[[Z2_CAST]](%[[Z2_SHAPE]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box>> !FIRDialect: fir.store %[[PP20]] to %[[Y2_PVT_DECL]]#0 : !fir.ref>>> !FIRDialect: omp.terminator !FIRDialect: } diff --git a/flang/test/Lower/pointer-disassociate-character.f90 b/flang/test/Lower/pointer-disassociate-character.f90 new file mode 100644 index 0000000000000..5ee50fa821345 --- /dev/null +++ b/flang/test/Lower/pointer-disassociate-character.f90 @@ -0,0 +1,69 @@ +! Test character_pointer => NULL() +! The main point is to check that non deferred length parameter is preserved +! inside the descriptor, and that the length is otherwise set to zero. +! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s + +subroutine test_deferred(p) + character(:), pointer :: p + p => null() +end subroutine +subroutine test_cst(p) + character(10), pointer :: p + p => null() +end subroutine +subroutine test_explicit(p, n) + integer(8) :: n + character(n), pointer :: p + p => null() +end subroutine +subroutine test_assumed(p) + character(*), pointer :: p + p => null() +end subroutine +subroutine test_deferred_comp(p) + type t + character(:), pointer :: p + end type + type(t) :: x + x%p => null() +end subroutine +subroutine test_explicit_comp(p) + type t + character(10), pointer :: p + end type + type(t) :: x + x%p => null() +end subroutine + +! CHECK-LABEL: func.func @_QPtest_deferred( +! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr> +! CHECK: %[[CONSTANT_0:.*]] = arith.constant 0 : index +! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] typeparams %[[CONSTANT_0]] : (!fir.ptr>, index) -> !fir.box>> + +! CHECK-LABEL: func.func @_QPtest_cst( +! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr> +! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] : (!fir.ptr>) -> !fir.box>> + +! CHECK-LABEL: func.func @_QPtest_explicit( +! CHECK: %[[LOAD_0:.*]] = fir.load %{{.*}} : !fir.ref +! CHECK: %[[SELECT_0:.*]] = arith.select %{{.*}}, %[[LOAD_0]], %c0{{.*}} : i64 +! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr> +! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] typeparams %[[SELECT_0]] : (!fir.ptr>, i64) -> !fir.box>> + +! CHECK-LABEL: func.func @_QPtest_assumed( +! CHECK: %[[LOAD_0:.*]] = fir.load %[[ARG0:.*]] : !fir.ref>>> +! CHECK: %[[BOX_ELESIZE_0:.*]] = fir.box_elesize %[[LOAD_0]] : (!fir.box>>) -> index +! CHECK: %[[DECLARE_0:.*]]:2 = hlfir.declare %[[ARG0]] +! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr> +! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] typeparams %[[BOX_ELESIZE_0]] : (!fir.ptr>, index) -> !fir.box>> + +! CHECK-LABEL: func.func @_QPtest_deferred_comp( +! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr> +! CHECK: %[[CONSTANT_0:.*]] = arith.constant 0 : index +! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] typeparams %[[CONSTANT_0]] : (!fir.ptr>, index) -> !fir.box>> +! CHECK: fir.store %[[EMBOX_0]] to %{{.*}} : !fir.ref>>> + +! CHECK-LABEL: func.func @_QPtest_explicit_comp( +! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr> +! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] : (!fir.ptr>) -> !fir.box>> +! CHECK: fir.store %[[EMBOX_0]] to %{{.*}} : !fir.ref>>> diff --git a/flang/test/Lower/volatile3.f90 b/flang/test/Lower/volatile3.f90 index 9bee56e660531..d5eaa8ee8f752 100644 --- a/flang/test/Lower/volatile3.f90 +++ b/flang/test/Lower/volatile3.f90 @@ -69,199 +69,199 @@ subroutine sub_select_rank(arr) end subroutine end program - -! CHECK-LABEL: func.func @_QQmain() attributes {fir.bindc_name = "P"} { -! CHECK: %[[VAL_0:.*]] = arith.constant 1 : index -! CHECK: %[[VAL_1:.*]] = arith.constant 0 : index -! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index -! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box, volatile> -! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.box>, volatile> -! CHECK: %[[VAL_5:.*]] = fir.address_of(@_QFEnonvolatile_array) : !fir.ref> -! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1> -! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_5]](%[[VAL_6]]) {uniq_name = "_QFEnonvolatile_array"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) -! CHECK: %[[VAL_8:.*]] = fir.address_of(@_QFEnonvolatile_array_pointer) : !fir.ref>>> -! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_8]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEnonvolatile_array_pointer"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) -! CHECK: %[[VAL_10:.*]] = fir.address_of(@_QFEnonvolatile_array_target) : !fir.ref> -! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]](%[[VAL_6]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEnonvolatile_array_target"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) -! CHECK: %[[VAL_12:.*]] = fir.address_of(@_QFEnonvolatile_integer_target) : !fir.ref -! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_12]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEnonvolatile_integer_target"} : (!fir.ref) -> (!fir.ref, !fir.ref) -! CHECK: %[[VAL_14:.*]] = fir.address_of(@_QFEvolatile_array) : !fir.ref> -! CHECK: %[[VAL_15:.*]] = fir.volatile_cast %[[VAL_14]] : (!fir.ref>) -> !fir.ref, volatile> -! CHECK: %[[VAL_16:.*]]:2 = hlfir.declare %[[VAL_15]](%[[VAL_6]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_array"} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) -! CHECK: %[[VAL_17:.*]] = fir.address_of(@_QFEvolatile_array_2d) : !fir.ref> -! CHECK: %[[VAL_18:.*]] = fir.shape %[[VAL_2]], %[[VAL_2]] : (index, index) -> !fir.shape<2> -! CHECK: %[[VAL_19:.*]] = fir.volatile_cast %[[VAL_17]] : (!fir.ref>) -> !fir.ref, volatile> -! CHECK: %[[VAL_20:.*]]:2 = hlfir.declare %[[VAL_19]](%[[VAL_18]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_array_2d"} : (!fir.ref, volatile>, !fir.shape<2>) -> (!fir.ref, volatile>, !fir.ref, volatile>) -! CHECK: %[[VAL_21:.*]] = fir.address_of(@_QFEvolatile_array_pointer) : !fir.ref>>> -! CHECK: %[[VAL_22:.*]] = fir.volatile_cast %[[VAL_21]] : (!fir.ref>>>) -> !fir.ref>, volatile>, volatile> -! CHECK: %[[VAL_23:.*]]:2 = hlfir.declare %[[VAL_22]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_array_pointer"} : (!fir.ref>, volatile>, volatile>) -> (!fir.ref>, volatile>, volatile>, !fir.ref>, volatile>, volatile>) -! CHECK: %[[VAL_24:.*]] = fir.address_of(@_QFEvolatile_array_target) : !fir.ref> -! CHECK: %[[VAL_25:.*]] = fir.volatile_cast %[[VAL_24]] : (!fir.ref>) -> !fir.ref, volatile> -! CHECK: %[[VAL_26:.*]]:2 = hlfir.declare %[[VAL_25]](%[[VAL_6]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_array_target"} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) -! CHECK: %[[VAL_27:.*]] = fir.alloca i32 {bindc_name = "volatile_integer", uniq_name = "_QFEvolatile_integer"} -! CHECK: %[[VAL_28:.*]] = fir.volatile_cast %[[VAL_27]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_29:.*]]:2 = hlfir.declare %[[VAL_28]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_integer"} : (!fir.ref) -> (!fir.ref, !fir.ref) -! CHECK: %[[VAL_30:.*]] = fir.alloca !fir.box> {bindc_name = "volatile_integer_pointer", uniq_name = "_QFEvolatile_integer_pointer"} -! CHECK: %[[VAL_31:.*]] = fir.zero_bits !fir.ptr -! CHECK: %[[VAL_32:.*]] = fir.embox %[[VAL_31]] : (!fir.ptr) -> !fir.box> -! CHECK: fir.store %[[VAL_32]] to %[[VAL_30]] : !fir.ref>> -! CHECK: %[[VAL_33:.*]] = fir.volatile_cast %[[VAL_30]] : (!fir.ref>>) -> !fir.ref, volatile>, volatile> -! CHECK: %[[VAL_34:.*]]:2 = hlfir.declare %[[VAL_33]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_integer_pointer"} : (!fir.ref, volatile>, volatile>) -> (!fir.ref, volatile>, volatile>, !fir.ref, volatile>, volatile>) -! CHECK: %[[VAL_35:.*]] = fir.address_of(@_QFEvolatile_integer_target) : !fir.ref -! CHECK: %[[VAL_36:.*]] = fir.volatile_cast %[[VAL_35]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_37:.*]]:2 = hlfir.declare %[[VAL_36]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_integer_target"} : (!fir.ref) -> (!fir.ref, !fir.ref) -! CHECK: %[[VAL_38:.*]] = fir.embox %[[VAL_26]]#0(%[[VAL_6]]) : (!fir.ref, volatile>, !fir.shape<1>) -> !fir.box>, volatile> -! CHECK: fir.store %[[VAL_38]] to %[[VAL_23]]#0 : !fir.ref>, volatile>, volatile> -! CHECK: %[[VAL_39:.*]] = fir.embox %[[VAL_11]]#0(%[[VAL_6]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box>> -! CHECK: %[[VAL_40:.*]] = fir.volatile_cast %[[VAL_39]] : (!fir.box>>) -> !fir.box>, volatile> -! CHECK: fir.store %[[VAL_40]] to %[[VAL_23]]#0 : !fir.ref>, volatile>, volatile> -! CHECK: %[[VAL_41:.*]] = fir.zero_bits !fir.ptr> -! CHECK: %[[VAL_42:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1> -! CHECK: %[[VAL_43:.*]] = fir.embox %[[VAL_41]](%[[VAL_42]]) : (!fir.ptr>, !fir.shape<1>) -> !fir.box>, volatile> -! CHECK: fir.store %[[VAL_43]] to %[[VAL_4]] : !fir.ref>, volatile>> -! CHECK: %[[VAL_44:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = ".tmp.intrinsic_result"} : (!fir.ref>, volatile>>) -> (!fir.ref>, volatile>>, !fir.ref>, volatile>>) -! CHECK: %[[VAL_45:.*]] = fir.load %[[VAL_44]]#0 : !fir.ref>, volatile>> -! CHECK: %[[VAL_46:.*]]:3 = fir.box_dims %[[VAL_45]], %[[VAL_1]] : (!fir.box>, volatile>, index) -> (index, index, index) -! CHECK: %[[VAL_47:.*]] = fir.shift %[[VAL_46]]#0 : (index) -> !fir.shift<1> -! CHECK: %[[VAL_48:.*]] = fir.rebox %[[VAL_45]](%[[VAL_47]]) : (!fir.box>, volatile>, !fir.shift<1>) -> !fir.box>, volatile> -! CHECK: fir.store %[[VAL_48]] to %[[VAL_23]]#0 : !fir.ref>, volatile>, volatile> -! CHECK: %[[VAL_49:.*]] = fir.volatile_cast %[[VAL_38]] : (!fir.box>, volatile>) -> !fir.box>> -! CHECK: fir.store %[[VAL_49]] to %[[VAL_9]]#0 : !fir.ref>>> -! CHECK: fir.store %[[VAL_39]] to %[[VAL_9]]#0 : !fir.ref>>> -! CHECK: %[[VAL_50:.*]] = fir.embox %[[VAL_37]]#0 : (!fir.ref) -> !fir.box, volatile> -! CHECK: fir.store %[[VAL_50]] to %[[VAL_34]]#0 : !fir.ref, volatile>, volatile> -! CHECK: %[[VAL_51:.*]] = fir.embox %[[VAL_31]] : (!fir.ptr) -> !fir.box, volatile> -! CHECK: fir.store %[[VAL_51]] to %[[VAL_3]] : !fir.ref, volatile>> -! CHECK: %[[VAL_52:.*]]:2 = hlfir.declare %[[VAL_3]] {uniq_name = ".tmp.intrinsic_result"} : (!fir.ref, volatile>>) -> (!fir.ref, volatile>>, !fir.ref, volatile>>) -! CHECK: %[[VAL_53:.*]] = fir.load %[[VAL_52]]#0 : !fir.ref, volatile>> -! CHECK: %[[VAL_54:.*]] = fir.box_addr %[[VAL_53]] : (!fir.box, volatile>) -> !fir.ptr -! CHECK: %[[VAL_55:.*]] = fir.embox %[[VAL_54]] : (!fir.ptr) -> !fir.box> -! CHECK: %[[VAL_56:.*]] = fir.volatile_cast %[[VAL_55]] : (!fir.box>) -> !fir.box, volatile> -! CHECK: fir.store %[[VAL_56]] to %[[VAL_34]]#0 : !fir.ref, volatile>, volatile> -! CHECK: %[[VAL_57:.*]] = fir.volatile_cast %[[VAL_16]]#0 : (!fir.ref, volatile>) -> !fir.ref> -! CHECK: fir.call @_QFPsub_nonvolatile_array(%[[VAL_57]]) fastmath : (!fir.ref>) -> () -! CHECK: %[[VAL_58:.*]] = fir.embox %[[VAL_16]]#0(%[[VAL_6]]) : (!fir.ref, volatile>, !fir.shape<1>) -> !fir.box, volatile> -! CHECK: %[[VAL_59:.*]] = fir.volatile_cast %[[VAL_58]] : (!fir.box, volatile>) -> !fir.box> -! CHECK: %[[VAL_60:.*]] = fir.convert %[[VAL_59]] : (!fir.box>) -> !fir.box> -! CHECK: fir.call @_QFPsub_volatile_array_assumed_shape(%[[VAL_60]]) fastmath : (!fir.box>) -> () -! CHECK: fir.call @_QFPsub_volatile_array(%[[VAL_57]]) fastmath : (!fir.ref>) -> () -! CHECK: %[[VAL_61:.*]] = fir.embox %[[VAL_7]]#0(%[[VAL_6]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box> -! CHECK: %[[VAL_62:.*]] = fir.convert %[[VAL_61]] : (!fir.box>) -> !fir.box> -! CHECK: fir.call @_QFPsub_volatile_array_assumed_shape(%[[VAL_62]]) fastmath : (!fir.box>) -> () -! CHECK: fir.call @_QFPsub_volatile_array(%[[VAL_7]]#0) fastmath : (!fir.ref>) -> () -! CHECK: %[[VAL_63:.*]] = fir.convert %[[VAL_23]]#0 : (!fir.ref>, volatile>, volatile>) -> !fir.ref>>, volatile> -! CHECK: fir.call @_QFPsub_volatile_array_pointer(%[[VAL_63]]) fastmath : (!fir.ref>>, volatile>) -> () -! CHECK: %[[VAL_64:.*]] = fir.volatile_cast %[[VAL_9]]#0 : (!fir.ref>>>) -> !fir.ref>>, volatile> -! CHECK: fir.call @_QFPsub_volatile_array_pointer(%[[VAL_64]]) fastmath : (!fir.ref>>, volatile>) -> () -! CHECK: %[[VAL_65:.*]] = hlfir.designate %[[VAL_16]]#0 (%[[VAL_0]]:%[[VAL_2]]:%[[VAL_0]]) shape %[[VAL_6]] : (!fir.ref, volatile>, index, index, index, !fir.shape<1>) -> !fir.ref, volatile> -! CHECK: %[[VAL_66:.*]] = fir.embox %[[VAL_65]](%[[VAL_6]]) : (!fir.ref, volatile>, !fir.shape<1>) -> !fir.box, volatile> -! CHECK: %[[VAL_67:.*]] = fir.volatile_cast %[[VAL_66]] : (!fir.box, volatile>) -> !fir.box> -! CHECK: %[[VAL_68:.*]] = fir.convert %[[VAL_67]] : (!fir.box>) -> !fir.box> -! CHECK: fir.call @_QFPsub_volatile_array_assumed_shape(%[[VAL_68]]) fastmath : (!fir.box>) -> () -! CHECK: %[[VAL_69:.*]] = hlfir.designate %[[VAL_20]]#0 (%[[VAL_0]]:%[[VAL_2]]:%[[VAL_0]], %[[VAL_0]]:%[[VAL_2]]:%[[VAL_0]]) shape %[[VAL_18]] : (!fir.ref, volatile>, index, index, index, index, index, index, !fir.shape<2>) -> !fir.box, volatile> -! CHECK: %[[VAL_70:.*]] = fir.volatile_cast %[[VAL_69]] : (!fir.box, volatile>) -> !fir.box> -! CHECK: %[[VAL_71:.*]] = fir.convert %[[VAL_70]] : (!fir.box>) -> !fir.box> -! CHECK: fir.call @_QFPsub_volatile_array_assumed_shape_2d(%[[VAL_71]]) fastmath : (!fir.box>) -> () -! CHECK: %[[VAL_72:.*]] = fir.convert %[[VAL_59]] : (!fir.box>) -> !fir.box> -! CHECK: fir.call @_QFPsub_select_rank(%[[VAL_72]]) fastmath : (!fir.box>) -> () -! CHECK: %[[VAL_73:.*]] = fir.embox %[[VAL_20]]#0(%[[VAL_18]]) : (!fir.ref, volatile>, !fir.shape<2>) -> !fir.box, volatile> -! CHECK: %[[VAL_74:.*]] = fir.volatile_cast %[[VAL_73]] : (!fir.box, volatile>) -> !fir.box> -! CHECK: %[[VAL_75:.*]] = fir.convert %[[VAL_74]] : (!fir.box>) -> !fir.box> -! CHECK: fir.call @_QFPsub_select_rank(%[[VAL_75]]) fastmath : (!fir.box>) -> () +! CHECK-LABEL: func.func @_QQmain() {{.*}} { +! CHECK: %[[CONSTANT_0:.*]] = arith.constant 1 : index +! CHECK: %[[CONSTANT_1:.*]] = arith.constant 0 : index +! CHECK: %[[CONSTANT_2:.*]] = arith.constant 10 : index +! CHECK: %[[ALLOCA_0:.*]] = fir.alloca !fir.box, volatile> +! CHECK: %[[ALLOCA_1:.*]] = fir.alloca !fir.box>, volatile> +! CHECK: %[[DUMMY_SCOPE_0:.*]] = fir.dummy_scope : !fir.dscope +! CHECK: %[[ADDRESS_OF_0:.*]] = fir.address_of(@_QFEnonvolatile_array) : !fir.ref> +! CHECK: %[[SHAPE_0:.*]] = fir.shape %[[CONSTANT_2]] : (index) -> !fir.shape<1> +! CHECK: %[[DECLARE_0:.*]]:2 = hlfir.declare %[[ADDRESS_OF_0]](%[[SHAPE_0]]) {uniq_name = "_QFEnonvolatile_array"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) +! CHECK: %[[ADDRESS_OF_1:.*]] = fir.address_of(@_QFEnonvolatile_array_pointer) : !fir.ref>>> +! CHECK: %[[DECLARE_1:.*]]:2 = hlfir.declare %[[ADDRESS_OF_1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEnonvolatile_array_pointer"} : (!fir.ref>>>) -> (!fir.ref>>>, !fir.ref>>>) +! CHECK: %[[ADDRESS_OF_2:.*]] = fir.address_of(@_QFEnonvolatile_array_target) : !fir.ref> +! CHECK: %[[DECLARE_2:.*]]:2 = hlfir.declare %[[ADDRESS_OF_2]](%[[SHAPE_0]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEnonvolatile_array_target"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) +! CHECK: %[[ADDRESS_OF_3:.*]] = fir.address_of(@_QFEnonvolatile_integer_target) : !fir.ref +! CHECK: %[[DECLARE_3:.*]]:2 = hlfir.declare %[[ADDRESS_OF_3]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEnonvolatile_integer_target"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[ADDRESS_OF_4:.*]] = fir.address_of(@_QFEvolatile_array) : !fir.ref> +! CHECK: %[[VOLATILE_CAST_0:.*]] = fir.volatile_cast %[[ADDRESS_OF_4]] : (!fir.ref>) -> !fir.ref, volatile> +! CHECK: %[[DECLARE_4:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_0]](%[[SHAPE_0]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_array"} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) +! CHECK: %[[ADDRESS_OF_5:.*]] = fir.address_of(@_QFEvolatile_array_2d) : !fir.ref> +! CHECK: %[[SHAPE_1:.*]] = fir.shape %[[CONSTANT_2]], %[[CONSTANT_2]] : (index, index) -> !fir.shape<2> +! CHECK: %[[VOLATILE_CAST_1:.*]] = fir.volatile_cast %[[ADDRESS_OF_5]] : (!fir.ref>) -> !fir.ref, volatile> +! CHECK: %[[DECLARE_5:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_1]](%[[SHAPE_1]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_array_2d"} : (!fir.ref, volatile>, !fir.shape<2>) -> (!fir.ref, volatile>, !fir.ref, volatile>) +! CHECK: %[[ADDRESS_OF_6:.*]] = fir.address_of(@_QFEvolatile_array_pointer) : !fir.ref>>> +! CHECK: %[[VOLATILE_CAST_2:.*]] = fir.volatile_cast %[[ADDRESS_OF_6]] : (!fir.ref>>>) -> !fir.ref>, volatile>, volatile> +! CHECK: %[[DECLARE_6:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_2]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_array_pointer"} : (!fir.ref>, volatile>, volatile>) -> (!fir.ref>, volatile>, volatile>, !fir.ref>, volatile>, volatile>) +! CHECK: %[[ADDRESS_OF_7:.*]] = fir.address_of(@_QFEvolatile_array_target) : !fir.ref> +! CHECK: %[[VOLATILE_CAST_3:.*]] = fir.volatile_cast %[[ADDRESS_OF_7]] : (!fir.ref>) -> !fir.ref, volatile> +! CHECK: %[[DECLARE_7:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_3]](%[[SHAPE_0]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_array_target"} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) +! CHECK: %[[ALLOCA_2:.*]] = fir.alloca i32 {bindc_name = "volatile_integer", uniq_name = "_QFEvolatile_integer"} +! CHECK: %[[VOLATILE_CAST_4:.*]] = fir.volatile_cast %[[ALLOCA_2]] : (!fir.ref) -> !fir.ref +! CHECK: %[[DECLARE_8:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_4]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_integer"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[ALLOCA_3:.*]] = fir.alloca !fir.box> {bindc_name = "volatile_integer_pointer", uniq_name = "_QFEvolatile_integer_pointer"} +! CHECK: %[[ZERO_BITS_0:.*]] = fir.zero_bits !fir.ptr +! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[ZERO_BITS_0]] : (!fir.ptr) -> !fir.box> +! CHECK: fir.store %[[EMBOX_0]] to %[[ALLOCA_3]] : !fir.ref>> +! CHECK: %[[VOLATILE_CAST_5:.*]] = fir.volatile_cast %[[ALLOCA_3]] : (!fir.ref>>) -> !fir.ref, volatile>, volatile> +! CHECK: %[[DECLARE_9:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_5]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_integer_pointer"} : (!fir.ref, volatile>, volatile>) -> (!fir.ref, volatile>, volatile>, !fir.ref, volatile>, volatile>) +! CHECK: %[[ADDRESS_OF_8:.*]] = fir.address_of(@_QFEvolatile_integer_target) : !fir.ref +! CHECK: %[[VOLATILE_CAST_6:.*]] = fir.volatile_cast %[[ADDRESS_OF_8]] : (!fir.ref) -> !fir.ref +! CHECK: %[[DECLARE_10:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_6]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEvolatile_integer_target"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[CONVERT_0:.*]] = fir.convert %[[DECLARE_7]]#0 : (!fir.ref, volatile>) -> !fir.ref, volatile> +! CHECK: %[[EMBOX_1:.*]] = fir.embox %[[CONVERT_0]](%[[SHAPE_0]]) : (!fir.ref, volatile>, !fir.shape<1>) -> !fir.box>, volatile> +! CHECK: fir.store %[[EMBOX_1]] to %[[DECLARE_6]]#0 : !fir.ref>, volatile>, volatile> +! CHECK: %[[VOLATILE_CAST_7:.*]] = fir.volatile_cast %[[DECLARE_2]]#0 : (!fir.ref>) -> !fir.ref, volatile> +! CHECK: %[[CONVERT_1:.*]] = fir.convert %[[VOLATILE_CAST_7]] : (!fir.ref, volatile>) -> !fir.ref, volatile> +! CHECK: %[[EMBOX_2:.*]] = fir.embox %[[CONVERT_1]](%[[SHAPE_0]]) : (!fir.ref, volatile>, !fir.shape<1>) -> !fir.box>, volatile> +! CHECK: fir.store %[[EMBOX_2]] to %[[DECLARE_6]]#0 : !fir.ref>, volatile>, volatile> +! CHECK: %[[ZERO_BITS_1:.*]] = fir.zero_bits !fir.ptr> +! CHECK: %[[SHAPE_2:.*]] = fir.shape %[[CONSTANT_1]] : (index) -> !fir.shape<1> +! CHECK: %[[EMBOX_3:.*]] = fir.embox %[[ZERO_BITS_1]](%[[SHAPE_2]]) : (!fir.ptr>, !fir.shape<1>) -> !fir.box>, volatile> +! CHECK: fir.store %[[EMBOX_3]] to %[[ALLOCA_1]] : !fir.ref>, volatile>> +! CHECK: %[[DECLARE_11:.*]]:2 = hlfir.declare %[[ALLOCA_1]] {uniq_name = ".tmp.intrinsic_result"} : (!fir.ref>, volatile>>) -> (!fir.ref>, volatile>>, !fir.ref>, volatile>>) +! CHECK: %[[LOAD_0:.*]] = fir.load %[[DECLARE_11]]#0 : !fir.ref>, volatile>> +! CHECK: fir.store %[[LOAD_0]] to %[[DECLARE_6]]#0 : !fir.ref>, volatile>, volatile> +! CHECK: %[[VOLATILE_CAST_8:.*]] = fir.volatile_cast %[[DECLARE_7]]#0 : (!fir.ref, volatile>) -> !fir.ref> +! CHECK: %[[CONVERT_2:.*]] = fir.convert %[[VOLATILE_CAST_8]] : (!fir.ref>) -> !fir.ref> +! CHECK: %[[EMBOX_4:.*]] = fir.embox %[[CONVERT_2]](%[[SHAPE_0]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box>> +! CHECK: fir.store %[[EMBOX_4]] to %[[DECLARE_1]]#0 : !fir.ref>>> +! CHECK: %[[CONVERT_3:.*]] = fir.convert %[[DECLARE_2]]#0 : (!fir.ref>) -> !fir.ref> +! CHECK: %[[EMBOX_5:.*]] = fir.embox %[[CONVERT_3]](%[[SHAPE_0]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box>> +! CHECK: fir.store %[[EMBOX_5]] to %[[DECLARE_1]]#0 : !fir.ref>>> +! CHECK: %[[EMBOX_6:.*]] = fir.embox %[[DECLARE_10]]#0 : (!fir.ref) -> !fir.box, volatile> +! CHECK: fir.store %[[EMBOX_6]] to %[[DECLARE_9]]#0 : !fir.ref, volatile>, volatile> +! CHECK: %[[EMBOX_7:.*]] = fir.embox %[[ZERO_BITS_0]] : (!fir.ptr) -> !fir.box, volatile> +! CHECK: fir.store %[[EMBOX_7]] to %[[ALLOCA_0]] : !fir.ref, volatile>> +! CHECK: %[[DECLARE_12:.*]]:2 = hlfir.declare %[[ALLOCA_0]] {uniq_name = ".tmp.intrinsic_result"} : (!fir.ref, volatile>>) -> (!fir.ref, volatile>>, !fir.ref, volatile>>) +! CHECK: %[[LOAD_1:.*]] = fir.load %[[DECLARE_12]]#0 : !fir.ref, volatile>> +! CHECK: fir.store %[[LOAD_1]] to %[[DECLARE_9]]#0 : !fir.ref, volatile>, volatile> +! CHECK: %[[VOLATILE_CAST_9:.*]] = fir.volatile_cast %[[DECLARE_4]]#0 : (!fir.ref, volatile>) -> !fir.ref> +! CHECK: fir.call @_QFPsub_nonvolatile_array(%[[VOLATILE_CAST_9]]) fastmath : (!fir.ref>) -> () +! CHECK: %[[EMBOX_8:.*]] = fir.embox %[[DECLARE_4]]#0(%[[SHAPE_0]]) : (!fir.ref, volatile>, !fir.shape<1>) -> !fir.box, volatile> +! CHECK: %[[VOLATILE_CAST_10:.*]] = fir.volatile_cast %[[EMBOX_8]] : (!fir.box, volatile>) -> !fir.box> +! CHECK: %[[CONVERT_4:.*]] = fir.convert %[[VOLATILE_CAST_10]] : (!fir.box>) -> !fir.box> +! CHECK: fir.call @_QFPsub_volatile_array_assumed_shape(%[[CONVERT_4]]) fastmath : (!fir.box>) -> () +! CHECK: fir.call @_QFPsub_volatile_array(%[[VOLATILE_CAST_9]]) fastmath : (!fir.ref>) -> () +! CHECK: %[[EMBOX_9:.*]] = fir.embox %[[DECLARE_0]]#0(%[[SHAPE_0]]) : (!fir.ref>, !fir.shape<1>) -> !fir.box> +! CHECK: %[[CONVERT_5:.*]] = fir.convert %[[EMBOX_9]] : (!fir.box>) -> !fir.box> +! CHECK: fir.call @_QFPsub_volatile_array_assumed_shape(%[[CONVERT_5]]) fastmath : (!fir.box>) -> () +! CHECK: fir.call @_QFPsub_volatile_array(%[[DECLARE_0]]#0) fastmath : (!fir.ref>) -> () +! CHECK: %[[CONVERT_6:.*]] = fir.convert %[[DECLARE_6]]#0 : (!fir.ref>, volatile>, volatile>) -> !fir.ref>>, volatile> +! CHECK: fir.call @_QFPsub_volatile_array_pointer(%[[CONVERT_6]]) fastmath : (!fir.ref>>, volatile>) -> () +! CHECK: %[[VOLATILE_CAST_11:.*]] = fir.volatile_cast %[[DECLARE_1]]#0 : (!fir.ref>>>) -> !fir.ref>>, volatile> +! CHECK: fir.call @_QFPsub_volatile_array_pointer(%[[VOLATILE_CAST_11]]) fastmath : (!fir.ref>>, volatile>) -> () +! CHECK: %[[DESIGNATE_0:.*]] = hlfir.designate %[[DECLARE_4]]#0 (%[[CONSTANT_0]]:%[[CONSTANT_2]]:%[[CONSTANT_0]]) shape %[[SHAPE_0]] : (!fir.ref, volatile>, index, index, index, !fir.shape<1>) -> !fir.ref, volatile> +! CHECK: %[[EMBOX_10:.*]] = fir.embox %[[DESIGNATE_0]](%[[SHAPE_0]]) : (!fir.ref, volatile>, !fir.shape<1>) -> !fir.box, volatile> +! CHECK: %[[VOLATILE_CAST_12:.*]] = fir.volatile_cast %[[EMBOX_10]] : (!fir.box, volatile>) -> !fir.box> +! CHECK: %[[CONVERT_7:.*]] = fir.convert %[[VOLATILE_CAST_12]] : (!fir.box>) -> !fir.box> +! CHECK: fir.call @_QFPsub_volatile_array_assumed_shape(%[[CONVERT_7]]) fastmath : (!fir.box>) -> () +! CHECK: %[[DESIGNATE_1:.*]] = hlfir.designate %[[DECLARE_5]]#0 (%[[CONSTANT_0]]:%[[CONSTANT_2]]:%[[CONSTANT_0]], %[[CONSTANT_0]]:%[[CONSTANT_2]]:%[[CONSTANT_0]]) shape %[[SHAPE_1]] : (!fir.ref, volatile>, index, index, index, index, index, index, !fir.shape<2>) -> !fir.box, volatile> +! CHECK: %[[VOLATILE_CAST_13:.*]] = fir.volatile_cast %[[DESIGNATE_1]] : (!fir.box, volatile>) -> !fir.box> +! CHECK: %[[CONVERT_8:.*]] = fir.convert %[[VOLATILE_CAST_13]] : (!fir.box>) -> !fir.box> +! CHECK: fir.call @_QFPsub_volatile_array_assumed_shape_2d(%[[CONVERT_8]]) fastmath : (!fir.box>) -> () +! CHECK: %[[CONVERT_9:.*]] = fir.convert %[[VOLATILE_CAST_10]] : (!fir.box>) -> !fir.box> +! CHECK: fir.call @_QFPsub_select_rank(%[[CONVERT_9]]) fastmath : (!fir.box>) -> () +! CHECK: %[[EMBOX_11:.*]] = fir.embox %[[DECLARE_5]]#0(%[[SHAPE_1]]) : (!fir.ref, volatile>, !fir.shape<2>) -> !fir.box, volatile> +! CHECK: %[[VOLATILE_CAST_14:.*]] = fir.volatile_cast %[[EMBOX_11]] : (!fir.box, volatile>) -> !fir.box> +! CHECK: %[[CONVERT_10:.*]] = fir.convert %[[VOLATILE_CAST_14]] : (!fir.box>) -> !fir.box> +! CHECK: fir.call @_QFPsub_select_rank(%[[CONVERT_10]]) fastmath : (!fir.box>) -> () ! CHECK: return ! CHECK: } ! CHECK-LABEL: func.func private @_QFPsub_nonvolatile_array( -! CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.ref> {fir.bindc_name = "arr"}) attributes {fir.host_symbol = @_QQmain, llvm.linkage = #llvm.linkage} { -! CHECK: %[[VAL_1:.*]] = arith.constant 1 : index -! CHECK: %[[VAL_2:.*]] = arith.constant 5 : i32 -! CHECK: %[[VAL_3:.*]] = arith.constant 10 : index -! CHECK: %[[VAL_4:.*]] = fir.dummy_scope : !fir.dscope -! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1> -! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_0]](%[[VAL_5]]) dummy_scope %[[VAL_4]] arg {{[0-9]+}} {uniq_name = "_QFFsub_nonvolatile_arrayEarr"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> (!fir.ref>, !fir.ref>) -! CHECK: %[[VAL_7:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_1]]) : (!fir.ref>, index) -> !fir.ref -! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_7]] : i32, !fir.ref +! CHECK-SAME: %[[ARG0:.*]]: !fir.ref> {fir.bindc_name = "arr"}) {{.*}} { +! CHECK: %[[CONSTANT_0:.*]] = arith.constant 1 : index +! CHECK: %[[CONSTANT_1:.*]] = arith.constant 5 : i32 +! CHECK: %[[CONSTANT_2:.*]] = arith.constant 10 : index +! CHECK: %[[DUMMY_SCOPE_0:.*]] = fir.dummy_scope : !fir.dscope +! CHECK: %[[SHAPE_0:.*]] = fir.shape %[[CONSTANT_2]] : (index) -> !fir.shape<1> +! CHECK: %[[DECLARE_0:.*]]:2 = hlfir.declare %[[ARG0]](%[[SHAPE_0]]) dummy_scope %[[DUMMY_SCOPE_0]] arg 1 {uniq_name = "_QFFsub_nonvolatile_arrayEarr"} : (!fir.ref>, !fir.shape<1>, !fir.dscope) -> (!fir.ref>, !fir.ref>) +! CHECK: %[[DESIGNATE_0:.*]] = hlfir.designate %[[DECLARE_0]]#0 (%[[CONSTANT_0]]) : (!fir.ref>, index) -> !fir.ref +! CHECK: hlfir.assign %[[CONSTANT_1]] to %[[DESIGNATE_0]] : i32, !fir.ref ! CHECK: return ! CHECK: } ! CHECK-LABEL: func.func private @_QFPsub_volatile_array_assumed_shape( -! CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box> {fir.bindc_name = "arr"}) attributes {fir.host_symbol = @_QQmain, llvm.linkage = #llvm.linkage} { -! CHECK: %[[VAL_1:.*]] = arith.constant 1 : index -! CHECK: %[[VAL_2:.*]] = arith.constant 5 : i32 -! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope -! CHECK: %[[VAL_4:.*]] = fir.volatile_cast %[[VAL_0]] : (!fir.box>) -> !fir.box, volatile> -! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] dummy_scope %[[VAL_3]] arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_volatile_array_assumed_shapeEarr"} : (!fir.box, volatile>, !fir.dscope) -> (!fir.box, volatile>, !fir.box, volatile>) -! CHECK: %[[VAL_6:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_1]]) : (!fir.box, volatile>, index) -> !fir.ref -! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_6]] : i32, !fir.ref +! CHECK-SAME: %[[ARG0:.*]]: !fir.box> {fir.bindc_name = "arr"}) {{.*}} { +! CHECK: %[[CONSTANT_0:.*]] = arith.constant 1 : index +! CHECK: %[[CONSTANT_1:.*]] = arith.constant 5 : i32 +! CHECK: %[[DUMMY_SCOPE_0:.*]] = fir.dummy_scope : !fir.dscope +! CHECK: %[[VOLATILE_CAST_0:.*]] = fir.volatile_cast %[[ARG0]] : (!fir.box>) -> !fir.box, volatile> +! CHECK: %[[DECLARE_0:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_0]] dummy_scope %[[DUMMY_SCOPE_0]] arg 1 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_volatile_array_assumed_shapeEarr"} : (!fir.box, volatile>, !fir.dscope) -> (!fir.box, volatile>, !fir.box, volatile>) +! CHECK: %[[DESIGNATE_0:.*]] = hlfir.designate %[[DECLARE_0]]#0 (%[[CONSTANT_0]]) : (!fir.box, volatile>, index) -> !fir.ref +! CHECK: hlfir.assign %[[CONSTANT_1]] to %[[DESIGNATE_0]] : i32, !fir.ref ! CHECK: return ! CHECK: } ! CHECK-LABEL: func.func private @_QFPsub_volatile_array_assumed_shape_2d( -! CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box> {fir.bindc_name = "arr"}) attributes {fir.host_symbol = @_QQmain, llvm.linkage = #llvm.linkage} { -! CHECK: %[[VAL_1:.*]] = arith.constant 1 : index -! CHECK: %[[VAL_2:.*]] = arith.constant 5 : i32 -! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope -! CHECK: %[[VAL_4:.*]] = fir.volatile_cast %[[VAL_0]] : (!fir.box>) -> !fir.box, volatile> -! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] dummy_scope %[[VAL_3]] arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_volatile_array_assumed_shape_2dEarr"} : (!fir.box, volatile>, !fir.dscope) -> (!fir.box, volatile>, !fir.box, volatile>) -! CHECK: %[[VAL_6:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_1]], %[[VAL_1]]) : (!fir.box, volatile>, index, index) -> !fir.ref -! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_6]] : i32, !fir.ref +! CHECK-SAME: %[[ARG0:.*]]: !fir.box> {fir.bindc_name = "arr"}) {{.*}} { +! CHECK: %[[CONSTANT_0:.*]] = arith.constant 1 : index +! CHECK: %[[CONSTANT_1:.*]] = arith.constant 5 : i32 +! CHECK: %[[DUMMY_SCOPE_0:.*]] = fir.dummy_scope : !fir.dscope +! CHECK: %[[VOLATILE_CAST_0:.*]] = fir.volatile_cast %[[ARG0]] : (!fir.box>) -> !fir.box, volatile> +! CHECK: %[[DECLARE_0:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_0]] dummy_scope %[[DUMMY_SCOPE_0]] arg 1 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_volatile_array_assumed_shape_2dEarr"} : (!fir.box, volatile>, !fir.dscope) -> (!fir.box, volatile>, !fir.box, volatile>) +! CHECK: %[[DESIGNATE_0:.*]] = hlfir.designate %[[DECLARE_0]]#0 (%[[CONSTANT_0]], %[[CONSTANT_0]]) : (!fir.box, volatile>, index, index) -> !fir.ref +! CHECK: hlfir.assign %[[CONSTANT_1]] to %[[DESIGNATE_0]] : i32, !fir.ref ! CHECK: return ! CHECK: } ! CHECK-LABEL: func.func private @_QFPsub_volatile_array( -! CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.ref> {fir.bindc_name = "arr"}) attributes {fir.host_symbol = @_QQmain, llvm.linkage = #llvm.linkage} { -! CHECK: %[[VAL_1:.*]] = arith.constant 1 : index -! CHECK: %[[VAL_2:.*]] = arith.constant 5 : i32 -! CHECK: %[[VAL_3:.*]] = arith.constant 10 : index -! CHECK: %[[VAL_4:.*]] = fir.dummy_scope : !fir.dscope -! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1> -! CHECK: %[[VAL_6:.*]] = fir.volatile_cast %[[VAL_0]] : (!fir.ref>) -> !fir.ref, volatile> -! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]](%[[VAL_5]]) dummy_scope %[[VAL_4]] arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_volatile_arrayEarr"} : (!fir.ref, volatile>, !fir.shape<1>, !fir.dscope) -> (!fir.ref, volatile>, !fir.ref, volatile>) -! CHECK: %[[VAL_8:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[VAL_1]]) : (!fir.ref, volatile>, index) -> !fir.ref -! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_8]] : i32, !fir.ref +! CHECK-SAME: %[[ARG0:.*]]: !fir.ref> {fir.bindc_name = "arr"}) {{.*}} { +! CHECK: %[[CONSTANT_0:.*]] = arith.constant 1 : index +! CHECK: %[[CONSTANT_1:.*]] = arith.constant 5 : i32 +! CHECK: %[[CONSTANT_2:.*]] = arith.constant 10 : index +! CHECK: %[[DUMMY_SCOPE_0:.*]] = fir.dummy_scope : !fir.dscope +! CHECK: %[[SHAPE_0:.*]] = fir.shape %[[CONSTANT_2]] : (index) -> !fir.shape<1> +! CHECK: %[[VOLATILE_CAST_0:.*]] = fir.volatile_cast %[[ARG0]] : (!fir.ref>) -> !fir.ref, volatile> +! CHECK: %[[DECLARE_0:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_0]](%[[SHAPE_0]]) dummy_scope %[[DUMMY_SCOPE_0]] arg 1 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_volatile_arrayEarr"} : (!fir.ref, volatile>, !fir.shape<1>, !fir.dscope) -> (!fir.ref, volatile>, !fir.ref, volatile>) +! CHECK: %[[DESIGNATE_0:.*]] = hlfir.designate %[[DECLARE_0]]#0 (%[[CONSTANT_0]]) : (!fir.ref, volatile>, index) -> !fir.ref +! CHECK: hlfir.assign %[[CONSTANT_1]] to %[[DESIGNATE_0]] : i32, !fir.ref ! CHECK: return ! CHECK: } ! CHECK-LABEL: func.func private @_QFPsub_volatile_array_pointer( -! CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.ref>>, volatile> {fir.bindc_name = "arr"}) attributes {fir.host_symbol = @_QQmain, llvm.linkage = #llvm.linkage} { -! CHECK: %[[VAL_1:.*]] = arith.constant 1 : index -! CHECK: %[[VAL_2:.*]] = arith.constant 5 : i32 -! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope -! CHECK: %[[VAL_4:.*]] = fir.volatile_cast %[[VAL_0]] : (!fir.ref>>, volatile>) -> !fir.ref>, volatile>, volatile> -! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] dummy_scope %[[VAL_3]] arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_volatile_array_pointerEarr"} : (!fir.ref>, volatile>, volatile>, !fir.dscope) -> (!fir.ref>, volatile>, volatile>, !fir.ref>, volatile>, volatile>) -! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_5]]#0 : !fir.ref>, volatile>, volatile> -! CHECK: %[[VAL_7:.*]] = hlfir.designate %[[VAL_6]] (%[[VAL_1]]) : (!fir.box>, volatile>, index) -> !fir.ref -! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_7]] : i32, !fir.ref +! CHECK-SAME: %[[ARG0:.*]]: !fir.ref>>, volatile> {fir.bindc_name = "arr"}) {{.*}} { +! CHECK: %[[CONSTANT_0:.*]] = arith.constant 1 : index +! CHECK: %[[CONSTANT_1:.*]] = arith.constant 5 : i32 +! CHECK: %[[DUMMY_SCOPE_0:.*]] = fir.dummy_scope : !fir.dscope +! CHECK: %[[VOLATILE_CAST_0:.*]] = fir.volatile_cast %[[ARG0]] : (!fir.ref>>, volatile>) -> !fir.ref>, volatile>, volatile> +! CHECK: %[[DECLARE_0:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_0]] dummy_scope %[[DUMMY_SCOPE_0]] arg 1 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_volatile_array_pointerEarr"} : (!fir.ref>, volatile>, volatile>, !fir.dscope) -> (!fir.ref>, volatile>, volatile>, !fir.ref>, volatile>, volatile>) +! CHECK: %[[LOAD_0:.*]] = fir.load %[[DECLARE_0]]#0 : !fir.ref>, volatile>, volatile> +! CHECK: %[[DESIGNATE_0:.*]] = hlfir.designate %[[LOAD_0]] (%[[CONSTANT_0]]) : (!fir.box>, volatile>, index) -> !fir.ref +! CHECK: hlfir.assign %[[CONSTANT_1]] to %[[DESIGNATE_0]] : i32, !fir.ref ! CHECK: return ! CHECK: } ! CHECK-LABEL: func.func private @_QFPsub_select_rank( -! CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box> {fir.bindc_name = "arr"}) attributes {fir.host_symbol = @_QQmain, llvm.linkage = #llvm.linkage} { -! CHECK: %[[VAL_1:.*]] = arith.constant 1 : index -! CHECK: %[[VAL_2:.*]] = arith.constant 5 : i32 -! CHECK: %[[VAL_3:.*]] = arith.constant 4 : i8 -! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i8 -! CHECK: %[[VAL_5:.*]] = fir.dummy_scope : !fir.dscope -! CHECK: %[[VAL_6:.*]] = fir.volatile_cast %[[VAL_0]] : (!fir.box>) -> !fir.box, volatile> -! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]] dummy_scope %[[VAL_5]] arg {{[0-9]+}} {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_select_rankEarr"} : (!fir.box, volatile>, !fir.dscope) -> (!fir.box, volatile>, !fir.box, volatile>) -! CHECK: %[[VAL_8:.*]] = fir.volatile_cast %[[VAL_7]]#0 : (!fir.box, volatile>) -> !fir.box> -! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.box>) -> !fir.box -! CHECK: %[[VAL_10:.*]] = fir.call @_FortranAIsAssumedSize(%[[VAL_9]]) : (!fir.box) -> i1 -! CHECK: cf.cond_br %[[VAL_10]], ^bb4, ^bb1 +! CHECK-SAME: %[[ARG0:.*]]: !fir.box> {fir.bindc_name = "arr"}) {{.*}} { +! CHECK: %[[CONSTANT_0:.*]] = arith.constant 1 : index +! CHECK: %[[CONSTANT_1:.*]] = arith.constant 5 : i32 +! CHECK: %[[CONSTANT_2:.*]] = arith.constant 4 : i8 +! CHECK: %[[CONSTANT_3:.*]] = arith.constant 1 : i8 +! CHECK: %[[DUMMY_SCOPE_0:.*]] = fir.dummy_scope : !fir.dscope +! CHECK: %[[VOLATILE_CAST_0:.*]] = fir.volatile_cast %[[ARG0]] : (!fir.box>) -> !fir.box, volatile> +! CHECK: %[[DECLARE_0:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_0]] dummy_scope %[[DUMMY_SCOPE_0]] arg 1 {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_select_rankEarr"} : (!fir.box, volatile>, !fir.dscope) -> (!fir.box, volatile>, !fir.box, volatile>) +! CHECK: %[[VOLATILE_CAST_1:.*]] = fir.volatile_cast %[[DECLARE_0]]#0 : (!fir.box, volatile>) -> !fir.box> +! CHECK: %[[CONVERT_0:.*]] = fir.convert %[[VOLATILE_CAST_1]] : (!fir.box>) -> !fir.box +! CHECK: %[[CALL_0:.*]] = fir.call @_FortranAIsAssumedSize(%[[CONVERT_0]]) : (!fir.box) -> i1 +! CHECK: cf.cond_br %[[CALL_0]], ^bb4, ^bb1 ! CHECK: ^bb1: -! CHECK: %[[VAL_11:.*]] = fir.box_rank %[[VAL_7]]#0 : (!fir.box, volatile>) -> i8 -! CHECK: fir.select_case %[[VAL_11]] : i8 [#fir.point, %[[VAL_4]], ^bb2, #fir.point, %[[VAL_3]], ^bb3, unit, ^bb4] +! CHECK: %[[BOX_RANK_0:.*]] = fir.box_rank %[[DECLARE_0]]#0 : (!fir.box, volatile>) -> i8 +! CHECK: fir.select_case %[[BOX_RANK_0]] : i8 [#fir.point, %[[CONSTANT_3]], ^bb2, #fir.point, %[[CONSTANT_2]], ^bb3, unit, ^bb4] ! CHECK: ^bb2: -! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_7]]#0 : (!fir.box, volatile>) -> !fir.box, volatile> -! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_12]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_select_rankEarr"} : (!fir.box, volatile>) -> (!fir.box, volatile>, !fir.box, volatile>) -! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_13]]#0 (%[[VAL_1]]) : (!fir.box, volatile>, index) -> !fir.ref -! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_14]] : i32, !fir.ref +! CHECK: %[[CONVERT_1:.*]] = fir.convert %[[DECLARE_0]]#0 : (!fir.box, volatile>) -> !fir.box, volatile> +! CHECK: %[[DECLARE_1:.*]]:2 = hlfir.declare %[[CONVERT_1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_select_rankEarr"} : (!fir.box, volatile>) -> (!fir.box, volatile>, !fir.box, volatile>) +! CHECK: %[[DESIGNATE_0:.*]] = hlfir.designate %[[DECLARE_1]]#0 (%[[CONSTANT_0]]) : (!fir.box, volatile>, index) -> !fir.ref +! CHECK: hlfir.assign %[[CONSTANT_1]] to %[[DESIGNATE_0]] : i32, !fir.ref ! CHECK: cf.br ^bb4 ! CHECK: ^bb3: -! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_7]]#0 : (!fir.box, volatile>) -> !fir.box, volatile> -! CHECK: %[[VAL_16:.*]]:2 = hlfir.declare %[[VAL_15]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_select_rankEarr"} : (!fir.box, volatile>) -> (!fir.box, volatile>, !fir.box, volatile>) -! CHECK: %[[VAL_17:.*]] = hlfir.designate %[[VAL_16]]#0 (%[[VAL_1]], %[[VAL_1]], %[[VAL_1]], %[[VAL_1]]) : (!fir.box, volatile>, index, index, index, index) -> !fir.ref -! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_17]] : i32, !fir.ref +! CHECK: %[[CONVERT_2:.*]] = fir.convert %[[DECLARE_0]]#0 : (!fir.box, volatile>) -> !fir.box, volatile> +! CHECK: %[[DECLARE_2:.*]]:2 = hlfir.declare %[[CONVERT_2]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFFsub_select_rankEarr"} : (!fir.box, volatile>) -> (!fir.box, volatile>, !fir.box, volatile>) +! CHECK: %[[DESIGNATE_1:.*]] = hlfir.designate %[[DECLARE_2]]#0 (%[[CONSTANT_0]], %[[CONSTANT_0]], %[[CONSTANT_0]], %[[CONSTANT_0]]) : (!fir.box, volatile>, index, index, index, index) -> !fir.ref +! CHECK: hlfir.assign %[[CONSTANT_1]] to %[[DESIGNATE_1]] : i32, !fir.ref ! CHECK: cf.br ^bb4 ! CHECK: ^bb4: ! CHECK: return diff --git a/flang/test/Lower/volatile4.f90 b/flang/test/Lower/volatile4.f90 index 83ce2b8fdb25a..9b17d2c265458 100644 --- a/flang/test/Lower/volatile4.f90 +++ b/flang/test/Lower/volatile4.f90 @@ -17,76 +17,64 @@ subroutine host_assoc end subroutine end program -! CHECK-LABEL: func.func @_QQmain() attributes {{.+}} { -! CHECK: %[[VAL_0:.*]] = arith.constant 1 : i32 -! CHECK: %[[VAL_1:.*]] = arith.constant 0 : i32 -! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index -! CHECK: %[[VAL_3:.*]] = fir.address_of(@_QFEarr) : !fir.ref> -! CHECK: %[[VAL_4:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1> -! CHECK: %[[VAL_5:.*]] = fir.volatile_cast %[[VAL_3]] : (!fir.ref>) -> !fir.ref, volatile> -! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_5]](%[[VAL_4]]) {{.+}} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) -! CHECK: %[[VAL_7:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFEi"} -! CHECK: %[[VAL_8:.*]] = fir.volatile_cast %[[VAL_7]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_8]] {{.+}} : (!fir.ref) -> (!fir.ref, !fir.ref) -! CHECK: %[[VAL_10:.*]] = fir.address_of(@_QFEptr) : !fir.ref>>> -! CHECK: %[[VAL_11:.*]] = fir.volatile_cast %[[VAL_10]] : (!fir.ref>>>) -> !fir.ref>, volatile>, volatile> -! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare %[[VAL_11]] {{.+}} : (!fir.ref>, volatile>, volatile>) -> (!fir.ref>, volatile>, volatile>, !fir.ref>, volatile>, volatile>) -! CHECK: %[[VAL_13:.*]] = fir.address_of(@_QFEtgt) : !fir.ref> -! CHECK: %[[VAL_14:.*]] = fir.volatile_cast %[[VAL_13]] : (!fir.ref>) -> !fir.ref, volatile> -! CHECK: %[[VAL_15:.*]]:2 = hlfir.declare %[[VAL_14]](%[[VAL_4]]) {{.+}} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) -! CHECK: %[[VAL_16:.*]] = fir.alloca tuple> -! CHECK: %[[VAL_17:.*]] = fir.coordinate_of %[[VAL_16]], %[[VAL_1]] : (!fir.ref>>, i32) -> !fir.llvm_ptr> -! CHECK: %[[VAL_18:.*]] = fir.volatile_cast %[[VAL_9]]#0 : (!fir.ref) -> !fir.ref -! CHECK: fir.store %[[VAL_18]] to %[[VAL_17]] : !fir.llvm_ptr> -! CHECK: %[[VAL_19:.*]] = fir.embox %[[VAL_15]]#0(%[[VAL_4]]) : (!fir.ref, volatile>, !fir.shape<1>) -> !fir.box>, volatile> -! CHECK: fir.store %[[VAL_19]] to %[[VAL_12]]#0 : !fir.ref>, volatile>, volatile> -! CHECK: hlfir.assign %[[VAL_1]] to %[[VAL_9]]#0 : i32, !fir.ref -! CHECK: hlfir.assign %[[VAL_0]] to %[[VAL_6]]#0 : i32, !fir.ref, volatile> -! CHECK: fir.call @_QFPhost_assoc(%[[VAL_16]]) fastmath : (!fir.ref>>) -> () +! CHECK-LABEL: func.func @_QQmain() {{.*}} { +! CHECK: %[[CONSTANT_0:.*]] = arith.constant 1 : i32 +! CHECK: %[[CONSTANT_1:.*]] = arith.constant 0 : i32 +! CHECK: %[[CONSTANT_2:.*]] = arith.constant 10 : index +! CHECK: %[[DUMMY_SCOPE_0:.*]] = fir.dummy_scope : !fir.dscope +! CHECK: %[[ADDRESS_OF_0:.*]] = fir.address_of(@_QFEarr) : !fir.ref> +! CHECK: %[[SHAPE_0:.*]] = fir.shape %[[CONSTANT_2]] : (index) -> !fir.shape<1> +! CHECK: %[[VOLATILE_CAST_0:.*]] = fir.volatile_cast %[[ADDRESS_OF_0]] : (!fir.ref>) -> !fir.ref, volatile> +! CHECK: %[[DECLARE_0:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_0]](%[[SHAPE_0]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEarr"} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) +! CHECK: %[[ALLOCA_0:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFEi"} +! CHECK: %[[VOLATILE_CAST_1:.*]] = fir.volatile_cast %[[ALLOCA_0]] : (!fir.ref) -> !fir.ref +! CHECK: %[[DECLARE_1:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEi"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[ADDRESS_OF_1:.*]] = fir.address_of(@_QFEptr) : !fir.ref>>> +! CHECK: %[[VOLATILE_CAST_2:.*]] = fir.volatile_cast %[[ADDRESS_OF_1]] : (!fir.ref>>>) -> !fir.ref>, volatile>, volatile> +! CHECK: %[[DECLARE_2:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_2]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEptr"} : (!fir.ref>, volatile>, volatile>) -> (!fir.ref>, volatile>, volatile>, !fir.ref>, volatile>, volatile>) +! CHECK: %[[ADDRESS_OF_2:.*]] = fir.address_of(@_QFEtgt) : !fir.ref> +! CHECK: %[[VOLATILE_CAST_3:.*]] = fir.volatile_cast %[[ADDRESS_OF_2]] : (!fir.ref>) -> !fir.ref, volatile> +! CHECK: %[[DECLARE_3:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_3]](%[[SHAPE_0]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEtgt"} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) +! CHECK: %[[ALLOCA_1:.*]] = fir.alloca tuple> +! CHECK: %[[COORDINATE_OF_0:.*]] = fir.coordinate_of %[[ALLOCA_1]], %[[CONSTANT_1]] : (!fir.ref>>, i32) -> !fir.llvm_ptr> +! CHECK: %[[VOLATILE_CAST_4:.*]] = fir.volatile_cast %[[DECLARE_1]]#0 : (!fir.ref) -> !fir.ref +! CHECK: fir.store %[[VOLATILE_CAST_4]] to %[[COORDINATE_OF_0]] : !fir.llvm_ptr> +! CHECK: %[[CONVERT_0:.*]] = fir.convert %[[DECLARE_1]]#0 : (!fir.ref) -> i64 +! CHECK: %[[CONVERT_1:.*]] = fir.convert %[[CONVERT_0]] : (i64) -> i32 +! CHECK: hlfir.assign %[[CONVERT_1]] to %[[DECLARE_1]]#0 : i32, !fir.ref +! CHECK: %[[CONVERT_2:.*]] = fir.convert %[[DECLARE_3]]#0 : (!fir.ref, volatile>) -> !fir.ref, volatile> +! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[CONVERT_2]](%[[SHAPE_0]]) : (!fir.ref, volatile>, !fir.shape<1>) -> !fir.box>, volatile> +! CHECK: fir.store %[[EMBOX_0]] to %[[DECLARE_2]]#0 : !fir.ref>, volatile>, volatile> +! CHECK: hlfir.assign %[[CONSTANT_1]] to %[[DECLARE_1]]#0 : i32, !fir.ref +! CHECK: hlfir.assign %[[CONSTANT_0]] to %[[DECLARE_0]]#0 : i32, !fir.ref, volatile> +! CHECK: fir.call @_QFPhost_assoc(%[[ALLOCA_1]]) fastmath : (!fir.ref>>) -> () ! CHECK: return ! CHECK: } ! CHECK-LABEL: func.func private @_QFPhost_assoc( -! CHECK-SAME: %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.ref>> {fir.host_assoc}) attributes {{.+}} { -! CHECK: %[[VAL_1:.*]] = arith.constant 1 : i32 -! CHECK: %[[VAL_2:.*]] = arith.constant 0 : i32 -! CHECK: %[[VAL_3:.*]] = arith.constant 10 : index -! CHECK: %[[VAL_4:.*]] = fir.dummy_scope : !fir.dscope -! CHECK: %[[VAL_5:.*]] = fir.address_of(@_QFEarr) : !fir.ref> -! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1> -! CHECK: %[[VAL_7:.*]] = fir.volatile_cast %[[VAL_5]] : (!fir.ref>) -> !fir.ref, volatile> -! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_7]](%[[VAL_6]]) {{.+}} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) -! CHECK: %[[VAL_9:.*]] = fir.address_of(@_QFEptr) : !fir.ref>>> -! CHECK: %[[VAL_10:.*]] = fir.volatile_cast %[[VAL_9]] : (!fir.ref>>>) -> !fir.ref>, volatile>, volatile> -! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {{.+}} : (!fir.ref>, volatile>, volatile>) -> (!fir.ref>, volatile>, volatile>, !fir.ref>, volatile>, volatile>) -! CHECK: %[[VAL_12:.*]] = fir.address_of(@_QFEtgt) : !fir.ref> -! CHECK: %[[VAL_13:.*]] = fir.volatile_cast %[[VAL_12]] : (!fir.ref>) -> !fir.ref, volatile> -! CHECK: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_13]](%[[VAL_6]]) {{.+}} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) -! CHECK: %[[VAL_15:.*]] = fir.coordinate_of %[[VAL_0]], %[[VAL_2]] : (!fir.ref>>, i32) -> !fir.llvm_ptr> -! CHECK: %[[VAL_16:.*]] = fir.load %[[VAL_15]] : !fir.llvm_ptr> -! CHECK: %[[VAL_17:.*]] = fir.volatile_cast %[[VAL_16]] : (!fir.ref) -> !fir.ref -! CHECK: %[[VAL_18:.*]]:2 = hlfir.declare %[[VAL_17]] {{.+}} : (!fir.ref) -> (!fir.ref, !fir.ref) -! CHECK: %[[VAL_19:.*]] = fir.embox %[[VAL_14]]#0(%[[VAL_6]]) : (!fir.ref, volatile>, !fir.shape<1>) -> !fir.box>, volatile> -! CHECK: fir.store %[[VAL_19]] to %[[VAL_11]]#0 : !fir.ref>, volatile>, volatile> -! CHECK: hlfir.assign %[[VAL_2]] to %[[VAL_18]]#0 : i32, !fir.ref -! CHECK: hlfir.assign %[[VAL_1]] to %[[VAL_8]]#0 : i32, !fir.ref, volatile> +! CHECK-SAME: %[[ARG0:.*]]: !fir.ref>> {fir.host_assoc}) {{.*}} { +! CHECK: %[[CONSTANT_0:.*]] = arith.constant 1 : i32 +! CHECK: %[[CONSTANT_1:.*]] = arith.constant 0 : i32 +! CHECK: %[[CONSTANT_2:.*]] = arith.constant 10 : index +! CHECK: %[[DUMMY_SCOPE_0:.*]] = fir.dummy_scope : !fir.dscope +! CHECK: %[[ADDRESS_OF_0:.*]] = fir.address_of(@_QFEarr) : !fir.ref> +! CHECK: %[[SHAPE_0:.*]] = fir.shape %[[CONSTANT_2]] : (index) -> !fir.shape<1> +! CHECK: %[[VOLATILE_CAST_0:.*]] = fir.volatile_cast %[[ADDRESS_OF_0]] : (!fir.ref>) -> !fir.ref, volatile> +! CHECK: %[[DECLARE_0:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_0]](%[[SHAPE_0]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEarr"} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) +! CHECK: %[[ADDRESS_OF_1:.*]] = fir.address_of(@_QFEptr) : !fir.ref>>> +! CHECK: %[[VOLATILE_CAST_1:.*]] = fir.volatile_cast %[[ADDRESS_OF_1]] : (!fir.ref>>>) -> !fir.ref>, volatile>, volatile> +! CHECK: %[[DECLARE_1:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_1]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEptr"} : (!fir.ref>, volatile>, volatile>) -> (!fir.ref>, volatile>, volatile>, !fir.ref>, volatile>, volatile>) +! CHECK: %[[ADDRESS_OF_2:.*]] = fir.address_of(@_QFEtgt) : !fir.ref> +! CHECK: %[[VOLATILE_CAST_2:.*]] = fir.volatile_cast %[[ADDRESS_OF_2]] : (!fir.ref>) -> !fir.ref, volatile> +! CHECK: %[[DECLARE_2:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_2]](%[[SHAPE_0]]) {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEtgt"} : (!fir.ref, volatile>, !fir.shape<1>) -> (!fir.ref, volatile>, !fir.ref, volatile>) +! CHECK: %[[COORDINATE_OF_0:.*]] = fir.coordinate_of %[[ARG0]], %[[CONSTANT_1]] : (!fir.ref>>, i32) -> !fir.llvm_ptr> +! CHECK: %[[LOAD_0:.*]] = fir.load %[[COORDINATE_OF_0]] : !fir.llvm_ptr> +! CHECK: %[[VOLATILE_CAST_3:.*]] = fir.volatile_cast %[[LOAD_0]] : (!fir.ref) -> !fir.ref +! CHECK: %[[DECLARE_3:.*]]:2 = hlfir.declare %[[VOLATILE_CAST_3]] {fortran_attrs = #fir.var_attrs, uniq_name = "_QFEi"} : (!fir.ref) -> (!fir.ref, !fir.ref) +! CHECK: %[[CONVERT_0:.*]] = fir.convert %[[DECLARE_2]]#0 : (!fir.ref, volatile>) -> !fir.ref, volatile> +! CHECK: %[[EMBOX_0:.*]] = fir.embox %[[CONVERT_0]](%[[SHAPE_0]]) : (!fir.ref, volatile>, !fir.shape<1>) -> !fir.box>, volatile> +! CHECK: fir.store %[[EMBOX_0]] to %[[DECLARE_1]]#0 : !fir.ref>, volatile>, volatile> +! CHECK: hlfir.assign %[[CONSTANT_1]] to %[[DECLARE_3]]#0 : i32, !fir.ref +! CHECK: hlfir.assign %[[CONSTANT_0]] to %[[DECLARE_0]]#0 : i32, !fir.ref, volatile> ! CHECK: return ! CHECK: } - -! CHECK-LABEL: fir.global internal @_QFEarr : !fir.array<10xi32> { -! CHECK: %[[VAL_0:.*]] = fir.zero_bits !fir.array<10xi32> -! CHECK: fir.has_value %[[VAL_0]] : !fir.array<10xi32> -! CHECK: } - -! CHECK-LABEL: fir.global internal @_QFEptr : !fir.box>> { -! CHECK: %[[VAL_0:.*]] = arith.constant 0 : index -! CHECK: %[[VAL_1:.*]] = fir.zero_bits !fir.ptr> -! CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_0]] : (index) -> !fir.shape<1> -! CHECK: %[[VAL_3:.*]] = fir.embox %[[VAL_1]](%[[VAL_2]]) : (!fir.ptr>, !fir.shape<1>) -> !fir.box>> -! CHECK: fir.has_value %[[VAL_3]] : !fir.box>> -! CHECK: } - -! CHECK-LABEL: fir.global internal @_QFEtgt target : !fir.array<10xi32> { -! CHECK: %[[VAL_0:.*]] = fir.zero_bits !fir.array<10xi32> -! CHECK: fir.has_value %[[VAL_0]] : !fir.array<10xi32> -! CHECK: }