diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp --- a/flang/lib/Lower/IO.cpp +++ b/flang/lib/Lower/IO.cpp @@ -161,7 +161,7 @@ static mlir::func::FuncOp getIORuntimeFunc(mlir::Location loc, fir::FirOpBuilder &builder) { llvm::StringRef name = getName(); - auto func = builder.getNamedFunction(name); + mlir::func::FuncOp func = builder.getNamedFunction(name); if (func) return func; auto funTy = getTypeModel()(builder.getContext()); @@ -179,7 +179,8 @@ Fortran::lower::StatementContext &stmtCtx) { fir::FirOpBuilder &builder = converter.getFirOpBuilder(); if (csi.ioMsg) { - auto getIoMsg = getIORuntimeFunc(loc, builder); + mlir::func::FuncOp getIoMsg = + getIORuntimeFunc(loc, builder); builder.create( loc, getIoMsg, mlir::ValueRange{ @@ -189,7 +190,8 @@ builder.createConvert(loc, getIoMsg.getFunctionType().getInput(2), fir::getLen(*csi.ioMsg))}); } - auto endIoStatement = getIORuntimeFunc(loc, builder); + mlir::func::FuncOp endIoStatement = + getIORuntimeFunc(loc, builder); auto call = builder.create(loc, endIoStatement, mlir::ValueRange{cookie}); mlir::Value iostat = call.getResult(0); @@ -478,7 +480,8 @@ if (!expr) fir::emitFatalError(loc, "internal error: could not get evaluate::Expr"); mlir::Type itemTy = converter.genType(*expr); - auto outputFunc = getOutputFunc(loc, builder, itemTy, isFormatted); + mlir::func::FuncOp outputFunc = + getOutputFunc(loc, builder, itemTy, isFormatted); mlir::Type argType = outputFunc.getFunctionType().getInput(1); assert((isFormatted || argType.isa()) && "expect descriptor for unformatted IO runtime"); @@ -625,7 +628,7 @@ if (Fortran::evaluate::HasVectorSubscript(*expr)) { auto vectorSubscriptBox = Fortran::lower::genVectorSubscriptBox(loc, converter, stmtCtx, *expr); - auto inputFunc = getInputFunc( + mlir::func::FuncOp inputFunc = getInputFunc( loc, builder, vectorSubscriptBox.getElementType(), isFormatted); const bool mustBox = inputFunc.getFunctionType().getInput(1).isa(); @@ -651,7 +654,8 @@ continue; } mlir::Type itemTy = converter.genType(*expr); - auto inputFunc = getInputFunc(loc, builder, itemTy, isFormatted); + mlir::func::FuncOp inputFunc = + getInputFunc(loc, builder, itemTy, isFormatted); auto itemExv = inputFunc.getFunctionType().getInput(1).isa() ? converter.genExprBox(loc, *expr, stmtCtx) : converter.genExprAddr(loc, expr, stmtCtx); @@ -873,7 +877,7 @@ const B &spec) { Fortran::lower::StatementContext localStatementCtx; fir::FirOpBuilder &builder = converter.getFirOpBuilder(); - auto ioFunc = getIORuntimeFunc(loc, builder); + mlir::func::FuncOp ioFunc = getIORuntimeFunc(loc, builder); mlir::FunctionType ioFuncTy = ioFunc.getFunctionType(); mlir::Value expr = fir::getBase(converter.genExprValue( loc, Fortran::semantics::GetExpr(spec.v), localStatementCtx)); @@ -890,7 +894,7 @@ const B &spec) { Fortran::lower::StatementContext localStatementCtx; fir::FirOpBuilder &builder = converter.getFirOpBuilder(); - auto ioFunc = getIORuntimeFunc(loc, builder); + mlir::func::FuncOp ioFunc = getIORuntimeFunc(loc, builder); mlir::FunctionType ioFuncTy = ioFunc.getFunctionType(); std::tuple tup = lowerStringLit(converter, loc, localStatementCtx, spec, @@ -922,7 +926,7 @@ Fortran::lower::StatementContext localStatementCtx; fir::FirOpBuilder &builder = converter.getFirOpBuilder(); // has an extra KIND argument - auto ioFunc = getIORuntimeFunc(loc, builder); + mlir::func::FuncOp ioFunc = getIORuntimeFunc(loc, builder); mlir::FunctionType ioFuncTy = ioFunc.getFunctionType(); std::tuple tup = lowerStringLit(converter, loc, localStatementCtx, spec, @@ -1093,7 +1097,8 @@ std::get_if(&spec.u)) { fir::FirOpBuilder &builder = converter.getFirOpBuilder(); - auto ioFunc = getIORuntimeFunc(loc, builder); + mlir::func::FuncOp ioFunc = + getIORuntimeFunc(loc, builder); auto sizeValue = builder.create(loc, ioFunc, mlir::ValueRange{cookie}) .getResult(0); @@ -1218,7 +1223,8 @@ if (!csi.hasAnyConditionSpec()) return; fir::FirOpBuilder &builder = converter.getFirOpBuilder(); - auto enableHandlers = getIORuntimeFunc(loc, builder); + mlir::func::FuncOp enableHandlers = + getIORuntimeFunc(loc, builder); mlir::Type boolType = enableHandlers.getFunctionType().getInput(1); auto boolValue = [&](bool specifierIsPresent) { return builder.create( @@ -1549,7 +1555,7 @@ // overflow when passed to the IO runtime, check that the unit number is // in range before calling the BeginXXX. if (rawUnitWidth > runtimeArgWidth) { - auto check = + mlir::func::FuncOp check = rawUnitWidth <= 64 ? getIORuntimeFunc(loc, builder) : getIORuntimeFunc(loc, @@ -1625,7 +1631,7 @@ Fortran::lower::StatementContext stmtCtx; mlir::Location loc = converter.getCurrentLocation(); ConditionSpecInfo csi = lowerErrorSpec(converter, loc, stmt.v); - auto beginFunc = getIORuntimeFunc(loc, builder); + mlir::func::FuncOp beginFunc = getIORuntimeFunc(loc, builder); mlir::FunctionType beginFuncTy = beginFunc.getFunctionType(); mlir::Value unit = genIOUnitNumber( converter, loc, getExpr(stmt), @@ -1678,7 +1684,8 @@ std::get_if(&spec.u)) { Fortran::lower::StatementContext stmtCtx; fir::FirOpBuilder &builder = converter.getFirOpBuilder(); - auto ioFunc = getIORuntimeFunc(loc, builder); + mlir::func::FuncOp ioFunc = + getIORuntimeFunc(loc, builder); mlir::FunctionType ioFuncTy = ioFunc.getFunctionType(); const auto *var = Fortran::semantics::GetExpr(newunit->v); mlir::Value addr = builder.createConvert( @@ -1745,9 +1752,9 @@ mlir::Location loc = converter.getCurrentLocation(); ConditionSpecInfo csi = lowerErrorSpec(converter, loc, stmt.v); bool hasId = hasSpec(stmt); - auto beginFunc = hasId - ? getIORuntimeFunc(loc, builder) - : getIORuntimeFunc(loc, builder); + mlir::func::FuncOp beginFunc = + hasId ? getIORuntimeFunc(loc, builder) + : getIORuntimeFunc(loc, builder); mlir::FunctionType beginFuncTy = beginFunc.getFunctionType(); mlir::Value unit = genIOUnitNumber( converter, loc, getExpr(stmt), @@ -1913,9 +1920,9 @@ } // Generate the begin data transfer function call. - auto ioFunc = getBeginDataTransferFunc(loc, builder, isFormatted, - isList || isNml, isInternal, - isInternalWithDesc, isAsync); + mlir::func::FuncOp ioFunc = getBeginDataTransferFunc( + loc, builder, isFormatted, isList || isNml, isInternal, + isInternalWithDesc, isAsync); llvm::SmallVector ioArgs; genBeginDataTransferCallArgs( ioArgs, converter, loc, stmt, ioFunc.getFunctionType(), isFormatted, @@ -2026,7 +2033,8 @@ Fortran::parser::InquireSpec::CharVar::Kind::Iomsg) return {}; fir::FirOpBuilder &builder = converter.getFirOpBuilder(); - auto specFunc = getIORuntimeFunc(loc, builder); + mlir::func::FuncOp specFunc = + getIORuntimeFunc(loc, builder); mlir::FunctionType specFuncTy = specFunc.getFunctionType(); const auto *varExpr = Fortran::semantics::GetExpr( std::get(var.t)); @@ -2055,7 +2063,8 @@ Fortran::parser::InquireSpec::IntVar::Kind::Iostat) return {}; fir::FirOpBuilder &builder = converter.getFirOpBuilder(); - auto specFunc = getIORuntimeFunc(loc, builder); + mlir::func::FuncOp specFunc = + getIORuntimeFunc(loc, builder); mlir::FunctionType specFuncTy = specFunc.getFunctionType(); const auto *varExpr = Fortran::semantics::GetExpr( std::get(var.t)); @@ -2091,7 +2100,7 @@ bool pendId = idExpr && logVarKind == Fortran::parser::InquireSpec::LogVar::Kind::Pending; - auto specFunc = + mlir::func::FuncOp specFunc = pendId ? getIORuntimeFunc(loc, builder) : getIORuntimeFunc(loc, builder); mlir::FunctionType specFuncTy = specFunc.getFunctionType(); diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp --- a/flang/lib/Lower/Mangler.cpp +++ b/flang/lib/Lower/Mangler.cpp @@ -57,12 +57,13 @@ static const Fortran::semantics::Symbol * findInterfaceIfSeperateMP(const Fortran::semantics::Symbol &symbol) { - const auto &scope = symbol.owner(); + const Fortran::semantics::Scope &scope = symbol.owner(); if (symbol.attrs().test(Fortran::semantics::Attr::MODULE) && scope.IsSubmodule()) { // FIXME symbol from MpSubprogramStmt do not seem to have // Attr::MODULE set. - const auto *iface = scope.parent().FindSymbol(symbol.name()); + const Fortran::semantics::Symbol *iface = + scope.parent().FindSymbol(symbol.name()); assert(iface && "Separate module procedure must be declared"); return iface; } @@ -108,10 +109,11 @@ // Separate module subprograms must be mangled according to the // scope where they were declared (the symbol we have is the // definition). - const auto *interface = &ultimateSymbol; + const Fortran::semantics::Symbol *interface = &ultimateSymbol; if (const auto *mpIface = findInterfaceIfSeperateMP(ultimateSymbol)) interface = mpIface; - auto modNames = moduleNames(*interface); + llvm::SmallVector modNames = + moduleNames(*interface); return fir::NameUniquer::doProcedure(modNames, hostName(*interface), symbolName); }, @@ -129,16 +131,18 @@ symbolName); }, [&](const Fortran::semantics::ObjectEntityDetails &) { - auto modNames = moduleNames(ultimateSymbol); - auto optHost = hostName(ultimateSymbol); + llvm::SmallVector modNames = + moduleNames(ultimateSymbol); + llvm::Optional optHost = hostName(ultimateSymbol); if (Fortran::semantics::IsNamedConstant(ultimateSymbol)) return fir::NameUniquer::doConstant(modNames, optHost, symbolName); return fir::NameUniquer::doVariable(modNames, optHost, symbolName); }, [&](const Fortran::semantics::NamelistDetails &) { - auto modNames = moduleNames(ultimateSymbol); - auto optHost = hostName(ultimateSymbol); + llvm::SmallVector modNames = + moduleNames(ultimateSymbol); + llvm::Optional optHost = hostName(ultimateSymbol); return fir::NameUniquer::doNamelistGroup(modNames, optHost, symbolName); }, @@ -159,21 +163,25 @@ std::string Fortran::lower::mangle::mangleName( const Fortran::semantics::DerivedTypeSpec &derivedType) { // Resolve host and module association before mangling - const auto &ultimateSymbol = derivedType.typeSymbol().GetUltimate(); - auto symbolName = toStringRef(ultimateSymbol.name()); - auto modNames = moduleNames(ultimateSymbol); - auto optHost = hostName(ultimateSymbol); + const Fortran::semantics::Symbol &ultimateSymbol = + derivedType.typeSymbol().GetUltimate(); + llvm::StringRef symbolName = toStringRef(ultimateSymbol.name()); + llvm::SmallVector modNames = moduleNames(ultimateSymbol); + llvm::Optional optHost = hostName(ultimateSymbol); llvm::SmallVector kinds; for (const auto ¶m : Fortran::semantics::OrderParameterDeclarations(ultimateSymbol)) { const auto ¶mDetails = param->get(); if (paramDetails.attr() == Fortran::common::TypeParamAttr::Kind) { - const auto *paramValue = derivedType.FindParameter(param->name()); + const Fortran::semantics::ParamValue *paramValue = + derivedType.FindParameter(param->name()); assert(paramValue && "derived type kind parameter value not found"); - auto paramExpr = paramValue->GetExplicit(); + const Fortran::semantics::MaybeIntExpr paramExpr = + paramValue->GetExplicit(); assert(paramExpr && "derived type kind param not explicit"); - auto init = Fortran::evaluate::ToInt64(paramValue->GetExplicit()); + std::optional init = + Fortran::evaluate::ToInt64(paramValue->GetExplicit()); assert(init && "derived type kind param is not constant"); kinds.emplace_back(*init); } @@ -273,7 +281,7 @@ name.append(intrinsic.str()).append("."); assert(funTy.getNumResults() == 1 && "only function mangling supported"); name.append(typeToString(funTy.getResult(0))); - auto e = funTy.getNumInputs(); + unsigned e = funTy.getNumInputs(); for (decltype(e) i = 0; i < e; ++i) name.append(".").append(typeToString(funTy.getInput(i))); return name;