aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Lower
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Lower')
-rw-r--r--flang/lib/Lower/ConvertCall.cpp9
-rw-r--r--flang/lib/Lower/OpenMP/ReductionProcessor.cpp31
-rw-r--r--flang/lib/Lower/Runtime.cpp9
3 files changed, 32 insertions, 17 deletions
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index 6eba243..315a3f6 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -1340,15 +1340,6 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
} else {
addr = hlfir::genVariableRawAddress(loc, builder, entity);
}
- // The last extent created for assumed-rank descriptors must be -1 (18.5.3
- // point 5.). This should be done when creating the assumed-size shape for
- // consistency.
- if (auto baseBoxDummy = mlir::dyn_cast<fir::BaseBoxType>(dummyType))
- if (baseBoxDummy.isAssumedRank())
- if (const Fortran::semantics::Symbol *sym =
- Fortran::evaluate::UnwrapWholeSymbolDataRef(*arg.entity))
- if (Fortran::semantics::IsAssumedSizeArray(sym->GetUltimate()))
- TODO(loc, "passing assumed-size to assumed-rank array");
// For ranked actual passed to assumed-rank dummy, the cast to assumed-rank
// box is inserted when building the fir.call op. Inserting it here would
diff --git a/flang/lib/Lower/OpenMP/ReductionProcessor.cpp b/flang/lib/Lower/OpenMP/ReductionProcessor.cpp
index 0d05ca5..c1c9411 100644
--- a/flang/lib/Lower/OpenMP/ReductionProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ReductionProcessor.cpp
@@ -13,6 +13,7 @@
#include "ReductionProcessor.h"
#include "flang/Lower/AbstractConverter.h"
+#include "flang/Lower/SymbolMap.h"
#include "flang/Optimizer/Builder/HLFIRTools.h"
#include "flang/Optimizer/Builder/Todo.h"
#include "flang/Optimizer/Dialect/FIRType.h"
@@ -522,12 +523,20 @@ void ReductionProcessor::addDeclareReduction(
if (reductionSymbols)
reductionSymbols->push_back(symbol);
mlir::Value symVal = converter.getSymbolAddress(*symbol);
- auto redType = mlir::cast<fir::ReferenceType>(symVal.getType());
+ mlir::Type eleType;
+ auto refType = mlir::dyn_cast_or_null<fir::ReferenceType>(symVal.getType());
+ if (refType)
+ eleType = refType.getEleTy();
+ else
+ eleType = symVal.getType();
// all arrays must be boxed so that we have convenient access to all the
// information needed to iterate over the array
- if (mlir::isa<fir::SequenceType>(redType.getEleTy())) {
- hlfir::Entity entity{symVal};
+ if (mlir::isa<fir::SequenceType>(eleType)) {
+ // For Host associated symbols, use `SymbolBox` instead
+ Fortran::lower::SymbolBox symBox =
+ converter.lookupOneLevelUpSymbol(*symbol);
+ hlfir::Entity entity{symBox.getAddr()};
entity = genVariableBox(currentLocation, builder, entity);
mlir::Value box = entity.getBase();
@@ -538,11 +547,25 @@ void ReductionProcessor::addDeclareReduction(
builder.create<fir::StoreOp>(currentLocation, box, alloca);
symVal = alloca;
- redType = mlir::cast<fir::ReferenceType>(symVal.getType());
+ } else if (mlir::isa<fir::BaseBoxType>(symVal.getType())) {
+ // boxed arrays are passed as values not by reference. Unfortunately,
+ // we can't pass a box by value to omp.redution_declare, so turn it
+ // into a reference
+
+ auto alloca =
+ builder.create<fir::AllocaOp>(currentLocation, symVal.getType());
+ builder.create<fir::StoreOp>(currentLocation, symVal, alloca);
+ symVal = alloca;
} else if (auto declOp = symVal.getDefiningOp<hlfir::DeclareOp>()) {
symVal = declOp.getBase();
}
+ // this isn't the same as the by-val and by-ref passing later in the
+ // pipeline. Both styles assume that the variable is a reference at
+ // this point
+ assert(mlir::isa<fir::ReferenceType>(symVal.getType()) &&
+ "reduction input var is a reference");
+
reductionVars.push_back(symVal);
}
const bool isByRef = doReductionByRef(reductionVars);
diff --git a/flang/lib/Lower/Runtime.cpp b/flang/lib/Lower/Runtime.cpp
index e769592..3474832 100644
--- a/flang/lib/Lower/Runtime.cpp
+++ b/flang/lib/Lower/Runtime.cpp
@@ -55,6 +55,8 @@ static void genUnreachable(fir::FirOpBuilder &builder, mlir::Location loc) {
void Fortran::lower::genStopStatement(
Fortran::lower::AbstractConverter &converter,
const Fortran::parser::StopStmt &stmt) {
+ const bool isError = std::get<Fortran::parser::StopStmt::Kind>(stmt.t) ==
+ Fortran::parser::StopStmt::Kind::ErrorStop;
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
mlir::Location loc = converter.getCurrentLocation();
Fortran::lower::StatementContext stmtCtx;
@@ -94,13 +96,12 @@ void Fortran::lower::genStopStatement(
} else {
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatement)>(loc, builder);
calleeType = callee.getFunctionType();
- operands.push_back(
- builder.createIntegerConstant(loc, calleeType.getInput(0), 0));
+ // Default to values are advised in F'2023 11.4 p2.
+ operands.push_back(builder.createIntegerConstant(
+ loc, calleeType.getInput(0), isError ? 1 : 0));
}
// Second operand indicates ERROR STOP
- bool isError = std::get<Fortran::parser::StopStmt::Kind>(stmt.t) ==
- Fortran::parser::StopStmt::Kind::ErrorStop;
operands.push_back(builder.createIntegerConstant(
loc, calleeType.getInput(operands.size()), isError));