Skip to content

Commit 0b3fa79

Browse files
authored
Merge pull request #1069 from flang-compiler/jpr-elem-sub-2
Lower elemental subroutine calls (outside of user assignment case)
2 parents 63130d8 + 6227665 commit 0b3fa79

File tree

7 files changed

+380
-90
lines changed

7 files changed

+380
-90
lines changed

flang/include/flang/Lower/ConvertExpr.h

+10
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ createSomeArrayBox(AbstractConverter &converter,
186186
const evaluate::Expr<evaluate::SomeType> &expr,
187187
SymMap &symMap, StatementContext &stmtCtx);
188188

189+
/// Lower a subroutine call. This handles both elemental and non elemental
190+
/// subroutines. \p isUserDefAssignment must be set if this is called in the
191+
/// context of a user defined assignment. For subroutines with alternate
192+
/// returns, the returned value indicates which label the code should jump to.
193+
/// The returned value is null otherwise.
194+
mlir::Value createSubroutineCall(AbstractConverter &converter,
195+
const evaluate::Expr<evaluate::SomeType> &call,
196+
SymMap &symMap, StatementContext &stmtCtx,
197+
bool isUserDefAssignment);
198+
189199
// Attribute for an alloca that is a trivial adaptor for converting a value to
190200
// pass-by-ref semantics for a VALUE parameter. The optimizer may be able to
191201
// eliminate these.

flang/lib/Lower/Bridge.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
662662
assert(stmt.typedCall && "Call was not analyzed");
663663
// Call statement lowering shares code with function call lowering.
664664
Fortran::semantics::SomeExpr expr{*stmt.typedCall};
665-
auto res = createFIRExpr(toLocation(), &expr, stmtCtx);
665+
auto res = Fortran::lower::createSubroutineCall(
666+
*this, expr, localSymbols, stmtCtx, /*isUserDefAssignment=*/false);
666667
if (!res)
667668
return; // "Normal" subroutine call.
668669
// Call with alternate return specifiers.
@@ -1939,11 +1940,13 @@ class FirConverter : public Fortran::lower::AbstractConverter {
19391940
[&](const Fortran::evaluate::ProcedureRef &procRef) {
19401941
if (implicitIterationSpace())
19411942
TODO(loc, "user defined assignment within WHERE");
1943+
19421944
Fortran::semantics::SomeExpr expr{procRef};
1943-
createFIRExpr(toLocation(), &expr,
1944-
explicitIterationSpace()
1945-
? explicitIterSpace.stmtContext()
1946-
: stmtCtx);
1945+
auto &ctx = explicitIterationSpace()
1946+
? explicitIterSpace.stmtContext()
1947+
: stmtCtx;
1948+
Fortran::lower::createSubroutineCall(
1949+
*this, expr, localSymbols, ctx, /*isUserDefAssignment=*/true);
19471950
},
19481951

19491952
// [3] Pointer assignment with possibly empty bounds-spec. R1035: a

0 commit comments

Comments
 (0)