[flang-commits] [clang] [flang] [flang] Remove legacy (non-HLFIR) lowering and related options (PR #196205)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Thu May 7 03:40:37 PDT 2026
https://github.com/eugeneepshteyn updated https://github.com/llvm/llvm-project/pull/196205
>From b065304c1fc3365d7a2efb13add4e392f785c9c3 Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Wed, 6 May 2026 12:23:40 -0400
Subject: [PATCH 1/3] [flang] Remove legacy (non-HLFIR) lowering options and
code paths
Remove the driver options `-flang-experimental-hlfir` and
`-flang-deprecated-no-hlfir`, the bbc `-hlfir` option, and the
`LowerToHighLevelFIR` lowering option. With HLFIR as the only path,
delete all `if (lowerToHighLevelFIR()) { ... } else { ... }` branches in
`lib/Lower/` (Bridge.cpp, ConvertVariable.cpp, ConvertCall.cpp,
CallInterface.cpp, Allocatable.cpp, HostAssociations.cpp, ConvertType.cpp,
ConvertConstant.cpp), keeping only the HLFIR side. Drop the now-unused
`copyVarFIR` and both `genNoHLFIRPointerAssignment` overloads in Bridge.cpp,
along with the entire legacy block in `genAssignment`.
Update tests that previously selected the lowering path explicitly to
remove the dropped flags. Delete `Driver/hlfir-no-hlfir-error.f90`, which
existed solely to test mutual exclusion of the two removed options.
The legacy entry points in `ConvertExpr.cpp` / `ConvertExpr.h`
(`createSomeExtendedExpression`, `createMutableBox`, etc.) are intentionally
left in place: `createSomeExtendedExpression` is still required by
`Lower/OpenMP/Utils.cpp` for iterator-dependent OpenMP subscripts (HLFIR
cannot lower OpenMP iterator variables yet), and `createMutableBox` is
still called from `ConvertVariable.cpp` for allocatables/pointers. Their
removal is a follow-up.
Verified: ninja flang, ninja install, ninja check-flang
(4270 passing / 0 failing), ninja check-flang-rt (312/312 passing).
---
clang/include/clang/Options/FlangOptions.td | 12 -
clang/lib/Driver/ToolChains/Flang.cpp | 2 -
flang/include/flang/Lower/LoweringOptions.def | 3 -
flang/lib/Frontend/CompilerInvocation.cpp | 19 -
flang/lib/Frontend/FrontendActions.cpp | 8 +-
flang/lib/Lower/Allocatable.cpp | 17 +-
flang/lib/Lower/Bridge.cpp | 664 +++---------------
flang/lib/Lower/CallInterface.cpp | 11 +-
flang/lib/Lower/ConvertCall.cpp | 20 +-
flang/lib/Lower/ConvertConstant.cpp | 12 -
flang/lib/Lower/ConvertType.cpp | 30 +-
flang/lib/Lower/ConvertVariable.cpp | 109 +--
flang/lib/Lower/HostAssociations.cpp | 7 +-
flang/test/Driver/frontend-forwarding.f90 | 2 -
flang/test/Driver/hlfir-no-hlfir-error.f90 | 16 -
flang/test/HLFIR/dummy_deallocation.f90 | 2 +-
flang/test/HLFIR/hlfir-flags.f90 | 6 +-
flang/test/HLFIR/inline-elemental.f90 | 2 +-
flang/test/HLFIR/no-block-merging.fir | 2 +-
.../forall-fusing-scheduling.f90 | 4 +-
...l-pointer-assignment-scheduling-bounds.f90 | 2 +-
...nter-assignment-scheduling-polymorphic.f90 | 2 +-
.../forall-pointer-assignment-scheduling.f90 | 2 +-
...ointer-assignment-scheduling-character.f90 | 2 +-
...all-proc-pointer-assignment-scheduling.f90 | 2 +-
.../order_assignments/forall-scheduling.f90 | 2 +-
.../where-array-sections.f90 | 4 +-
.../where-fusing-scheduling.f90 | 4 +-
.../order_assignments/where-hoisting.f90 | 2 +-
.../order_assignments/where-scheduling.f90 | 2 +-
flang/test/Lower/CUDA/cuda-devptr.cuf | 2 +-
flang/test/Lower/CUDA/cuda-init.cuf | 4 +-
.../Lower/CUDA/cuda-kernel-alloca-block.cuf | 2 +-
.../test/Lower/HLFIR/bindc-assumed-length.f90 | 2 +-
flang/test/Lower/HLFIR/expr-box.f90 | 2 +-
flang/test/Lower/HLFIR/forall.f90 | 2 +-
flang/test/Lower/HLFIR/goto-do-body.f90 | 2 +-
.../Lower/HLFIR/tdesc-character-comp-init.f90 | 2 +-
.../Lower/HLFIR/type-bound-proc-tdesc.f90 | 2 +-
.../Lower/OpenACC/acc-atomic-update-hlfir.f90 | 2 +-
.../Lower/OpenMP/function-filtering-2.f90 | 4 +-
.../Lower/OpenMP/function-filtering-3.f90 | 4 +-
.../test/Lower/OpenMP/function-filtering.f90 | 4 +-
.../Lower/OpenMP/hlfir-seqloop-parallel.f90 | 2 +-
flang/test/Lower/OpenMP/hlfir-wsloop.f90 | 4 +-
flang/test/Lower/OpenMP/sections.f90 | 2 +-
flang/test/Lower/OpenMP/simd.f90 | 4 +-
flang/test/Lower/OpenMP/simple-barrier.f90 | 4 +-
.../test/Lower/OpenMP/stop-stmt-in-region.f90 | 4 +-
.../threadprivate-common-block-hlfir.f90 | 4 +-
.../threadprivate-common-block-pointer.f90 | 2 +-
.../test/Lower/OpenMP/threadprivate-hlfir.f90 | 4 +-
flang/test/Lower/pass-null-for-class-arg.f90 | 2 +-
flang/tools/bbc/bbc.cpp | 7 +-
54 files changed, 195 insertions(+), 850 deletions(-)
delete mode 100644 flang/test/Driver/hlfir-no-hlfir-error.f90
diff --git a/clang/include/clang/Options/FlangOptions.td b/clang/include/clang/Options/FlangOptions.td
index 1ab83b6ffbbad..50e4642358b71 100644
--- a/clang/include/clang/Options/FlangOptions.td
+++ b/clang/include/clang/Options/FlangOptions.td
@@ -114,18 +114,6 @@ def static_libflangrt : Flag<["-"], "static-libflangrt">,
HelpText<"Link the flang-rt static library">, Group<Link_Group>,
Visibility<[FlangOption]>, Flags<[NoArgumentUnused]>;
-//===----------------------------------------------------------------------===//
-// FlangOption + NoXarchOption
-//===----------------------------------------------------------------------===//
-
-def flang_experimental_hlfir : Flag<["-"], "flang-experimental-hlfir">,
- Flags<[HelpHidden]>, Visibility<[FlangOption, FC1Option]>,
- HelpText<"Use HLFIR lowering (experimental)">;
-
-def flang_deprecated_no_hlfir : Flag<["-"], "flang-deprecated-no-hlfir">,
- Flags<[HelpHidden]>, Visibility<[FlangOption, FC1Option]>,
- HelpText<"Do not use HLFIR lowering (deprecated)">;
-
//===----------------------------------------------------------------------===//
// FlangOption + CoreOption + NoXarchOption
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index ce503b74295e4..082df7beb4b85 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -252,8 +252,6 @@ void Flang::addCodegenOptions(const ArgList &Args,
Args.addAllArgs(
CmdArgs,
{options::OPT_fdo_concurrent_to_openmp_EQ,
- options::OPT_flang_experimental_hlfir,
- options::OPT_flang_deprecated_no_hlfir,
options::OPT_fno_ppc_native_vec_elem_order,
options::OPT_fppc_native_vec_elem_order, options::OPT_finit_global_zero,
options::OPT_fno_init_global_zero, options::OPT_frepack_arrays,
diff --git a/flang/include/flang/Lower/LoweringOptions.def b/flang/include/flang/Lower/LoweringOptions.def
index 0b829bf3e08af..e89ad75704609 100644
--- a/flang/include/flang/Lower/LoweringOptions.def
+++ b/flang/include/flang/Lower/LoweringOptions.def
@@ -24,9 +24,6 @@ LOWERINGOPT(Name, Bits, Default)
/// If true, lower transpose without a runtime call.
ENUM_LOWERINGOPT(OptimizeTranspose, unsigned, 1, 1)
-/// If true, lower to High level FIR before lowering to FIR. On by default.
-ENUM_LOWERINGOPT(LowerToHighLevelFIR, unsigned, 1, 1)
-
/// If true, reverse PowerPC native vector element order.
ENUM_LOWERINGOPT(NoPPCNativeVecElemOrder, unsigned, 1, 0)
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index e7f4762e167fb..7205eb4548968 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -1629,25 +1629,6 @@ bool CompilerInvocation::createFromArgs(
success = false;
}
- // -flang-experimental-hlfir
- if (args.hasArg(clang::options::OPT_flang_experimental_hlfir) ||
- args.hasArg(clang::options::OPT_emit_hlfir)) {
- invoc.loweringOpts.setLowerToHighLevelFIR(true);
- }
-
- // -flang-deprecated-no-hlfir
- if (args.hasArg(clang::options::OPT_flang_deprecated_no_hlfir) &&
- !args.hasArg(clang::options::OPT_emit_hlfir)) {
- if (args.hasArg(clang::options::OPT_flang_experimental_hlfir)) {
- const unsigned diagID = diags.getCustomDiagID(
- clang::DiagnosticsEngine::Error,
- "Options '-flang-experimental-hlfir' and "
- "'-flang-deprecated-no-hlfir' cannot be both specified");
- diags.Report(diagID);
- }
- invoc.loweringOpts.setLowerToHighLevelFIR(false);
- }
-
// -fno-ppc-native-vector-element-order
if (args.hasArg(clang::options::OPT_fno_ppc_native_vec_elem_order)) {
invoc.loweringOpts.setNoPPCNativeVecElemOrder(true);
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 4e058786a9a72..9ad1da0011ef4 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -1345,8 +1345,6 @@ void CodeGenAction::executeAction() {
clang::DiagnosticsEngine &diags = ci.getDiagnostics();
const CodeGenOptions &codeGenOpts = ci.getInvocation().getCodeGenOpts();
const TargetOptions &targetOpts = ci.getInvocation().getTargetOpts();
- Fortran::lower::LoweringOptions &loweringOpts =
- ci.getInvocation().getLoweringOpts();
mlir::DefaultTimingManager &timingMgr = ci.getTimingManager();
mlir::TimingScope &timingScopeRoot = ci.getTimingScopeRoot();
@@ -1375,16 +1373,12 @@ void CodeGenAction::executeAction() {
}
if (action == BackendActionTy::Backend_EmitFIR) {
- if (loweringOpts.getLowerToHighLevelFIR()) {
- lowerHLFIRToFIR();
- }
+ lowerHLFIRToFIR();
mlirModule->print(ci.isOutputStreamNull() ? *os : ci.getOutputStream());
return;
}
if (action == BackendActionTy::Backend_EmitHLFIR) {
- assert(loweringOpts.getLowerToHighLevelFIR() &&
- "Lowering must have been configured to emit HLFIR");
mlirModule->print(ci.isOutputStreamNull() ? *os : ci.getOutputStream());
return;
}
diff --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp
index 5cbfba23cffdf..9173f06f2bd24 100644
--- a/flang/lib/Lower/Allocatable.cpp
+++ b/flang/lib/Lower/Allocatable.cpp
@@ -1163,22 +1163,9 @@ void Fortran::lower::associateMutableBox(
cuf::genPointerSync(box.getAddr(), builder);
return;
}
- if (converter.getLoweringOptions().getLowerToHighLevelFIR()) {
- fir::ExtendedValue rhs = converter.genExprAddr(loc, source, stmtCtx);
- fir::factory::associateMutableBox(builder, loc, box, rhs, lbounds);
- cuf::genPointerSync(box.getAddr(), builder);
- return;
- }
- // The right hand side is not be evaluated into a temp. Array sections can
- // typically be represented as a value of type `!fir.box`. However, an
- // expression that uses vector subscripts cannot be emboxed. In that case,
- // generate a reference to avoid having to later use a fir.rebox to implement
- // the pointer association.
- fir::ExtendedValue rhs = isArraySectionWithoutVectorSubscript(source)
- ? converter.genExprBox(loc, source, stmtCtx)
- : converter.genExprAddr(loc, source, stmtCtx);
-
+ fir::ExtendedValue rhs = converter.genExprAddr(loc, source, stmtCtx);
fir::factory::associateMutableBox(builder, loc, box, rhs, lbounds);
+ cuf::genPointerSync(box.getAddr(), builder);
}
bool Fortran::lower::isWholeAllocatable(const Fortran::lower::SomeExpr &expr) {
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index c5709e1cd94d4..091f267b43c17 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -808,11 +808,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
Fortran::lower::StatementContext &context,
mlir::Location *locPtr = nullptr) override final {
mlir::Location loc = locPtr ? *locPtr : toLocation();
- if (lowerToHighLevelFIR())
- return Fortran::lower::convertExprToAddress(loc, *this, expr,
- localSymbols, context);
- return Fortran::lower::createSomeExtendedAddress(loc, *this, expr,
- localSymbols, context);
+ return Fortran::lower::convertExprToAddress(loc, *this, expr, localSymbols,
+ context);
}
fir::ExtendedValue
@@ -820,21 +817,15 @@ class FirConverter : public Fortran::lower::AbstractConverter {
Fortran::lower::StatementContext &context,
mlir::Location *locPtr = nullptr) override final {
mlir::Location loc = locPtr ? *locPtr : toLocation();
- if (lowerToHighLevelFIR())
- return Fortran::lower::convertExprToValue(loc, *this, expr, localSymbols,
- context);
- return Fortran::lower::createSomeExtendedExpression(loc, *this, expr,
- localSymbols, context);
+ return Fortran::lower::convertExprToValue(loc, *this, expr, localSymbols,
+ context);
}
fir::ExtendedValue
genExprBox(mlir::Location loc, const Fortran::lower::SomeExpr &expr,
Fortran::lower::StatementContext &stmtCtx) override final {
- if (lowerToHighLevelFIR())
- return Fortran::lower::convertExprToBox(loc, *this, expr, localSymbols,
- stmtCtx);
- return Fortran::lower::createBoxValue(loc, *this, expr, localSymbols,
- stmtCtx);
+ return Fortran::lower::convertExprToBox(loc, *this, expr, localSymbols,
+ stmtCtx);
}
Fortran::evaluate::FoldingContext &getFoldingContext() override final {
@@ -1378,56 +1369,51 @@ class FirConverter : public Fortran::lower::AbstractConverter {
Fortran::lower::SymMap *symMap = nullptr,
bool forceHlfirBase = false) {
symMap = symMap ? symMap : &localSymbols;
- if (lowerToHighLevelFIR()) {
- if (std::optional<fir::FortranVariableOpInterface> var =
- symMap->lookupVariableDefinition(sym)) {
- auto exv = hlfir::translateToExtendedValue(toLocation(), *builder, *var,
- forceHlfirBase);
- return exv.match(
- [](mlir::Value x) -> Fortran::lower::SymbolBox {
- return Fortran::lower::SymbolBox::Intrinsic{x};
- },
- [](auto x) -> Fortran::lower::SymbolBox { return x; });
- }
-
- // Entry character result represented as an argument pair
- // needs to be represented in the symbol table even before
- // we can create DeclareOp for it. The temporary mapping
- // is EmboxCharOp that conveys the address and length information.
- // After mapSymbolAttributes is done, the mapping is replaced
- // with the new DeclareOp, and the following table lookups
- // do not reach here.
- if (sym.IsFuncResult())
- if (const Fortran::semantics::DeclTypeSpec *declTy = sym.GetType())
- if (declTy->category() ==
- Fortran::semantics::DeclTypeSpec::Category::Character)
- return symMap->lookupSymbol(sym);
-
- // Procedure dummies are not mapped with an hlfir.declare because
- // they are not "variable" (cannot be assigned to), and it would
- // make hlfir.declare more complex than it needs to to allow this.
- // Do a regular lookup.
- if (Fortran::semantics::IsProcedure(sym))
- return symMap->lookupSymbol(sym);
-
- // Commonblock names are not variables, but in some lowerings (like
- // OpenMP) it is useful to maintain the address of the commonblock in an
- // MLIR value and query it. hlfir.declare need not be created for these.
- if (sym.detailsIf<Fortran::semantics::CommonBlockDetails>())
- return symMap->lookupSymbol(sym);
-
- // For symbols to be privatized in OMP, the symbol is mapped to an
- // instance of `SymbolBox::Intrinsic` (i.e. a direct mapping to an MLIR
- // SSA value). This MLIR SSA value is the block argument to the
- // `omp.private`'s `alloc` block. If this is the case, we return this
- // `SymbolBox::Intrinsic` value.
- if (Fortran::lower::SymbolBox v = symMap->lookupSymbol(sym))
- return v;
-
- return {};
- }
+ if (std::optional<fir::FortranVariableOpInterface> var =
+ symMap->lookupVariableDefinition(sym)) {
+ auto exv = hlfir::translateToExtendedValue(toLocation(), *builder, *var,
+ forceHlfirBase);
+ return exv.match(
+ [](mlir::Value x) -> Fortran::lower::SymbolBox {
+ return Fortran::lower::SymbolBox::Intrinsic{x};
+ },
+ [](auto x) -> Fortran::lower::SymbolBox { return x; });
+ }
+
+ // Entry character result represented as an argument pair
+ // needs to be represented in the symbol table even before
+ // we can create DeclareOp for it. The temporary mapping
+ // is EmboxCharOp that conveys the address and length information.
+ // After mapSymbolAttributes is done, the mapping is replaced
+ // with the new DeclareOp, and the following table lookups
+ // do not reach here.
+ if (sym.IsFuncResult())
+ if (const Fortran::semantics::DeclTypeSpec *declTy = sym.GetType())
+ if (declTy->category() ==
+ Fortran::semantics::DeclTypeSpec::Category::Character)
+ return symMap->lookupSymbol(sym);
+
+ // Procedure dummies are not mapped with an hlfir.declare because
+ // they are not "variable" (cannot be assigned to), and it would
+ // make hlfir.declare more complex than it needs to to allow this.
+ // Do a regular lookup.
+ if (Fortran::semantics::IsProcedure(sym))
+ return symMap->lookupSymbol(sym);
+
+ // Commonblock names are not variables, but in some lowerings (like
+ // OpenMP) it is useful to maintain the address of the commonblock in an
+ // MLIR value and query it. hlfir.declare need not be created for these.
+ if (sym.detailsIf<Fortran::semantics::CommonBlockDetails>())
+ return symMap->lookupSymbol(sym);
+
+ // For symbols to be privatized in OMP, the symbol is mapped to an
+ // instance of `SymbolBox::Intrinsic` (i.e. a direct mapping to an MLIR
+ // SSA value). This MLIR SSA value is the block argument to the
+ // `omp.private`'s `alloc` block. If this is the case, we return this
+ // `SymbolBox::Intrinsic` value.
if (Fortran::lower::SymbolBox v = symMap->lookupSymbol(sym))
return v;
+
return {};
}
@@ -1451,13 +1437,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
fir::ExtendedValue val, bool forced = false) {
if (!forced && lookupSymbol(sym))
return false;
- if (lowerToHighLevelFIR()) {
- Fortran::lower::genDeclareSymbol(*this, localSymbols, sym, val,
- fir::FortranVariableFlagsEnum::None,
- forced);
- } else {
- localSymbols.addSymbol(sym, val, forced);
- }
+ Fortran::lower::genDeclareSymbol(*this, localSymbols, sym, val,
+ fir::FortranVariableFlagsEnum::None,
+ forced);
return true;
}
@@ -1466,17 +1448,12 @@ class FirConverter : public Fortran::lower::AbstractConverter {
const Fortran::lower::SymbolBox &rhs_sb,
Fortran::semantics::Symbol::Flags flags) {
mlir::Location loc = genLocation(sym.name());
- if (lowerToHighLevelFIR())
- copyVarHLFIR(loc, lhs_sb, rhs_sb, flags);
- else
- copyVarFIR(loc, sym, lhs_sb, rhs_sb);
+ copyVarHLFIR(loc, lhs_sb, rhs_sb, flags);
}
void copyVarHLFIR(mlir::Location loc, Fortran::lower::SymbolBox dst,
Fortran::lower::SymbolBox src,
Fortran::semantics::Symbol::Flags flags) {
- assert(lowerToHighLevelFIR());
-
bool isBoxAllocatable = dst.match(
[](const fir::MutableBoxValue &box) { return box.isAllocatable(); },
[](const fir::FortranVariableOpInterface &box) {
@@ -1500,7 +1477,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
void copyVarHLFIR(mlir::Location loc, Fortran::lower::SymbolBox dst,
Fortran::lower::SymbolBox src, bool isAllocatable,
bool isPointer, Fortran::semantics::Symbol::Flags flags) {
- assert(lowerToHighLevelFIR());
hlfir::Entity lhs{dst.getAddr()};
hlfir::Entity rhs{src.getAddr()};
@@ -1553,26 +1529,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
}
}
- void copyVarFIR(mlir::Location loc, const Fortran::semantics::Symbol &sym,
- const Fortran::lower::SymbolBox &lhs_sb,
- const Fortran::lower::SymbolBox &rhs_sb) {
- assert(!lowerToHighLevelFIR());
- fir::ExtendedValue lhs = symBoxToExtendedValue(lhs_sb);
- fir::ExtendedValue rhs = symBoxToExtendedValue(rhs_sb);
- mlir::Type symType = genType(sym);
- if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(symType)) {
- Fortran::lower::StatementContext stmtCtx;
- Fortran::lower::createSomeArrayAssignment(*this, lhs, rhs, localSymbols,
- stmtCtx);
- stmtCtx.finalizeAndReset();
- } else if (lhs.getBoxOf<fir::CharBoxValue>()) {
- fir::factory::CharacterExprHelper{*builder, loc}.createAssign(lhs, rhs);
- } else {
- auto loadVal = fir::LoadOp::create(*builder, loc, fir::getBase(rhs));
- fir::StoreOp::create(*builder, loc, loadVal, fir::getBase(lhs));
- }
- }
-
/// Map a block argument to a result or dummy symbol. This is not the
/// definitive mapping. The specification expression have not been lowered
/// yet. The final mapping will be done using this pre-mapping in
@@ -2130,7 +2086,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
dir->u);
}
- if (lowerToHighLevelFIR()) {
+ {
std::optional<mlir::Type> resultType;
if (stmt.typedCall->hasAlternateReturns())
resultType = builder->getIndexType();
@@ -2139,11 +2095,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
stmtCtx);
if (hlfirRes)
res = *hlfirRes;
- } else {
- // Call statement lowering shares code with function call lowering.
- res = Fortran::lower::createSubroutineCall(
- *this, *stmt.typedCall, explicitIterSpace, implicitIterSpace,
- localSymbols, stmtCtx, /*isUserDefAssignment=*/false);
}
stmtCtx.finalizeAndReset();
if (!res)
@@ -3390,24 +3341,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
Fortran::common::visit([&](const auto &x) { genFIR(x); }, stmt.u);
}
- void genFIR(const Fortran::parser::EndForallStmt &) {
- if (!lowerToHighLevelFIR())
- cleanupExplicitSpace();
- }
-
- template <typename A>
- void prepareExplicitSpace(const A &forall) {
- if (!explicitIterSpace.isActive())
- analyzeExplicitSpace(forall);
- localSymbols.pushScope();
- explicitIterSpace.enter();
- }
-
- /// Cleanup all the FORALL context information when we exit.
- void cleanupExplicitSpace() {
- explicitIterSpace.leave();
- localSymbols.popScope();
- }
+ void genFIR(const Fortran::parser::EndForallStmt &) {}
/// Generate FIR for a FORALL statement.
void genFIR(const Fortran::parser::ForallStmt &stmt) {
@@ -3416,31 +3350,19 @@ class FirConverter : public Fortran::lower::AbstractConverter {
Fortran::common::Indirection<Fortran::parser::ConcurrentHeader>>(
stmt.t)
.value();
- if (lowerToHighLevelFIR()) {
- mlir::OpBuilder::InsertionGuard guard(*builder);
- Fortran::lower::SymMapScope scope(localSymbols);
- genForallNest(concurrentHeader);
- genFIR(std::get<Fortran::parser::UnlabeledStatement<
- Fortran::parser::ForallAssignmentStmt>>(stmt.t)
- .statement);
- return;
- }
- prepareExplicitSpace(stmt);
- genFIR(concurrentHeader);
+ mlir::OpBuilder::InsertionGuard guard(*builder);
+ Fortran::lower::SymMapScope scope(localSymbols);
+ genForallNest(concurrentHeader);
genFIR(std::get<Fortran::parser::UnlabeledStatement<
Fortran::parser::ForallAssignmentStmt>>(stmt.t)
.statement);
- cleanupExplicitSpace();
}
/// Generate FIR for a FORALL construct.
void genFIR(const Fortran::parser::ForallConstruct &forall) {
setCurrentPositionAt(forall);
mlir::OpBuilder::InsertPoint insertPt = builder->saveInsertionPoint();
- if (lowerToHighLevelFIR())
- localSymbols.pushScope();
- else
- prepareExplicitSpace(forall);
+ localSymbols.pushScope();
genNestedStatement(
std::get<
Fortran::parser::Statement<Fortran::parser::ForallConstructStmt>>(
@@ -3458,10 +3380,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
genNestedStatement(
std::get<Fortran::parser::Statement<Fortran::parser::EndForallStmt>>(
forall.t));
- if (lowerToHighLevelFIR()) {
- localSymbols.popScope();
- builder->restoreInsertionPoint(insertPt);
- }
+ localSymbols.popScope();
+ builder->restoreInsertionPoint(insertPt);
}
/// Lower the concurrent header specification.
@@ -3471,10 +3391,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
Fortran::common::Indirection<Fortran::parser::ConcurrentHeader>>(
stmt.t)
.value();
- if (lowerToHighLevelFIR())
- genForallNest(concurrentHeader);
- else
- genFIR(concurrentHeader);
+ genForallNest(concurrentHeader);
}
/// Generate hlfir.forall and hlfir.forall_mask nest given a Forall
@@ -4309,12 +4226,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
fir::ExtendedValue
genAssociateSelector(const Fortran::lower::SomeExpr &selector,
Fortran::lower::StatementContext &stmtCtx) {
- if (lowerToHighLevelFIR())
- return genExprAddr(selector, stmtCtx);
- return Fortran::lower::isArraySectionWithoutVectorSubscript(selector)
- ? Fortran::lower::createSomeArrayBox(*this, selector,
- localSymbols, stmtCtx)
- : genExprAddr(selector, stmtCtx);
+ return genExprAddr(selector, stmtCtx);
}
void genFIR(const Fortran::parser::AssociateConstruct &) {
@@ -5117,10 +5029,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
inline fir::MutableBoxValue
genExprMutableBox(mlir::Location loc,
const Fortran::lower::SomeExpr &expr) override final {
- if (lowerToHighLevelFIR())
- return Fortran::lower::convertExprToMutableBox(loc, *this, expr,
- localSymbols);
- return Fortran::lower::createMutableBox(loc, *this, expr, localSymbols);
+ return Fortran::lower::convertExprToMutableBox(loc, *this, expr,
+ localSymbols);
}
// Create the [newRank] array with the lower bounds to be passed to the
@@ -5147,61 +5057,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
return fir::EmboxOp::create(*builder, loc, boxTy, boundArray, shapeOp);
}
- // Generate pointer assignment with possibly empty bounds-spec. R1035: a
- // bounds-spec is a lower bound value.
- void genNoHLFIRPointerAssignment(
- mlir::Location loc, const Fortran::evaluate::Assignment &assign,
- const Fortran::evaluate::Assignment::BoundsSpec &lbExprs) {
- Fortran::lower::StatementContext stmtCtx;
-
- assert(!lowerToHighLevelFIR() && "code should not be called with HFLIR");
- if (Fortran::evaluate::IsProcedureDesignator(assign.rhs))
- TODO(loc, "procedure pointer assignment");
-
- std::optional<Fortran::evaluate::DynamicType> lhsType =
- assign.lhs.GetType();
- // Delegate pointer association to unlimited polymorphic pointer
- // to the runtime. element size, type code, attribute and of
- // course base_addr might need to be updated.
- if (lhsType && lhsType->IsPolymorphic()) {
- if (explicitIterationSpace())
- TODO(loc, "polymorphic pointer assignment in FORALL");
- llvm::SmallVector<mlir::Value> lbounds;
- for (const Fortran::evaluate::ExtentExpr &lbExpr : lbExprs)
- lbounds.push_back(
- fir::getBase(genExprValue(toEvExpr(lbExpr), stmtCtx)));
- fir::MutableBoxValue lhsMutableBox = genExprMutableBox(loc, assign.lhs);
- if (Fortran::evaluate::UnwrapExpr<Fortran::evaluate::NullPointer>(
- assign.rhs)) {
- fir::factory::disassociateMutableBox(*builder, loc, lhsMutableBox);
- return;
- }
- mlir::Value lhs = lhsMutableBox.getAddr();
- mlir::Value rhs = fir::getBase(genExprBox(loc, assign.rhs, stmtCtx));
- if (!lbounds.empty()) {
- mlir::Value boundsDesc = createLboundArray(lbounds, loc);
- Fortran::lower::genPointerAssociateLowerBounds(*builder, loc, lhs, rhs,
- boundsDesc);
- return;
- }
- Fortran::lower::genPointerAssociate(*builder, loc, lhs, rhs);
- return;
- }
-
- llvm::SmallVector<mlir::Value> lbounds;
- for (const Fortran::evaluate::ExtentExpr &lbExpr : lbExprs)
- lbounds.push_back(fir::getBase(genExprValue(toEvExpr(lbExpr), stmtCtx)));
- if (explicitIterationSpace()) {
- // Pointer assignment in FORALL context. Copy the rhs box value
- // into the lhs box variable.
- genArrayAssignment(assign, stmtCtx, lbounds);
- return;
- }
- fir::MutableBoxValue lhs = genExprMutableBox(loc, assign.lhs);
- Fortran::lower::associateMutableBox(*this, loc, lhs, assign.rhs, lbounds,
- stmtCtx);
- }
-
void genPointerAssignment(mlir::Location loc,
const Fortran::evaluate::Assignment &assign) {
if (isInsideHlfirForallOrWhere()) {
@@ -5385,75 +5240,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
return fir::EmboxOp::create(*builder, loc, boxTy, boundArray, shapeOp);
}
- // Pointer assignment with bounds-remapping. R1036: a bounds-remapping is a
- // pair, lower bound and upper bound.
- 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<mlir::Value> lbounds;
- llvm::SmallVector<mlir::Value> ubounds;
- for (const std::pair<Fortran::evaluate::ExtentExpr,
- Fortran::evaluate::ExtentExpr> &pair : boundExprs) {
- const Fortran::evaluate::ExtentExpr &lbExpr = pair.first;
- const Fortran::evaluate::ExtentExpr &ubExpr = pair.second;
- lbounds.push_back(fir::getBase(genExprValue(toEvExpr(lbExpr), stmtCtx)));
- ubounds.push_back(fir::getBase(genExprValue(toEvExpr(ubExpr), stmtCtx)));
- }
-
- std::optional<Fortran::evaluate::DynamicType> lhsType =
- assign.lhs.GetType();
- std::optional<Fortran::evaluate::DynamicType> rhsType =
- assign.rhs.GetType();
- // Polymorphic lhs/rhs need more care. See F2018 10.2.2.3.
- if ((lhsType && lhsType->IsPolymorphic()) ||
- (rhsType && rhsType->IsPolymorphic())) {
- if (explicitIterationSpace())
- TODO(loc, "polymorphic pointer assignment in FORALL");
-
- fir::MutableBoxValue lhsMutableBox = genExprMutableBox(loc, assign.lhs);
- if (Fortran::evaluate::UnwrapExpr<Fortran::evaluate::NullPointer>(
- assign.rhs)) {
- fir::factory::disassociateMutableBox(*builder, loc, lhsMutableBox);
- return;
- }
- mlir::Value lhs = lhsMutableBox.getAddr();
- mlir::Value rhs = fir::getBase(genExprBox(loc, assign.rhs, stmtCtx));
- mlir::Value boundsDesc = createBoundArray(lbounds, ubounds, loc);
- Fortran::lower::genPointerAssociateRemapping(
- *builder, loc, lhs, rhs, boundsDesc,
- lhsType && rhsType && !lhsType->IsPolymorphic() &&
- rhsType->IsPolymorphic());
- return;
- }
- if (explicitIterationSpace()) {
- // Pointer assignment in FORALL context. Copy the rhs box value
- // into the lhs box variable.
- genArrayAssignment(assign, stmtCtx, lbounds, ubounds);
- return;
- }
- fir::MutableBoxValue lhs = genExprMutableBox(loc, assign.lhs);
- if (Fortran::evaluate::UnwrapExpr<Fortran::evaluate::NullPointer>(
- assign.rhs)) {
- fir::factory::disassociateMutableBox(*builder, loc, lhs);
- return;
- }
- // Do not generate a temp in case rhs is an array section.
- fir::ExtendedValue rhs =
- Fortran::lower::isArraySectionWithoutVectorSubscript(assign.rhs)
- ? Fortran::lower::createSomeArrayBox(*this, assign.rhs,
- localSymbols, stmtCtx)
- : genExprAddr(assign.rhs, stmtCtx);
- fir::factory::associateMutableBoxWithRemap(*builder, loc, lhs, rhs, lbounds,
- ubounds);
- if (explicitIterationSpace()) {
- mlir::ValueRange inners = explicitIterSpace.getInnerArgs();
- if (!inners.empty())
- fir::ResultOp::create(*builder, loc, inners);
- }
- }
-
/// Given converted LHS and RHS of the assignment, materialize any
/// implicit conversion of the RHS to the LHS type. The front-end
/// usually already makes those explicit, except for non-standard
@@ -5835,233 +5621,23 @@ class FirConverter : public Fortran::lower::AbstractConverter {
const llvm::ArrayRef<const Fortran::parser::CompilerDirective *>
&dirs = {}) {
mlir::Location loc = toLocation();
- if (lowerToHighLevelFIR()) {
- Fortran::common::visit(
- Fortran::common::visitors{
- [&](const Fortran::evaluate::Assignment::Intrinsic &) {
- genDataAssignment(assign, /*userDefinedAssignment=*/nullptr,
- dirs);
- },
- [&](const Fortran::evaluate::ProcedureRef &procRef) {
- genDataAssignment(assign, /*userDefinedAssignment=*/&procRef,
- dirs);
- },
- [&](const Fortran::evaluate::Assignment::BoundsSpec &lbExprs) {
- genPointerAssignment(loc, assign);
- },
- [&](const Fortran::evaluate::Assignment::BoundsRemapping
- &boundExprs) { genPointerAssignment(loc, assign); },
- },
- assign.u);
- return;
- }
- if (explicitIterationSpace()) {
- Fortran::lower::createArrayLoads(*this, explicitIterSpace, localSymbols);
- explicitIterSpace.genLoopNest();
- }
- Fortran::lower::StatementContext stmtCtx;
Fortran::common::visit(
Fortran::common::visitors{
- // [1] Plain old assignment.
[&](const Fortran::evaluate::Assignment::Intrinsic &) {
- const Fortran::semantics::Symbol *sym =
- Fortran::evaluate::GetLastSymbol(assign.lhs);
-
- if (!sym)
- TODO(loc, "assignment to pointer result of function reference");
-
- std::optional<Fortran::evaluate::DynamicType> lhsType =
- assign.lhs.GetType();
- assert(lhsType && "lhs cannot be typeless");
- std::optional<Fortran::evaluate::DynamicType> rhsType =
- assign.rhs.GetType();
-
- // Assignment to/from polymorphic entities are done with the
- // runtime.
- if (lhsType->IsPolymorphic() ||
- lhsType->IsUnlimitedPolymorphic() ||
- (rhsType && (rhsType->IsPolymorphic() ||
- rhsType->IsUnlimitedPolymorphic()))) {
- mlir::Value lhs;
- if (Fortran::lower::isWholeAllocatable(assign.lhs))
- lhs = genExprMutableBox(loc, assign.lhs).getAddr();
- else
- lhs = fir::getBase(genExprBox(loc, assign.lhs, stmtCtx));
- mlir::Value rhs =
- fir::getBase(genExprBox(loc, assign.rhs, stmtCtx));
- if ((lhsType->IsPolymorphic() ||
- lhsType->IsUnlimitedPolymorphic()) &&
- Fortran::lower::isWholeAllocatable(assign.lhs))
- fir::runtime::genAssignPolymorphic(*builder, loc, lhs, rhs);
- else
- fir::runtime::genAssign(*builder, loc, lhs, rhs);
- return;
- }
-
- // Note: No ad-hoc handling for pointers is required here. The
- // target will be assigned as per 2018 10.2.1.3 p2. genExprAddr
- // on a pointer returns the target address and not the address of
- // the pointer variable.
-
- if (assign.lhs.Rank() > 0 || explicitIterationSpace()) {
- if (isDerivedCategory(lhsType->category()) &&
- Fortran::semantics::IsFinalizable(
- lhsType->GetDerivedTypeSpec()))
- TODO(loc, "derived-type finalization with array assignment");
- // Array assignment
- // See Fortran 2018 10.2.1.3 p5, p6, and p7
- genArrayAssignment(assign, stmtCtx);
- return;
- }
-
- // Scalar assignment
- const bool isNumericScalar =
- isNumericScalarCategory(lhsType->category());
- const bool isVector =
- isDerivedCategory(lhsType->category()) &&
- lhsType->GetDerivedTypeSpec().IsVectorType();
- fir::ExtendedValue rhs = (isNumericScalar || isVector)
- ? genExprValue(assign.rhs, stmtCtx)
- : genExprAddr(assign.rhs, stmtCtx);
- const bool lhsIsWholeAllocatable =
- Fortran::lower::isWholeAllocatable(assign.lhs);
- std::optional<fir::factory::MutableBoxReallocation> lhsRealloc;
- std::optional<fir::MutableBoxValue> lhsMutableBox;
-
- // Set flag to know if the LHS needs finalization. Polymorphic,
- // unlimited polymorphic assignment will be done with genAssign.
- // Assign runtime function performs the finalization.
- bool needFinalization = !lhsType->IsPolymorphic() &&
- !lhsType->IsUnlimitedPolymorphic() &&
- (isDerivedCategory(lhsType->category()) &&
- Fortran::semantics::IsFinalizable(
- lhsType->GetDerivedTypeSpec()));
-
- auto lhs = [&]() -> fir::ExtendedValue {
- if (lhsIsWholeAllocatable) {
- lhsMutableBox = genExprMutableBox(loc, assign.lhs);
- // Finalize if needed.
- if (needFinalization) {
- mlir::Value isAllocated =
- fir::factory::genIsAllocatedOrAssociatedTest(
- *builder, loc, *lhsMutableBox);
- builder->genIfThen(loc, isAllocated)
- .genThen([&]() {
- fir::runtime::genDerivedTypeDestroy(
- *builder, loc, fir::getBase(*lhsMutableBox));
- })
- .end();
- needFinalization = false;
- }
-
- llvm::SmallVector<mlir::Value> lengthParams;
- if (const fir::CharBoxValue *charBox = rhs.getCharBox())
- lengthParams.push_back(charBox->getLen());
- else if (fir::isDerivedWithLenParameters(rhs))
- TODO(loc, "assignment to derived type allocatable with "
- "LEN parameters");
- lhsRealloc = fir::factory::genReallocIfNeeded(
- *builder, loc, *lhsMutableBox,
- /*shape=*/{}, lengthParams);
- return lhsRealloc->newValue;
- }
- return genExprAddr(assign.lhs, stmtCtx);
- }();
-
- if (isNumericScalar || isVector) {
- // Fortran 2018 10.2.1.3 p8 and p9
- // Conversions should have been inserted by semantic analysis,
- // but they can be incorrect between the rhs and lhs. Correct
- // that here.
- mlir::Value addr = fir::getBase(lhs);
- mlir::Value val = fir::getBase(rhs);
- // A function with multiple entry points returning different
- // types tags all result variables with one of the largest
- // types to allow them to share the same storage. Assignment
- // to a result variable of one of the other types requires
- // conversion to the actual type.
- mlir::Type toTy = genType(assign.lhs);
-
- // If Cray pointee, need to handle the address
- // Array is handled in genCoordinateOp.
- if (sym->test(Fortran::semantics::Symbol::Flag::CrayPointee) &&
- sym->Rank() == 0) {
- // get the corresponding Cray pointer
-
- const Fortran::semantics::Symbol &ptrSym =
- Fortran::semantics::GetCrayPointer(*sym);
- fir::ExtendedValue ptr =
- getSymbolExtendedValue(ptrSym, nullptr);
- mlir::Value ptrVal = fir::getBase(ptr);
- mlir::Type ptrTy = genType(ptrSym);
-
- fir::ExtendedValue pte =
- getSymbolExtendedValue(*sym, nullptr);
- mlir::Value pteVal = fir::getBase(pte);
- mlir::Value cnvrt = Fortran::lower::addCrayPointerInst(
- loc, *builder, ptrVal, ptrTy, pteVal.getType());
- addr = fir::LoadOp::create(*builder, loc, cnvrt);
- }
- mlir::Value cast =
- isVector ? val
- : builder->convertWithSemantics(loc, toTy, val);
- if (fir::dyn_cast_ptrEleTy(addr.getType()) != toTy) {
- assert(isFuncResultDesignator(assign.lhs) && "type mismatch");
- addr = builder->createConvert(
- toLocation(), builder->getRefType(toTy), addr);
- }
- fir::StoreOp::create(*builder, loc, cast, addr);
- } else if (isCharacterCategory(lhsType->category())) {
- // Fortran 2018 10.2.1.3 p10 and p11
- fir::factory::CharacterExprHelper{*builder, loc}.createAssign(
- lhs, rhs);
- } else if (isDerivedCategory(lhsType->category())) {
- // Handle parent component.
- if (Fortran::lower::isParentComponent(assign.lhs)) {
- if (!mlir::isa<fir::BaseBoxType>(fir::getBase(lhs).getType()))
- lhs = fir::getBase(builder->createBox(loc, lhs));
- lhs = Fortran::lower::updateBoxForParentComponent(*this, lhs,
- assign.lhs);
- }
-
- // Fortran 2018 10.2.1.3 p13 and p14
- // Recursively gen an assignment on each element pair.
- fir::factory::genRecordAssignment(*builder, loc, lhs, rhs,
- needFinalization);
- } else {
- llvm_unreachable("unknown category");
- }
- if (lhsIsWholeAllocatable) {
- assert(lhsRealloc.has_value());
- fir::factory::finalizeRealloc(*builder, loc, *lhsMutableBox,
- /*lbounds=*/{},
- /*takeLboundsIfRealloc=*/false,
- *lhsRealloc);
- }
+ genDataAssignment(assign, /*userDefinedAssignment=*/nullptr,
+ dirs);
},
-
- // [2] User defined assignment. If the context is a scalar
- // expression then call the procedure.
[&](const Fortran::evaluate::ProcedureRef &procRef) {
- Fortran::lower::StatementContext &ctx =
- explicitIterationSpace() ? explicitIterSpace.stmtContext()
- : stmtCtx;
- Fortran::lower::createSubroutineCall(
- *this, procRef, explicitIterSpace, implicitIterSpace,
- localSymbols, ctx, /*isUserDefAssignment=*/true);
+ genDataAssignment(assign, /*userDefinedAssignment=*/&procRef,
+ dirs);
},
-
[&](const Fortran::evaluate::Assignment::BoundsSpec &lbExprs) {
- return genNoHLFIRPointerAssignment(loc, assign, lbExprs);
+ genPointerAssignment(loc, assign);
},
[&](const Fortran::evaluate::Assignment::BoundsRemapping
- &boundExprs) {
- return genNoHLFIRPointerAssignment(loc, assign, boundExprs);
- },
+ &boundExprs) { genPointerAssignment(loc, assign); },
},
assign.u);
- if (explicitIterationSpace())
- Fortran::lower::createArrayMergeStores(*this, explicitIterSpace);
}
// Is the insertion point of the builder directly or indirectly set
@@ -6085,26 +5661,17 @@ class FirConverter : public Fortran::lower::AbstractConverter {
void genFIR(const Fortran::parser::WhereConstruct &c) {
setCurrentPositionAt(c);
mlir::Location loc = getCurrentLocation();
- hlfir::WhereOp whereOp;
-
- if (!lowerToHighLevelFIR()) {
- implicitIterSpace.growStack();
- } else {
- whereOp = hlfir::WhereOp::create(*builder, loc);
- builder->createBlock(&whereOp.getMaskRegion());
- }
+ auto whereOp = hlfir::WhereOp::create(*builder, loc);
+ builder->createBlock(&whereOp.getMaskRegion());
- // Lower the where mask. For HLFIR, this is done in the hlfir.where mask
- // region.
+ // Lower the where mask in the hlfir.where mask region.
genNestedStatement(
std::get<
Fortran::parser::Statement<Fortran::parser::WhereConstructStmt>>(
c.t));
- // Lower WHERE body. For HLFIR, this is done in the hlfir.where body
- // region.
- if (whereOp)
- builder->createBlock(&whereOp.getBody());
+ // Lower WHERE body in the hlfir.where body region.
+ builder->createBlock(&whereOp.getBody());
for (const auto &body :
std::get<std::list<Fortran::parser::WhereBodyConstruct>>(c.t))
@@ -6122,12 +5689,10 @@ class FirConverter : public Fortran::lower::AbstractConverter {
std::get<Fortran::parser::Statement<Fortran::parser::EndWhereStmt>>(
c.t));
- if (whereOp) {
- // For HLFIR, create fir.end terminator in the last hlfir.elsewhere, or
- // in the hlfir.where if it had no elsewhere.
- fir::FirEndOp::create(*builder, loc);
- builder->setInsertionPointAfter(whereOp);
- }
+ // Create fir.end terminator in the last hlfir.elsewhere, or in the
+ // hlfir.where if it had no elsewhere.
+ fir::FirEndOp::create(*builder, loc);
+ builder->setInsertionPointAfter(whereOp);
}
void genFIR(const Fortran::parser::WhereBodyConstruct &body) {
Fortran::common::visit(
@@ -6159,28 +5724,21 @@ class FirConverter : public Fortran::lower::AbstractConverter {
void genFIR(const Fortran::parser::WhereConstructStmt &stmt) {
const Fortran::semantics::SomeExpr *maskExpr = Fortran::semantics::GetExpr(
std::get<Fortran::parser::LogicalExpr>(stmt.t));
- if (lowerToHighLevelFIR())
- lowerWhereMaskToHlfir(getCurrentLocation(), maskExpr);
- else
- implicitIterSpace.append(maskExpr);
+ lowerWhereMaskToHlfir(getCurrentLocation(), maskExpr);
}
void genFIR(const Fortran::parser::WhereConstruct::MaskedElsewhere &ew) {
setCurrentPositionAt(ew);
mlir::Location loc = getCurrentLocation();
- hlfir::ElseWhereOp elsewhereOp;
- if (lowerToHighLevelFIR()) {
- elsewhereOp = hlfir::ElseWhereOp::create(*builder, loc);
- // Lower mask in the mask region.
- builder->createBlock(&elsewhereOp.getMaskRegion());
- }
+ auto elsewhereOp = hlfir::ElseWhereOp::create(*builder, loc);
+ // Lower mask in the mask region.
+ builder->createBlock(&elsewhereOp.getMaskRegion());
genNestedStatement(
std::get<
Fortran::parser::Statement<Fortran::parser::MaskedElsewhereStmt>>(
ew.t));
- // For HLFIR, lower the body in the hlfir.elsewhere body region.
- if (elsewhereOp)
- builder->createBlock(&elsewhereOp.getBody());
+ // Lower the body in the hlfir.elsewhere body region.
+ builder->createBlock(&elsewhereOp.getBody());
for (const auto &body :
std::get<std::list<Fortran::parser::WhereBodyConstruct>>(ew.t))
@@ -6189,18 +5747,13 @@ class FirConverter : public Fortran::lower::AbstractConverter {
void genFIR(const Fortran::parser::MaskedElsewhereStmt &stmt) {
const auto *maskExpr = Fortran::semantics::GetExpr(
std::get<Fortran::parser::LogicalExpr>(stmt.t));
- if (lowerToHighLevelFIR())
- lowerWhereMaskToHlfir(getCurrentLocation(), maskExpr);
- else
- implicitIterSpace.append(maskExpr);
+ lowerWhereMaskToHlfir(getCurrentLocation(), maskExpr);
}
void genFIR(const Fortran::parser::WhereConstruct::Elsewhere &ew) {
setCurrentPositionAt(ew);
- if (lowerToHighLevelFIR()) {
- auto elsewhereOp =
- hlfir::ElseWhereOp::create(*builder, getCurrentLocation());
- builder->createBlock(&elsewhereOp.getBody());
- }
+ auto elsewhereOp =
+ hlfir::ElseWhereOp::create(*builder, getCurrentLocation());
+ builder->createBlock(&elsewhereOp.getBody());
genNestedStatement(
std::get<Fortran::parser::Statement<Fortran::parser::ElsewhereStmt>>(
ew.t));
@@ -6208,35 +5761,22 @@ class FirConverter : public Fortran::lower::AbstractConverter {
std::get<std::list<Fortran::parser::WhereBodyConstruct>>(ew.t))
genFIR(body);
}
- void genFIR(const Fortran::parser::ElsewhereStmt &stmt) {
- if (!lowerToHighLevelFIR())
- implicitIterSpace.append(nullptr);
- }
- void genFIR(const Fortran::parser::EndWhereStmt &) {
- if (!lowerToHighLevelFIR())
- implicitIterSpace.shrinkStack();
- }
+ void genFIR(const Fortran::parser::ElsewhereStmt &stmt) {}
+ void genFIR(const Fortran::parser::EndWhereStmt &) {}
void genFIR(const Fortran::parser::WhereStmt &stmt) {
Fortran::lower::StatementContext stmtCtx;
const auto &assign = std::get<Fortran::parser::AssignmentStmt>(stmt.t);
const auto *mask = Fortran::semantics::GetExpr(
std::get<Fortran::parser::LogicalExpr>(stmt.t));
- if (lowerToHighLevelFIR()) {
- mlir::Location loc = getCurrentLocation();
- auto whereOp = hlfir::WhereOp::create(*builder, loc);
- builder->createBlock(&whereOp.getMaskRegion());
- lowerWhereMaskToHlfir(loc, mask);
- builder->createBlock(&whereOp.getBody());
- genAssignment(*assign.typedAssignment->v);
- fir::FirEndOp::create(*builder, loc);
- builder->setInsertionPointAfter(whereOp);
- return;
- }
- implicitIterSpace.growStack();
- implicitIterSpace.append(mask);
+ mlir::Location loc = getCurrentLocation();
+ auto whereOp = hlfir::WhereOp::create(*builder, loc);
+ builder->createBlock(&whereOp.getMaskRegion());
+ lowerWhereMaskToHlfir(loc, mask);
+ builder->createBlock(&whereOp.getBody());
genAssignment(*assign.typedAssignment->v);
- implicitIterSpace.shrinkStack();
+ fir::FirEndOp::create(*builder, loc);
+ builder->setInsertionPointAfter(whereOp);
}
void genFIR(const Fortran::parser::PointerAssignmentStmt &stmt) {
@@ -6482,7 +6022,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
// Always generate fir.dummy_scope even if there are no arguments.
// It is currently used to create proper TBAA forest.
- if (lowerToHighLevelFIR()) {
+ {
mlir::Value scopeOp = fir::DummyScopeOp::create(*builder, toLocation());
setDummyArgsScope(scopeOp);
}
@@ -7272,10 +6812,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
void createRuntimeTypeInfoGlobals() {}
- bool lowerToHighLevelFIR() const {
- return bridge.getLoweringOptions().getLowerToHighLevelFIR();
- }
-
// Returns the mangling prefix for the given constant expression.
std::string getConstantExprManglePrefix(mlir::Location loc,
const Fortran::lower::SomeExpr &expr,
diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp
index cd94f4d363061..e9059581c690a 100644
--- a/flang/lib/Lower/CallInterface.cpp
+++ b/flang/lib/Lower/CallInterface.cpp
@@ -226,8 +226,7 @@ Fortran::lower::CallerInterface::characterize() const {
// ProcedureDesignator has no interface, or may mismatch in case of implicit
// interface.
if (!characteristic->HasExplicitInterface() ||
- (converter.getLoweringOptions().getLowerToHighLevelFIR() &&
- isExternalDefinedInSameCompilationUnit(procRef.proc()) &&
+ (isExternalDefinedInSameCompilationUnit(procRef.proc()) &&
characteristic->CanBeCalledViaImplicitInterface())) {
// In HLFIR lowering, calls to subprogram with implicit interfaces are
// always prepared according to the actual arguments. This is to support
@@ -1173,9 +1172,6 @@ class Fortran::lower::CallInterfaceImpl {
addPassedArg(PassEntityBy::MutableBox, entity, characteristics);
} else if (obj.IsPassedByDescriptor(isBindC)) {
// Pass as fir.box or fir.class
- if (isValueAttr &&
- !getConverter().getLoweringOptions().getLowerToHighLevelFIR())
- TODO(loc, "assumed shape dummy argument with VALUE attribute");
addFirOperand(boxType, nextPassedArgPosition(), Property::Box, attrs);
addPassedArg(PassEntityBy::Box, entity, characteristics);
} else if (dynamicType.category() ==
@@ -1233,11 +1229,6 @@ class Fortran::lower::CallInterfaceImpl {
const DummyCharacteristics *characteristics,
const Fortran::evaluate::characteristics::DummyProcedure &proc,
const FortranEntity &entity) {
- if (!interface.converter.getLoweringOptions().getLowerToHighLevelFIR() &&
- proc.attrs.test(
- Fortran::evaluate::characteristics::DummyProcedure::Attr::Pointer))
- TODO(interface.converter.getCurrentLocation(),
- "procedure pointer arguments");
const Fortran::evaluate::characteristics::Procedure &procedure =
proc.procedure.value();
mlir::Type funcType =
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index d9204976ea7d3..e6c89122bde23 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -145,12 +145,11 @@ static bool mustCastFuncOpToCopeWithImplicitInterfaceMismatch(
// mismatch on the arguments. The argument are always prepared according
// to the implicit interface. Cast the actual function if any of the
// argument mismatch cannot be dealt with a simple fir.convert.
- if (converter.getLoweringOptions().getLowerToHighLevelFIR())
- for (auto [actualType, dummyType] :
- llvm::zip(callSiteType.getInputs(), funcOpType.getInputs()))
- if (actualType != dummyType &&
- !fir::ConvertOp::canBeConverted(actualType, dummyType))
- return true;
+ for (auto [actualType, dummyType] :
+ llvm::zip(callSiteType.getInputs(), funcOpType.getInputs()))
+ if (actualType != dummyType &&
+ !fir::ConvertOp::canBeConverted(actualType, dummyType))
+ return true;
return false;
}
@@ -408,7 +407,6 @@ Fortran::lower::genCallOpAndResult(
}
}
const bool isExprCall =
- converter.getLoweringOptions().getLowerToHighLevelFIR() &&
callSiteType.getNumResults() == 1 &&
llvm::isa<fir::SequenceType>(callSiteType.getResult(0));
@@ -622,8 +620,6 @@ Fortran::lower::genCallOpAndResult(
// With the lowering to HLFIR, box arguments have already been built
// according to the attributes, rank, bounds, and type they should have.
// Do not attempt any reboxing here that could break this.
- bool legacyLowering =
- !converter.getLoweringOptions().getLowerToHighLevelFIR();
// When dealing with a dummy character argument (fir.boxchar), the
// effective argument might be a non-character raw pointer. This may
// happen when calling an implicit interface that was previously called
@@ -635,7 +631,7 @@ Fortran::lower::genCallOpAndResult(
cast = builder.createVolatileCast(loc, isVolatile, fst);
cast = builder.convertWithSemantics(loc, snd, cast,
allowCharacterConversions,
- /*allowRebox=*/legacyLowering);
+ /*allowRebox=*/false);
}
}
operands.push_back(cast);
@@ -845,9 +841,7 @@ Fortran::lower::genCallOpAndResult(
// In HLFIR, this is skipped when the result does not need to be finalized
// because the result is moved to an expression that will deal with the
// finalization.
- if (allocatedResult &&
- (mustFinalizeResult ||
- !converter.getLoweringOptions().getLowerToHighLevelFIR())) {
+ if (allocatedResult && mustFinalizeResult) {
// The result must be optionally destroyed (if it is of a derived type
// that may need finalization or deallocation of the components).
// For an allocatable result we have to free the memory allocated
diff --git a/flang/lib/Lower/ConvertConstant.cpp b/flang/lib/Lower/ConvertConstant.cpp
index 0feb78e7fe9a1..41d8703bfc8e1 100644
--- a/flang/lib/Lower/ConvertConstant.cpp
+++ b/flang/lib/Lower/ConvertConstant.cpp
@@ -497,18 +497,6 @@ static mlir::Value genInlinedStructureCtorLitImpl(
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
auto recTy = mlir::cast<fir::RecordType>(type);
- if (!converter.getLoweringOptions().getLowerToHighLevelFIR()) {
- mlir::Value res = fir::UndefOp::create(builder, loc, recTy);
- for (const auto &[sym, expr] : ctor.values()) {
- // Parent components need more work because they do not appear in the
- // fir.rec type.
- if (sym->test(Fortran::semantics::Symbol::Flag::ParentComp))
- TODO(loc, "parent component in structure constructor");
- res = genStructureComponentInit(converter, loc, sym, expr.value(), res);
- }
- return res;
- }
-
auto fieldTy = fir::FieldType::get(recTy.getContext());
mlir::Value res{};
// When the first structure component values belong to some parent type PT
diff --git a/flang/lib/Lower/ConvertType.cpp b/flang/lib/Lower/ConvertType.cpp
index 0d343968374f0..d2a5a978756fd 100644
--- a/flang/lib/Lower/ConvertType.cpp
+++ b/flang/lib/Lower/ConvertType.cpp
@@ -409,7 +409,7 @@ struct TypeBuilderImpl {
// Gather the record type fields.
// (1) The data components.
- if (converter.getLoweringOptions().getLowerToHighLevelFIR()) {
+ {
size_t prev_offset{0};
unsigned padCounter{0};
// In HLFIR the parent component is the first fir.type component.
@@ -454,34 +454,6 @@ struct TypeBuilderImpl {
}
}
}
- } else {
- for (const auto &component :
- Fortran::semantics::OrderedComponentIterator(tySpec)) {
- // In the lowering to FIR the parent component does not appear in the
- // fir.type and its components are inlined at the beginning of the
- // fir.type<>.
- // FIXME: this strategy leads to bugs because padding should be inserted
- // after the component of the parents so that the next components do not
- // end-up in the parent storage if the sum of the parent's component
- // storage size is not a multiple of the parent type storage alignment.
-
- // Lowering is assuming non deferred component lower bounds are
- // always 1. Catch any situations where this is not true for now.
- if (componentHasNonDefaultLowerBounds(component))
- TODO(converter.genLocation(component.name()),
- "derived type components with non default lower bounds");
- if (IsProcedure(component))
- TODO(converter.genLocation(component.name()), "procedure components");
- mlir::Type ty = genSymbolType(component);
- // Do not add the parent component (component of the parents are
- // added and should be sufficient, the parent component would
- // duplicate the fields). Note that genSymbolType must be called above
- // on it so that the dispatch table for the parent type still gets
- // emitted as needed.
- if (component.test(Fortran::semantics::Symbol::Flag::ParentComp))
- continue;
- cs.emplace_back(converter.getRecordTypeFieldName(component), ty);
- }
}
mlir::Location loc = converter.genLocation(typeSymbol.name());
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index 59abdb92e33ba..a18b204f75403 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -66,15 +66,10 @@ static mlir::Value genScalarValue(Fortran::lower::AbstractConverter &converter,
Fortran::lower::StatementContext &context) {
// This does not use the AbstractConverter member function to override the
// symbol mapping to be used expression lowering.
- if (converter.getLoweringOptions().getLowerToHighLevelFIR()) {
- hlfir::EntityWithAttributes loweredExpr =
- Fortran::lower::convertExprToHLFIR(loc, converter, expr, symMap,
- context);
- return hlfir::loadTrivialScalar(loc, converter.getFirOpBuilder(),
- loweredExpr);
- }
- return fir::getBase(Fortran::lower::createSomeExtendedExpression(
- loc, converter, expr, symMap, context));
+ hlfir::EntityWithAttributes loweredExpr =
+ Fortran::lower::convertExprToHLFIR(loc, converter, expr, symMap, context);
+ return hlfir::loadTrivialScalar(loc, converter.getFirOpBuilder(),
+ loweredExpr);
}
/// Does this variable have a default initialization?
@@ -255,11 +250,8 @@ fir::ExtendedValue Fortran::lower::genExtAddrInInitializer(
storeMap);
}
- if (converter.getLoweringOptions().getLowerToHighLevelFIR())
- return Fortran::lower::convertExprToAddress(loc, converter, addr,
- globalOpSymMap, stmtCtx);
- return Fortran::lower::createInitializerAddress(loc, converter, addr,
- globalOpSymMap, stmtCtx);
+ return Fortran::lower::convertExprToAddress(loc, converter, addr,
+ globalOpSymMap, stmtCtx);
}
/// create initial-data-target fir.box in a global initializer region.
@@ -326,23 +318,11 @@ mlir::Value Fortran::lower::genInitialDataTarget(
mlir::Value targetBox;
mlir::Value targetShift;
- if (converter.getLoweringOptions().getLowerToHighLevelFIR()) {
+ {
auto target = Fortran::lower::convertExprToBox(
loc, converter, initialTarget, globalOpSymMap, stmtCtx);
targetBox = fir::getBase(target);
targetShift = builder.createShape(loc, target);
- } else {
- if (initialTarget.Rank() > 0) {
- auto target = Fortran::lower::createSomeArrayBox(converter, initialTarget,
- globalOpSymMap, stmtCtx);
- targetBox = fir::getBase(target);
- targetShift = builder.createShape(loc, target);
- } else {
- fir::ExtendedValue addr = Fortran::lower::createInitializerAddress(
- loc, converter, initialTarget, globalOpSymMap, stmtCtx);
- targetBox = builder.createBox(loc, addr);
- // Nothing to do for targetShift, the target is a scalar.
- }
}
// The targetBox is a fir.box<T>, not a fir.box<fir.ptr<T>> as it should for
// pointers (this matters to get the POINTER attribute correctly inside the
@@ -446,36 +426,21 @@ static mlir::Value genDefaultInitializerValue(
const Fortran::semantics::DeclTypeSpec *declTy = sym.GetType();
assert(declTy && "var with default initialization must have a type");
- if (converter.getLoweringOptions().getLowerToHighLevelFIR()) {
- // In HLFIR, the parent type is the first component, while in FIR there is
- // not parent component in the fir.type and the component of the parent are
- // "inlined" at the beginning of the fir.type.
- const Fortran::semantics::Symbol &typeSymbol =
- declTy->derivedTypeSpec().typeSymbol();
- const Fortran::semantics::Scope *derivedScope =
- declTy->derivedTypeSpec().GetScope();
- assert(derivedScope && "failed to retrieve derived type scope");
- for (const auto &componentName :
- typeSymbol.get<Fortran::semantics::DerivedTypeDetails>()
- .componentNames()) {
- auto scopeIter = derivedScope->find(componentName);
- assert(scopeIter != derivedScope->cend() &&
- "failed to find derived type component symbol");
- const Fortran::semantics::Symbol &component = scopeIter->second.get();
- initialValue = genComponentDefaultInit(converter, loc, component, recTy,
- initialValue, stmtCtx);
- }
- } else {
- Fortran::semantics::OrderedComponentIterator components(
- declTy->derivedTypeSpec());
- for (const auto &component : components) {
- // Skip parent components, the sub-components of parent types are part of
- // components and will be looped through right after.
- if (component.test(Fortran::semantics::Symbol::Flag::ParentComp))
- continue;
- initialValue = genComponentDefaultInit(converter, loc, component, recTy,
- initialValue, stmtCtx);
- }
+ // In HLFIR, the parent type is the first component of the fir.type.
+ const Fortran::semantics::Symbol &typeSymbol =
+ declTy->derivedTypeSpec().typeSymbol();
+ const Fortran::semantics::Scope *derivedScope =
+ declTy->derivedTypeSpec().GetScope();
+ assert(derivedScope && "failed to retrieve derived type scope");
+ for (const auto &componentName :
+ typeSymbol.get<Fortran::semantics::DerivedTypeDetails>()
+ .componentNames()) {
+ auto scopeIter = derivedScope->find(componentName);
+ assert(scopeIter != derivedScope->cend() &&
+ "failed to find derived type component symbol");
+ const Fortran::semantics::Symbol &component = scopeIter->second.get();
+ initialValue = genComponentDefaultInit(converter, loc, component, recTy,
+ initialValue, stmtCtx);
}
if (sequenceType) {
@@ -544,10 +509,6 @@ fir::GlobalOp Fortran::lower::defineGlobal(
if (global && globalIsInitialized(global))
return global;
- if (!converter.getLoweringOptions().getLowerToHighLevelFIR() &&
- Fortran::semantics::IsProcedurePointer(sym))
- TODO(loc, "procedure pointer globals");
-
const auto *oeDetails =
sym.detailsIf<Fortran::semantics::ObjectEntityDetails>();
@@ -1928,8 +1889,7 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,
// Commonblock names are not variables, but in some lowerings (like OpenMP) it
// is useful to maintain the address of the commonblock in an MLIR value and
// query it. hlfir.declare need not be created for these.
- if (converter.getLoweringOptions().getLowerToHighLevelFIR() &&
- (!Fortran::semantics::IsProcedure(sym) ||
+ if ((!Fortran::semantics::IsProcedure(sym) ||
Fortran::semantics::IsPointer(sym)) &&
!sym.detailsIf<Fortran::semantics::CommonBlockDetails>()) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
@@ -2036,8 +1996,7 @@ void Fortran::lower::genDeclareSymbol(
Fortran::lower::SymMap &symMap, const Fortran::semantics::Symbol &sym,
const fir::ExtendedValue &exv, fir::FortranVariableFlagsEnum extraFlags,
bool force) {
- if (converter.getLoweringOptions().getLowerToHighLevelFIR() &&
- (!Fortran::semantics::IsProcedure(sym) ||
+ if ((!Fortran::semantics::IsProcedure(sym) ||
Fortran::semantics::IsPointer(sym.GetUltimate())) &&
!sym.detailsIf<Fortran::semantics::CommonBlockDetails>()) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
@@ -2080,10 +2039,6 @@ genAllocatableOrPointerDeclare(Fortran::lower::AbstractConverter &converter,
Fortran::lower::SymMap &symMap,
const Fortran::semantics::Symbol &sym,
fir::MutableBoxValue box, bool force = false) {
- if (!converter.getLoweringOptions().getLowerToHighLevelFIR()) {
- symMap.addAllocatableOrPointer(sym, box, force);
- return;
- }
assert(!box.isDescribedByVariables() &&
"HLFIR alloctables/pointers must be fir.ref<fir.box>");
mlir::Value base = box.getAddr();
@@ -2118,15 +2073,10 @@ static void genBoxDeclare(Fortran::lower::AbstractConverter &converter,
llvm::ArrayRef<mlir::Value> explicitParams,
llvm::ArrayRef<mlir::Value> explicitExtents,
bool replace = false) {
- if (converter.getLoweringOptions().getLowerToHighLevelFIR()) {
- fir::BoxValue boxValue{box, lbounds, explicitParams, explicitExtents};
- Fortran::lower::genDeclareSymbol(
- converter, symMap, sym, std::move(boxValue),
- fir::FortranVariableFlagsEnum::None, replace);
- return;
- }
- symMap.addBoxSymbol(sym, box, lbounds, explicitParams, explicitExtents,
- replace);
+ fir::BoxValue boxValue{box, lbounds, explicitParams, explicitExtents};
+ Fortran::lower::genDeclareSymbol(
+ converter, symMap, sym, std::move(boxValue),
+ fir::FortranVariableFlagsEnum::None, replace);
}
/// Lower specification expressions and attributes of variable \p var and
@@ -2221,8 +2171,7 @@ void Fortran::lower::mapSymbolAttributes(
}
fir::MutableBoxValue box = Fortran::lower::createMutableBox(
converter, loc, var, boxAlloc, nonDeferredLenParams,
- /*alwaysUseBox=*/
- converter.getLoweringOptions().getLowerToHighLevelFIR(),
+ /*alwaysUseBox=*/true,
Fortran::lower::getAllocatorIdx(var.getSymbol()));
genAllocatableOrPointerDeclare(converter, symMap, var.getSymbol(), box,
replace);
diff --git a/flang/lib/Lower/HostAssociations.cpp b/flang/lib/Lower/HostAssociations.cpp
index ad6aba1d28ae4..93d0d748197d2 100644
--- a/flang/lib/Lower/HostAssociations.cpp
+++ b/flang/lib/Lower/HostAssociations.cpp
@@ -74,11 +74,8 @@ static void bindCapturedSymbol(const Fortran::semantics::Symbol &sym,
fir::ExtendedValue val,
Fortran::lower::AbstractConverter &converter,
Fortran::lower::SymMap &symMap) {
- if (converter.getLoweringOptions().getLowerToHighLevelFIR())
- Fortran::lower::genDeclareSymbol(converter, symMap, sym, val,
- fir::FortranVariableFlagsEnum::host_assoc);
- else
- symMap.addSymbol(sym, val);
+ Fortran::lower::genDeclareSymbol(converter, symMap, sym, val,
+ fir::FortranVariableFlagsEnum::host_assoc);
}
namespace {
diff --git a/flang/test/Driver/frontend-forwarding.f90 b/flang/test/Driver/frontend-forwarding.f90
index e4cb0b6835a75..2cc5524d351ff 100644
--- a/flang/test/Driver/frontend-forwarding.f90
+++ b/flang/test/Driver/frontend-forwarding.f90
@@ -20,7 +20,6 @@
! RUN: -fomit-frame-pointer \
! RUN: -fpass-plugin=Bye%pluginext \
! RUN: -fversion-loops-for-stride \
-! RUN: -flang-experimental-hlfir \
! RUN: -fno-ppc-native-vector-element-order \
! RUN: -fppc-native-vector-element-order \
! RUN: -mllvm -print-before-all \
@@ -52,7 +51,6 @@
! CHECK: "-fconvert=little-endian"
! CHECK: "-fpass-plugin=Bye
! CHECK: "-fversion-loops-for-stride"
-! CHECK: "-flang-experimental-hlfir"
! CHECK: "-fno-ppc-native-vector-element-order"
! CHECK: "-fppc-native-vector-element-order"
! CHECK: "-Rpass"
diff --git a/flang/test/Driver/hlfir-no-hlfir-error.f90 b/flang/test/Driver/hlfir-no-hlfir-error.f90
deleted file mode 100644
index 59f8304db5c9a..0000000000000
--- a/flang/test/Driver/hlfir-no-hlfir-error.f90
+++ /dev/null
@@ -1,16 +0,0 @@
-! Test that -flang-experimental-hlfir and -flang-deprecated-no-hlfir
-! options cannot be both used.
-
-!--------------------------
-! FLANG DRIVER (flang)
-!--------------------------
-! RUN: not %flang -flang-experimental-hlfir -flang-deprecated-no-hlfir %s 2>&1 | FileCheck %s
-
-!-----------------------------------------
-! FRONTEND FLANG DRIVER (flang -fc1)
-!-----------------------------------------
-! RUN: not %flang_fc1 -emit-llvm -flang-experimental-hlfir -flang-deprecated-no-hlfir %s 2>&1 | FileCheck %s
-
-! CHECK:error: Options '-flang-experimental-hlfir' and '-flang-deprecated-no-hlfir' cannot be both specified
-
-end
diff --git a/flang/test/HLFIR/dummy_deallocation.f90 b/flang/test/HLFIR/dummy_deallocation.f90
index 9d3c51c843bcc..6b9b3020edd6f 100644
--- a/flang/test/HLFIR/dummy_deallocation.f90
+++ b/flang/test/HLFIR/dummy_deallocation.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-fir -hlfir %s -o - | FileCheck %s
+! RUN: bbc -emit-fir %s -o - | FileCheck %s
! RUN: bbc -emit-fir %s -o - | FileCheck %s
! Test that the intent(out) allocatable dummy argument
diff --git a/flang/test/HLFIR/hlfir-flags.f90 b/flang/test/HLFIR/hlfir-flags.f90
index 50f1abf871444..0311a25a9d796 100644
--- a/flang/test/HLFIR/hlfir-flags.f90
+++ b/flang/test/HLFIR/hlfir-flags.f90
@@ -1,11 +1,7 @@
-! Test -flang-deprecated-hlfir, -flang-experimental-hlfir (flang), and
-! -hlfir (bbc), -emit-hlfir, -emit-fir flags
+! Test -emit-hlfir, -emit-fir flags
! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck --check-prefix HLFIR --check-prefix ALL %s
! RUN: bbc -emit-hlfir -o - %s | FileCheck --check-prefix HLFIR --check-prefix ALL %s
-! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck --check-prefix HLFIR --check-prefix ALL %s
-! RUN: bbc -emit-hlfir -hlfir -o - %s | FileCheck --check-prefix HLFIR --check-prefix ALL %s
! RUN: %flang_fc1 -emit-fir -o - %s | FileCheck --check-prefix FIR --check-prefix ALL %s
-! RUN: %flang_fc1 -emit-fir -flang-experimental-hlfir -o - %s | FileCheck %s --check-prefix FIR --check-prefix ALL
! RUN: bbc -emit-fir -o - %s | FileCheck --check-prefix FIR --check-prefix ALL %s
! | Action | Result |
diff --git a/flang/test/HLFIR/inline-elemental.f90 b/flang/test/HLFIR/inline-elemental.f90
index 4e91cc70ede22..2c3f4fdf1da77 100644
--- a/flang/test/HLFIR/inline-elemental.f90
+++ b/flang/test/HLFIR/inline-elemental.f90
@@ -1,4 +1,4 @@
-! RUN: %flang_fc1 -emit-obj -flang-experimental-hlfir -o /dev/null %s
+! RUN: %flang_fc1 -emit-obj -o /dev/null %s
! Regression test: ensure we can compile this without crashing
! this results in a hlfir.elemental with mismatched types in the hlfir.apply
diff --git a/flang/test/HLFIR/no-block-merging.fir b/flang/test/HLFIR/no-block-merging.fir
index 02deb0cc6c4e5..a08ad448db484 100644
--- a/flang/test/HLFIR/no-block-merging.fir
+++ b/flang/test/HLFIR/no-block-merging.fir
@@ -1,7 +1,7 @@
// Test that the HLFIR pipeline does not call MLIR canonicalizer with block
// merging enabled (moving fir.shape to block argument would cause failures
// when translating the FIR to LLVM).
-// RUN: %flang_fc1 %s -flang-experimental-hlfir -emit-llvm -O2 -o - | FileCheck %s
+// RUN: %flang_fc1 %s -emit-llvm -O2 -o - | FileCheck %s
func.func @no_shape_merge(%cdt: i1, %from: !fir.ref<!fir.array<?xf64>>, %to : !fir.ref<f64>) {
%c10 = arith.constant 10 : index
diff --git a/flang/test/HLFIR/order_assignments/forall-fusing-scheduling.f90 b/flang/test/HLFIR/order_assignments/forall-fusing-scheduling.f90
index 2ebbebd235521..ded3a593f7eed 100644
--- a/flang/test/HLFIR/order_assignments/forall-fusing-scheduling.f90
+++ b/flang/test/HLFIR/order_assignments/forall-fusing-scheduling.f90
@@ -2,9 +2,9 @@
! from lower-hlfir-ordered-assignments pass. Assignments are fused in the
! same loop nest if they are given the same run id.
-! RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=false})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix NOFUSE
+! RUN: bbc -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=false})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix NOFUSE
-! RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=true})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix FUSE
+! RUN: bbc -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=true})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix FUSE
! REQUIRES: asserts
diff --git a/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling-bounds.f90 b/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling-bounds.f90
index 00c94d25e7b11..7d146fcc60a66 100644
--- a/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling-bounds.f90
+++ b/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling-bounds.f90
@@ -4,7 +4,7 @@
! by the pointer assignments, or if the forall can be lowered into a single
! loop without any temporary copy.
-! RUN: bbc -hlfir -o /dev/null -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" \
+! RUN: bbc -o /dev/null -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" \
! RUN: --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s
! REQUIRES: asserts
module forall_pointers_bounds
diff --git a/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling-polymorphic.f90 b/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling-polymorphic.f90
index 9ccba7acc1b08..4f8d08543ab3b 100644
--- a/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling-polymorphic.f90
+++ b/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling-polymorphic.f90
@@ -3,7 +3,7 @@
! by the pointer assignments, or if the forall can be lowered into a single
! loop without any temporary copy.
-! RUN: bbc -hlfir -o /dev/null -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" \
+! RUN: bbc -o /dev/null -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" \
! RUN: --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s
! REQUIRES: asserts
module forall_poly_pointers
diff --git a/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling.f90 b/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling.f90
index fc2ef5248e410..73b147a25048f 100644
--- a/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling.f90
+++ b/flang/test/HLFIR/order_assignments/forall-pointer-assignment-scheduling.f90
@@ -3,7 +3,7 @@
! by the pointer assignments, or if the forall can be lowered into a single
! loop without any temporary copy.
-! RUN: bbc -hlfir -o /dev/null -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" \
+! RUN: bbc -o /dev/null -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" \
! RUN: --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s
! REQUIRES: asserts
module forall_pointers
diff --git a/flang/test/HLFIR/order_assignments/forall-proc-pointer-assignment-scheduling-character.f90 b/flang/test/HLFIR/order_assignments/forall-proc-pointer-assignment-scheduling-character.f90
index ff7f70bac1513..5922df66b65c9 100644
--- a/flang/test/HLFIR/order_assignments/forall-proc-pointer-assignment-scheduling-character.f90
+++ b/flang/test/HLFIR/order_assignments/forall-proc-pointer-assignment-scheduling-character.f90
@@ -2,7 +2,7 @@
! Character procedure gets their own tests because they are tracked differently
! in FIR because of the length of the function result.
-! RUN: bbc -hlfir -o /dev/null -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" \
+! RUN: bbc -o /dev/null -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" \
! RUN: --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only -I nw %s 2>&1 | FileCheck %s
! REQUIRES: asserts
diff --git a/flang/test/HLFIR/order_assignments/forall-proc-pointer-assignment-scheduling.f90 b/flang/test/HLFIR/order_assignments/forall-proc-pointer-assignment-scheduling.f90
index 0cce790470cb4..24c561ce2ff47 100644
--- a/flang/test/HLFIR/order_assignments/forall-proc-pointer-assignment-scheduling.f90
+++ b/flang/test/HLFIR/order_assignments/forall-proc-pointer-assignment-scheduling.f90
@@ -1,6 +1,6 @@
! Test analysis of procedure pointer assignments inside FORALL.
-! RUN: bbc -hlfir -o /dev/null -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" \
+! RUN: bbc -o /dev/null -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" \
! RUN: --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only -I nw %s 2>&1 | FileCheck %s
! REQUIRES: asserts
diff --git a/flang/test/HLFIR/order_assignments/forall-scheduling.f90 b/flang/test/HLFIR/order_assignments/forall-scheduling.f90
index 0af38786195e1..4ce11ae1acf2b 100644
--- a/flang/test/HLFIR/order_assignments/forall-scheduling.f90
+++ b/flang/test/HLFIR/order_assignments/forall-scheduling.f90
@@ -3,7 +3,7 @@
! This test test that conflicting actions are not scheduled to be evaluated
! in the same loops (same run id).
-! RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s
+! RUN: bbc -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s
! REQUIRES: asserts
subroutine no_conflict(x)
diff --git a/flang/test/HLFIR/order_assignments/where-array-sections.f90 b/flang/test/HLFIR/order_assignments/where-array-sections.f90
index aab264d6e105e..41c5b586b889c 100644
--- a/flang/test/HLFIR/order_assignments/where-array-sections.f90
+++ b/flang/test/HLFIR/order_assignments/where-array-sections.f90
@@ -1,8 +1,8 @@
! Test scheduling of WHERE with aligned array sections.
-!RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=false})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix NOFUSE
+!RUN: bbc -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=false})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix NOFUSE
-!RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=true})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix FUSE
+!RUN: bbc -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=true})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix FUSE
!REQUIRES: asserts
diff --git a/flang/test/HLFIR/order_assignments/where-fusing-scheduling.f90 b/flang/test/HLFIR/order_assignments/where-fusing-scheduling.f90
index 1de457f974508..f030ad7685be5 100644
--- a/flang/test/HLFIR/order_assignments/where-fusing-scheduling.f90
+++ b/flang/test/HLFIR/order_assignments/where-fusing-scheduling.f90
@@ -1,9 +1,9 @@
! Test scheduling of WHERE in lower-hlfir-ordered-assignments pass
! when fusing is enabled or disabled.
-!RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=false})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix NOFUSE
+!RUN: bbc -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=false})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix NOFUSE
-!RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=true})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix FUSE
+!RUN: bbc -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments{fuse-assignments=true})" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s --check-prefix FUSE
!REQUIRES: asserts
diff --git a/flang/test/HLFIR/order_assignments/where-hoisting.f90 b/flang/test/HLFIR/order_assignments/where-hoisting.f90
index 6ed2ecb3624b0..3a68945dc45d6 100644
--- a/flang/test/HLFIR/order_assignments/where-hoisting.f90
+++ b/flang/test/HLFIR/order_assignments/where-hoisting.f90
@@ -1,6 +1,6 @@
! Test that scalar expressions are not hoisted from WHERE loops
! when they do not appear
-! RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" %s | FileCheck %s
+! RUN: bbc -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" %s | FileCheck %s
subroutine do_not_hoist_div(n, mask, a)
integer :: a(10), n
diff --git a/flang/test/HLFIR/order_assignments/where-scheduling.f90 b/flang/test/HLFIR/order_assignments/where-scheduling.f90
index 496789334b84e..4d69862886c81 100644
--- a/flang/test/HLFIR/order_assignments/where-scheduling.f90
+++ b/flang/test/HLFIR/order_assignments/where-scheduling.f90
@@ -1,6 +1,6 @@
! Test scheduling of WHERE in lower-hlfir-ordered-assignments pass.
-! RUN: bbc -hlfir -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s
+! RUN: bbc -o - -pass-pipeline="builtin.module(lower-hlfir-ordered-assignments)" --debug-only=flang-ordered-assignment -flang-dbg-order-assignment-schedule-only %s 2>&1 | FileCheck %s
! REQUIRES: asserts
subroutine no_conflict(x, y)
diff --git a/flang/test/Lower/CUDA/cuda-devptr.cuf b/flang/test/Lower/CUDA/cuda-devptr.cuf
index b1126c6fd58af..924bfa55c7e5b 100644
--- a/flang/test/Lower/CUDA/cuda-devptr.cuf
+++ b/flang/test/Lower/CUDA/cuda-devptr.cuf
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-fir -hlfir -fcuda %s -o - | FileCheck %s
+! RUN: bbc -emit-fir -fcuda %s -o - | FileCheck %s
! Test CUDA Fortran specific type
diff --git a/flang/test/Lower/CUDA/cuda-init.cuf b/flang/test/Lower/CUDA/cuda-init.cuf
index 71ec1e3f9df56..7f58ec3c87dbf 100644
--- a/flang/test/Lower/CUDA/cuda-init.cuf
+++ b/flang/test/Lower/CUDA/cuda-init.cuf
@@ -1,5 +1,5 @@
-! RUN: bbc -emit-fir -hlfir -fcuda %s -o - | FileCheck %s --check-prefixes=ALL,CUDA
-! RUN: bbc -emit-fir -hlfir %s -o - | FileCheck %s --check-prefixes=ALL,NOCUDA
+! RUN: bbc -emit-fir -fcuda %s -o - | FileCheck %s --check-prefixes=ALL,CUDA
+! RUN: bbc -emit-fir %s -o - | FileCheck %s --check-prefixes=ALL,NOCUDA
program test_init
diff --git a/flang/test/Lower/CUDA/cuda-kernel-alloca-block.cuf b/flang/test/Lower/CUDA/cuda-kernel-alloca-block.cuf
index afad65bb3138c..c5e78e022c4aa 100644
--- a/flang/test/Lower/CUDA/cuda-kernel-alloca-block.cuf
+++ b/flang/test/Lower/CUDA/cuda-kernel-alloca-block.cuf
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-fir -hlfir -fcuda %s -o - | FileCheck %s
+! RUN: bbc -emit-fir -fcuda %s -o - | FileCheck %s
module char1
diff --git a/flang/test/Lower/HLFIR/bindc-assumed-length.f90 b/flang/test/Lower/HLFIR/bindc-assumed-length.f90
index 2f0b1437535dd..38bbf9a1c7c6b 100644
--- a/flang/test/Lower/HLFIR/bindc-assumed-length.f90
+++ b/flang/test/Lower/HLFIR/bindc-assumed-length.f90
@@ -1,7 +1,7 @@
! Test that assumed length character scalars and explicit shape arrays are passed via
! CFI descriptor (fir.box) in BIND(C) procedures. They are passed only by address
! and length in non BIND(C) procedures. See Fortran 2018 standard 18.3.6 point 2(5).
-! RUN: bbc -hlfir -emit-fir -o - %s 2>&1 | FileCheck %s
+! RUN: bbc -emit-fir -o - %s 2>&1 | FileCheck %s
module bindcchar
contains
diff --git a/flang/test/Lower/HLFIR/expr-box.f90 b/flang/test/Lower/HLFIR/expr-box.f90
index 2cc46666b71fb..0f96eb91df34d 100644
--- a/flang/test/Lower/HLFIR/expr-box.f90
+++ b/flang/test/Lower/HLFIR/expr-box.f90
@@ -1,5 +1,5 @@
! Test lowering of of expressions as fir.box
-! RUN: bbc -hlfir -o - %s 2>&1 --use-hlfir-intrinsic-ops=false | FileCheck %s
+! RUN: bbc -o - %s 2>&1 --use-hlfir-intrinsic-ops=false | FileCheck %s
! CHECK-LABEL: func.func @_QPfoo(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>
diff --git a/flang/test/Lower/HLFIR/forall.f90 b/flang/test/Lower/HLFIR/forall.f90
index 709e233746a91..edcd7fa27f536 100644
--- a/flang/test/Lower/HLFIR/forall.f90
+++ b/flang/test/Lower/HLFIR/forall.f90
@@ -1,5 +1,5 @@
! Test lowering of Forall to HLFIR.
-! RUN: bbc --hlfir -o - %s | FileCheck %s
+! RUN: bbc -o - %s | FileCheck %s
module forall_defs
integer :: x(10, 10), y(10)
diff --git a/flang/test/Lower/HLFIR/goto-do-body.f90 b/flang/test/Lower/HLFIR/goto-do-body.f90
index 8a04e5465a81a..6a313d18bea0a 100644
--- a/flang/test/Lower/HLFIR/goto-do-body.f90
+++ b/flang/test/Lower/HLFIR/goto-do-body.f90
@@ -1,4 +1,4 @@
-! RUN: bbc --hlfir -o - %s | FileCheck %s
+! RUN: bbc -o - %s | FileCheck %s
! Test jumping to the body of a do loop.
subroutine sub1()
diff --git a/flang/test/Lower/HLFIR/tdesc-character-comp-init.f90 b/flang/test/Lower/HLFIR/tdesc-character-comp-init.f90
index 1ae312e8cc1c4..5c9c1e0180d03 100644
--- a/flang/test/Lower/HLFIR/tdesc-character-comp-init.f90
+++ b/flang/test/Lower/HLFIR/tdesc-character-comp-init.f90
@@ -1,7 +1,7 @@
! Test lowering of derived type descriptor for types with
! a default initialized character component.
-! RUN: bbc -emit-fir -hlfir -o - %s | FileCheck %s
+! RUN: bbc -emit-fir -o - %s | FileCheck %s
subroutine test()
type t
diff --git a/flang/test/Lower/HLFIR/type-bound-proc-tdesc.f90 b/flang/test/Lower/HLFIR/type-bound-proc-tdesc.f90
index fed2097b0c138..13bef681740f6 100644
--- a/flang/test/Lower/HLFIR/type-bound-proc-tdesc.f90
+++ b/flang/test/Lower/HLFIR/type-bound-proc-tdesc.f90
@@ -1,6 +1,6 @@
! Test lowering of type bound procedure in the derived type descriptors (that
! are compiler generated constant structure constructors).
-! RUN: bbc -emit-fir -hlfir -o - %s | FileCheck %s
+! RUN: bbc -emit-fir -o - %s | FileCheck %s
module type_bound_proc_tdesc
type :: t
diff --git a/flang/test/Lower/OpenACC/acc-atomic-update-hlfir.f90 b/flang/test/Lower/OpenACC/acc-atomic-update-hlfir.f90
index dc21550084d4a..d0682976c7181 100644
--- a/flang/test/Lower/OpenACC/acc-atomic-update-hlfir.f90
+++ b/flang/test/Lower/OpenACC/acc-atomic-update-hlfir.f90
@@ -1,5 +1,5 @@
! This test checks lowering of atomic and atomic update constructs with HLFIR
-! RUN: bbc -hlfir -fopenacc -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s
! RUN: %flang_fc1 -emit-hlfir -fopenacc %s -o - | FileCheck %s
!CHECK-LABEL: @_QPsb
diff --git a/flang/test/Lower/OpenMP/function-filtering-2.f90 b/flang/test/Lower/OpenMP/function-filtering-2.f90
index 34d910c53d6ea..6ced7851dd4ea 100644
--- a/flang/test/Lower/OpenMP/function-filtering-2.f90
+++ b/flang/test/Lower/OpenMP/function-filtering-2.f90
@@ -1,6 +1,6 @@
-! RUN: %flang_fc1 -fopenmp -fopenmp-version=52 -flang-experimental-hlfir -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM,LLVM-HOST %s
+! RUN: %flang_fc1 -fopenmp -fopenmp-version=52 -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM,LLVM-HOST %s
! RUN: %flang_fc1 -fopenmp -fopenmp-version=52 -emit-hlfir %s -o - | FileCheck --check-prefix=MLIR %s
-! RUN: %if amdgpu-registered-target %{ %flang_fc1 -triple amdgcn-amd-amdhsa -fopenmp -fopenmp-version=52 -fopenmp-is-target-device -flang-experimental-hlfir -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM,LLVM-DEVICE %s %}
+! RUN: %if amdgpu-registered-target %{ %flang_fc1 -triple amdgcn-amd-amdhsa -fopenmp -fopenmp-version=52 -fopenmp-is-target-device -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM,LLVM-DEVICE %s %}
! RUN: %if amdgpu-registered-target %{ %flang_fc1 -triple amdgcn-amd-amdhsa -fopenmp -fopenmp-version=52 -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck --check-prefix=MLIR %s %}
! RUN: bbc -fopenmp -fopenmp-version=52 -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-HOST,MLIR-ALL %s
! RUN: %if amdgpu-registered-target %{ bbc -target amdgcn-amd-amdhsa -fopenmp -fopenmp-version=52 -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-DEVICE,MLIR-ALL %s %}
diff --git a/flang/test/Lower/OpenMP/function-filtering-3.f90 b/flang/test/Lower/OpenMP/function-filtering-3.f90
index d25c3d6ee88b0..0257994b78201 100644
--- a/flang/test/Lower/OpenMP/function-filtering-3.f90
+++ b/flang/test/Lower/OpenMP/function-filtering-3.f90
@@ -1,6 +1,6 @@
-! RUN: %flang_fc1 -fopenmp -flang-experimental-hlfir -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM-HOST,LLVM-ALL %s
+! RUN: %flang_fc1 -fopenmp -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM-HOST,LLVM-ALL %s
! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-HOST,MLIR-ALL %s
-! RUN: %if amdgpu-registered-target %{ %flang_fc1 -triple amdgcn-amd-amdhsa -fopenmp -fopenmp-is-target-device -flang-experimental-hlfir -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM-DEVICE,LLVM-ALL %s %}
+! RUN: %if amdgpu-registered-target %{ %flang_fc1 -triple amdgcn-amd-amdhsa -fopenmp -fopenmp-is-target-device -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM-DEVICE,LLVM-ALL %s %}
! RUN: %if amdgpu-registered-target %{ %flang_fc1 -triple amdgcn-amd-amdhsa -fopenmp -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-DEVICE,MLIR-ALL %s %}
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-HOST,MLIR-ALL %s
! RUN: %if amdgpu-registered-target %{ bbc -target amdgcn-amd-amdhsa -fopenmp -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-DEVICE,MLIR-ALL %s %}
diff --git a/flang/test/Lower/OpenMP/function-filtering.f90 b/flang/test/Lower/OpenMP/function-filtering.f90
index da0547028af61..65dee4eb62332 100644
--- a/flang/test/Lower/OpenMP/function-filtering.f90
+++ b/flang/test/Lower/OpenMP/function-filtering.f90
@@ -1,6 +1,6 @@
-! RUN: %flang_fc1 -fopenmp -fopenmp-version=52 -flang-experimental-hlfir -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM-HOST,LLVM-ALL %s
+! RUN: %flang_fc1 -fopenmp -fopenmp-version=52 -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM-HOST,LLVM-ALL %s
! RUN: %flang_fc1 -fopenmp -fopenmp-version=52 -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-HOST,MLIR-ALL %s
-! RUN: %if amdgpu-registered-target %{ %flang_fc1 -triple amdgcn-amd-amdhsa -fopenmp -fopenmp-version=52 -fopenmp-is-target-device -flang-experimental-hlfir -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM-DEVICE,LLVM-ALL %s %}
+! RUN: %if amdgpu-registered-target %{ %flang_fc1 -triple amdgcn-amd-amdhsa -fopenmp -fopenmp-version=52 -fopenmp-is-target-device -emit-llvm %s -o - | FileCheck --check-prefixes=LLVM-DEVICE,LLVM-ALL %s %}
! RUN: %if amdgpu-registered-target %{ %flang_fc1 -triple amdgcn-amd-amdhsa -fopenmp -fopenmp-version=52 -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-DEVICE,MLIR-ALL %s %}
! RUN: bbc -fopenmp -fopenmp-version=52 -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-HOST,MLIR-ALL %s
! RUN: %if amdgpu-registered-target %{ bbc -target amdgcn-amd-amdhsa -fopenmp -fopenmp-version=52 -fopenmp-is-target-device -emit-hlfir %s -o - | FileCheck --check-prefixes=MLIR-DEVICE,MLIR-ALL %s %}
diff --git a/flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90 b/flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90
index 642b11bcd6b75..7324b3c49fd6f 100644
--- a/flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90
+++ b/flang/test/Lower/OpenMP/hlfir-seqloop-parallel.f90
@@ -4,7 +4,7 @@
! RUN: bbc -fopenmp -emit-hlfir %s -o - \
! RUN: | FileCheck %s
-! RUN: %flang_fc1 -emit-hlfir -flang-experimental-hlfir -fopenmp %s -o - \
+! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - \
! RUN: | FileCheck %s
diff --git a/flang/test/Lower/OpenMP/hlfir-wsloop.f90 b/flang/test/Lower/OpenMP/hlfir-wsloop.f90
index 786ab916d000c..28903a4a85d02 100644
--- a/flang/test/Lower/OpenMP/hlfir-wsloop.f90
+++ b/flang/test/Lower/OpenMP/hlfir-wsloop.f90
@@ -1,7 +1,7 @@
! This test checks lowering of OpenMP DO Directive with HLFIR.
-! RUN: bbc -hlfir -fopenmp -emit-fir %s -o - | FileCheck %s
-! RUN: %flang_fc1 -emit-fir -flang-experimental-hlfir -fopenmp %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
!CHECK-LABEL: func @_QPsimple_loop()
subroutine simple_loop
diff --git a/flang/test/Lower/OpenMP/sections.f90 b/flang/test/Lower/OpenMP/sections.f90
index 514a82d386948..a58227e4f5287 100644
--- a/flang/test/Lower/OpenMP/sections.f90
+++ b/flang/test/Lower/OpenMP/sections.f90
@@ -3,7 +3,7 @@
! This test checks the lowering of OpenMP sections construct with several clauses present
! RUN: %flang_fc1 -emit-hlfir %openmp_flags %s -o - | FileCheck %s
-! RUN: bbc -hlfir -emit-hlfir %openmp_flags %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir %openmp_flags %s -o - | FileCheck %s
!CHECK: func @_QQmain() attributes {fir.bindc_name = "SAMPLE"} {
!CHECK: %[[COUNT:.*]] = fir.address_of(@_QFEcount) : !fir.ref<i32>
diff --git a/flang/test/Lower/OpenMP/simd.f90 b/flang/test/Lower/OpenMP/simd.f90
index ff0bd6dd0a730..53eb6c70b05d7 100644
--- a/flang/test/Lower/OpenMP/simd.f90
+++ b/flang/test/Lower/OpenMP/simd.f90
@@ -4,8 +4,8 @@
! To prevent testing for unrelated clauses like implicit linear clause and focusing on the
! clauses of interest here, the OpenMP version is 6.0
-! RUN: %flang_fc1 -flang-experimental-hlfir -emit-hlfir -fopenmp -fopenmp-version=60 %s -o - | FileCheck %s
-! RUN: bbc -hlfir -emit-hlfir -fopenmp -fopenmp-version=60 %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=60 %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=60 %s -o - | FileCheck %s
!CHECK: omp.declare_reduction @[[REDUCER:.*]] : i32
diff --git a/flang/test/Lower/OpenMP/simple-barrier.f90 b/flang/test/Lower/OpenMP/simple-barrier.f90
index cc996330a2a73..a5e97ecd2fafa 100644
--- a/flang/test/Lower/OpenMP/simple-barrier.f90
+++ b/flang/test/Lower/OpenMP/simple-barrier.f90
@@ -1,5 +1,5 @@
-!RUN: %flang_fc1 -flang-experimental-hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
-!RUN: bbc -hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+!RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s
subroutine sample()
! CHECK: omp.barrier
diff --git a/flang/test/Lower/OpenMP/stop-stmt-in-region.f90 b/flang/test/Lower/OpenMP/stop-stmt-in-region.f90
index 0be31cfcb1a4e..67cd8b17f484b 100644
--- a/flang/test/Lower/OpenMP/stop-stmt-in-region.f90
+++ b/flang/test/Lower/OpenMP/stop-stmt-in-region.f90
@@ -1,7 +1,7 @@
! This test checks lowering of stop statement in OpenMP region.
-! RUN: %flang_fc1 -flang-experimental-hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
-! RUN: bbc -hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s
! CHECK-LABEL: func.func @_QPtest_stop_in_region1() {
diff --git a/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90 b/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90
index 35231f5cd4717..310b5bcba222d 100644
--- a/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90
+++ b/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90
@@ -1,8 +1,8 @@
! Simple test for lowering of OpenMP Threadprivate Directive with HLFIR.
! Test for common block.
-!RUN: %flang_fc1 -flang-experimental-hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
-!RUN: bbc -hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+!RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s
!CHECK: %[[CBLK_ADDR:.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<4xi8>>
diff --git a/flang/test/Lower/OpenMP/threadprivate-common-block-pointer.f90 b/flang/test/Lower/OpenMP/threadprivate-common-block-pointer.f90
index c7b77f382b440..98ce784a7e3ae 100644
--- a/flang/test/Lower/OpenMP/threadprivate-common-block-pointer.f90
+++ b/flang/test/Lower/OpenMP/threadprivate-common-block-pointer.f90
@@ -2,7 +2,7 @@
! from a common block.
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
-!RUN: bbc -hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
+!RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s
! Regression test for a compiler crash
diff --git a/flang/test/Lower/OpenMP/threadprivate-hlfir.f90 b/flang/test/Lower/OpenMP/threadprivate-hlfir.f90
index 92e341aed1bf9..d767b39652b67 100644
--- a/flang/test/Lower/OpenMP/threadprivate-hlfir.f90
+++ b/flang/test/Lower/OpenMP/threadprivate-hlfir.f90
@@ -1,7 +1,7 @@
! Simple test for lowering of OpenMP Threadprivate Directive with HLFIR.
-!RUN: %flang_fc1 -flang-experimental-hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
-!RUN: bbc -hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+!RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s
!CHECK-LABEL: @_QPsub
!CHECK: %[[ADDR:.*]] = fir.address_of(@_QFsubEa) : !fir.ref<i32>
diff --git a/flang/test/Lower/pass-null-for-class-arg.f90 b/flang/test/Lower/pass-null-for-class-arg.f90
index f60cad30b1bf6..e7e4402efd61c 100644
--- a/flang/test/Lower/pass-null-for-class-arg.f90
+++ b/flang/test/Lower/pass-null-for-class-arg.f90
@@ -1,5 +1,5 @@
! RUN: bbc -emit-fir %s -o - | FileCheck %s --check-prefix=FIR
-! RUN: bbc -emit-fir -hlfir %s -o - | FileCheck %s --check-prefix=HLFIR
+! RUN: bbc -emit-fir %s -o - | FileCheck %s --check-prefix=HLFIR
subroutine test
interface
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index a21865f9c5ffe..bc6e9eb67e132 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -217,10 +217,6 @@ static llvm::cl::opt<bool> enableNoPPCNativeVecElemOrder(
llvm::cl::desc("no PowerPC native vector element order."),
llvm::cl::init(false));
-static llvm::cl::opt<bool> useHLFIR("hlfir",
- llvm::cl::desc("Lower to high level FIR"),
- llvm::cl::init(true));
-
static llvm::cl::opt<bool> enableCUDA("fcuda",
llvm::cl::desc("enable CUDA Fortran"),
llvm::cl::init(false));
@@ -468,7 +464,6 @@ static llvm::LogicalResult convertFortranSourceToMLIR(
// Use default lowering options for bbc.
Fortran::lower::LoweringOptions loweringOptions{};
loweringOptions.setNoPPCNativeVecElemOrder(enableNoPPCNativeVecElemOrder);
- loweringOptions.setLowerToHighLevelFIR(useHLFIR || emitHLFIR);
loweringOptions.setIntegerWrapAround(integerWrapAround);
loweringOptions.setInitGlobalZero(initGlobalZero);
loweringOptions.setReallocateLHS(reallocateLHS);
@@ -550,7 +545,7 @@ static llvm::LogicalResult convertFortranSourceToMLIR(
return mlir::failure();
}
- if (emitFIR && useHLFIR) {
+ if (emitFIR) {
// lower HLFIR to FIR
fir::EnableOpenMP enableOmp =
enableOpenMP ? fir::EnableOpenMP::Full : fir::EnableOpenMP::None;
>From 10e0ccc2ca0f1553744b8514f6b7d83a6603807e Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Wed, 6 May 2026 12:51:23 -0400
Subject: [PATCH 2/3] [flang] Remove --use-desc-for-alloc option and legacy
createMutableProperties
Remove the bbc `--use-desc-for-alloc` debug option (cl::opt
`useDescForMutableBox`), which when set to false enabled a legacy code
path that tracked allocatable/pointer mutable properties in individual
variables outside the descriptor. With the option always treated as
true (its default), `createMutableProperties` always returned an empty
`MutableProperties{}` and the property-allocation body was dead code.
Delete `createMutableProperties` and the four static helpers that only
its body used: `isNonContiguousArrayPointer`, `isPolymorphicPointer`,
`isPolymorphicAllocatable`, and `mayBeCapturedInInternalProc`. Inline a
default-constructed `MutableProperties{}` directly into `createMutableBox`.
Drop the `alwaysUseBox` parameter from `createMutableBox` (in
`Allocatable.h` / `Allocatable.cpp`); it was only consulted by the
deleted body. Update the sole caller in `ConvertVariable.cpp`.
Update the two tests that passed `--use-desc-for-alloc=false`
(`Lower/allocatable-polymorphic.f90` and
`Lower/OpenMP/parallel-private-clause.f90`) to drop the now-removed flag.
Verified: ninja flang, ninja install, ninja check-flang
(4270 passing / 0 failing), ninja check-flang-rt (312/312 passing).
---
flang/include/flang/Lower/Allocatable.h | 2 +-
flang/lib/Lower/Allocatable.cpp | 126 +-----------------
flang/lib/Lower/ConvertVariable.cpp | 1 -
.../Lower/OpenMP/parallel-private-clause.f90 | 2 +-
flang/test/Lower/allocatable-polymorphic.f90 | 4 +-
5 files changed, 6 insertions(+), 129 deletions(-)
diff --git a/flang/include/flang/Lower/Allocatable.h b/flang/include/flang/Lower/Allocatable.h
index 0e89af94af40f..1c1491b9beab2 100644
--- a/flang/include/flang/Lower/Allocatable.h
+++ b/flang/include/flang/Lower/Allocatable.h
@@ -71,7 +71,7 @@ void genDeallocateIfAllocated(AbstractConverter &converter,
fir::MutableBoxValue
createMutableBox(AbstractConverter &converter, mlir::Location loc,
const pft::Variable &var, mlir::Value boxAddr,
- mlir::ValueRange nonDeferredParams, bool alwaysUseBox,
+ mlir::ValueRange nonDeferredParams,
unsigned allocator = kDefaultAllocator);
/// Assign a boxed value to a boxed variable, \p box (known as a
diff --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp
index 9173f06f2bd24..faa49417d23ec 100644
--- a/flang/lib/Lower/Allocatable.cpp
+++ b/flang/lib/Lower/Allocatable.cpp
@@ -48,16 +48,6 @@ static llvm::cl::opt<bool> useAllocateRuntime(
"use-alloc-runtime",
llvm::cl::desc("Lower allocations to fortran runtime calls"),
llvm::cl::init(false));
-/// Switch to force lowering of allocatable and pointers to descriptors in all
-/// cases. This is now turned on by default since that is what will happen with
-/// HLFIR lowering, so this allows getting early feedback of the impact.
-/// If this turns out to cause performance regressions, a dedicated fir.box
-/// "discretization pass" would make more sense to cover all the fir.box usage
-/// (taking advantage of any future inlining for instance).
-static llvm::cl::opt<bool> useDescForMutableBox(
- "use-desc-for-alloc",
- llvm::cl::desc("Always use descriptors for POINTER and ALLOCATABLE"),
- llvm::cl::init(true));
//===----------------------------------------------------------------------===//
// Error management
@@ -1017,123 +1007,11 @@ void Fortran::lower::genDeallocateStmt(
// MutableBoxValue creation implementation
//===----------------------------------------------------------------------===//
-/// Is this symbol a pointer to a pointer array that does not have the
-/// CONTIGUOUS attribute ?
-static inline bool
-isNonContiguousArrayPointer(const Fortran::semantics::Symbol &sym) {
- return Fortran::semantics::IsPointer(sym) && sym.Rank() != 0 &&
- !sym.attrs().test(Fortran::semantics::Attr::CONTIGUOUS);
-}
-
-/// Is this symbol a polymorphic pointer?
-static inline bool isPolymorphicPointer(const Fortran::semantics::Symbol &sym) {
- return Fortran::semantics::IsPointer(sym) &&
- Fortran::semantics::IsPolymorphic(sym);
-}
-
-/// Is this symbol a polymorphic allocatable?
-static inline bool
-isPolymorphicAllocatable(const Fortran::semantics::Symbol &sym) {
- return Fortran::semantics::IsAllocatable(sym) &&
- Fortran::semantics::IsPolymorphic(sym);
-}
-
-/// Is this a local procedure symbol in a procedure that contains internal
-/// procedures ?
-static bool mayBeCapturedInInternalProc(const Fortran::semantics::Symbol &sym) {
- const Fortran::semantics::Scope &owner = sym.owner();
- Fortran::semantics::Scope::Kind kind = owner.kind();
- // Test if this is a procedure scope that contains a subprogram scope that is
- // not an interface.
- if (kind == Fortran::semantics::Scope::Kind::Subprogram ||
- kind == Fortran::semantics::Scope::Kind::MainProgram)
- for (const Fortran::semantics::Scope &childScope : owner.children())
- if (childScope.kind() == Fortran::semantics::Scope::Kind::Subprogram)
- if (const Fortran::semantics::Symbol *childSym = childScope.symbol())
- if (const auto *details =
- childSym->detailsIf<Fortran::semantics::SubprogramDetails>())
- if (!details->isInterface())
- return true;
- return false;
-}
-
-/// In case it is safe to track the properties in variables outside a
-/// descriptor, create the variables to hold the mutable properties of the
-/// entity var. The variables are not initialized here.
-static fir::MutableProperties
-createMutableProperties(Fortran::lower::AbstractConverter &converter,
- mlir::Location loc,
- const Fortran::lower::pft::Variable &var,
- mlir::ValueRange nonDeferredParams, bool alwaysUseBox) {
- fir::FirOpBuilder &builder = converter.getFirOpBuilder();
- const Fortran::semantics::Symbol &sym = var.getSymbol();
- // Globals and dummies may be associated, creating local variables would
- // require keeping the values and descriptor before and after every single
- // impure calls in the current scope (not only the ones taking the variable as
- // arguments. All.) Volatile means the variable may change in ways not defined
- // per Fortran, so lowering can most likely not keep the descriptor and values
- // in sync as needed.
- // Pointers to non contiguous arrays need to be represented with a fir.box to
- // account for the discontiguity.
- // Pointer/Allocatable in internal procedure are descriptors in the host link,
- // and it would increase complexity to sync this descriptor with the local
- // values every time the host link is escaping.
- if (alwaysUseBox || var.isGlobal() || Fortran::semantics::IsDummy(sym) ||
- Fortran::semantics::IsFunctionResult(sym) ||
- sym.attrs().test(Fortran::semantics::Attr::VOLATILE) ||
- isNonContiguousArrayPointer(sym) || useAllocateRuntime ||
- useDescForMutableBox || mayBeCapturedInInternalProc(sym) ||
- isPolymorphicPointer(sym) || isPolymorphicAllocatable(sym))
- return {};
- fir::MutableProperties mutableProperties;
- std::string name = converter.mangleName(sym);
- mlir::Type baseAddrTy = converter.genType(sym);
- if (auto boxType = mlir::dyn_cast<fir::BaseBoxType>(baseAddrTy))
- baseAddrTy = boxType.getEleTy();
- // Allocate and set a variable to hold the address.
- // It will be set to null in setUnallocatedStatus.
- mutableProperties.addr =
- builder.allocateLocal(loc, baseAddrTy, name + ".addr", "",
- /*shape=*/{}, /*typeparams=*/{});
- // Allocate variables to hold lower bounds and extents.
- int rank = sym.Rank();
- mlir::Type idxTy = builder.getIndexType();
- for (decltype(rank) i = 0; i < rank; ++i) {
- mlir::Value lboundVar =
- builder.allocateLocal(loc, idxTy, name + ".lb" + std::to_string(i), "",
- /*shape=*/{}, /*typeparams=*/{});
- mlir::Value extentVar =
- builder.allocateLocal(loc, idxTy, name + ".ext" + std::to_string(i), "",
- /*shape=*/{}, /*typeparams=*/{});
- mutableProperties.lbounds.emplace_back(lboundVar);
- mutableProperties.extents.emplace_back(extentVar);
- }
-
- // Allocate variable to hold deferred length parameters.
- mlir::Type eleTy = baseAddrTy;
- if (auto newTy = fir::dyn_cast_ptrEleTy(eleTy))
- eleTy = newTy;
- if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(eleTy))
- eleTy = seqTy.getEleTy();
- if (auto record = mlir::dyn_cast<fir::RecordType>(eleTy))
- if (record.getNumLenParams() != 0)
- TODO(loc, "deferred length type parameters.");
- if (fir::isa_char(eleTy) && nonDeferredParams.empty()) {
- mlir::Value lenVar = builder.allocateLocal(
- loc, builder.getCharacterLengthType(), name + ".len", "", /*shape=*/{},
- /*typeparams=*/{});
- mutableProperties.deferredParams.emplace_back(lenVar);
- }
- return mutableProperties;
-}
-
fir::MutableBoxValue Fortran::lower::createMutableBox(
Fortran::lower::AbstractConverter &converter, mlir::Location loc,
const Fortran::lower::pft::Variable &var, mlir::Value boxAddr,
- mlir::ValueRange nonDeferredParams, bool alwaysUseBox, unsigned allocator) {
- fir::MutableProperties mutableProperties = createMutableProperties(
- converter, loc, var, nonDeferredParams, alwaysUseBox);
- fir::MutableBoxValue box(boxAddr, nonDeferredParams, mutableProperties);
+ mlir::ValueRange nonDeferredParams, unsigned allocator) {
+ fir::MutableBoxValue box(boxAddr, nonDeferredParams, /*mutableProperties=*/{});
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
if (!var.isGlobal() && !Fortran::semantics::IsDummy(var.getSymbol()))
fir::factory::disassociateMutableBox(builder, loc, box,
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index a18b204f75403..377952555ec4f 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -2171,7 +2171,6 @@ void Fortran::lower::mapSymbolAttributes(
}
fir::MutableBoxValue box = Fortran::lower::createMutableBox(
converter, loc, var, boxAlloc, nonDeferredLenParams,
- /*alwaysUseBox=*/true,
Fortran::lower::getAllocatorIdx(var.getSymbol()));
genAllocatableOrPointerDeclare(converter, symMap, var.getSymbol(), box,
replace);
diff --git a/flang/test/Lower/OpenMP/parallel-private-clause.f90 b/flang/test/Lower/OpenMP/parallel-private-clause.f90
index f998c09fc4d4f..12cbda1c3d572 100644
--- a/flang/test/Lower/OpenMP/parallel-private-clause.f90
+++ b/flang/test/Lower/OpenMP/parallel-private-clause.f90
@@ -1,7 +1,7 @@
! This test checks lowering of OpenMP parallel Directive with
! `PRIVATE` clause present.
-! RUN: bbc --use-desc-for-alloc=false -fopenmp -emit-hlfir %s -o - \
+! RUN: bbc -fopenmp -emit-hlfir %s -o - \
! RUN: | FileCheck %s --check-prefix=FIRDialect
! FIRDialect: omp.private {type = private} @_QFsimd_loop_1Er_private_box_heap_f32 : !fir.box<!fir.heap<f32>> init {
diff --git a/flang/test/Lower/allocatable-polymorphic.f90 b/flang/test/Lower/allocatable-polymorphic.f90
index 8ae59df68dd8b..9e4f04b45516e 100644
--- a/flang/test/Lower/allocatable-polymorphic.f90
+++ b/flang/test/Lower/allocatable-polymorphic.f90
@@ -1,5 +1,5 @@
-! RUN: bbc --use-desc-for-alloc=false -emit-hlfir %s -o - | FileCheck %s
-! RUN: bbc --use-desc-for-alloc=false -emit-hlfir %s -o - | tco | FileCheck %s --check-prefix=LLVM
+! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir %s -o - | tco | FileCheck %s --check-prefix=LLVM
module poly
type p1
>From 867eab2edc6d778a68946d0fa00eb27e73fb1e8c Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Wed, 6 May 2026 19:14:13 -0400
Subject: [PATCH 3/3] clang-format
---
flang/include/flang/Lower/Allocatable.h | 11 ++++++-----
flang/lib/Lower/Allocatable.cpp | 3 ++-
flang/lib/Lower/ConvertVariable.cpp | 6 +++---
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/flang/include/flang/Lower/Allocatable.h b/flang/include/flang/Lower/Allocatable.h
index 1c1491b9beab2..515fd20b2bcb5 100644
--- a/flang/include/flang/Lower/Allocatable.h
+++ b/flang/include/flang/Lower/Allocatable.h
@@ -68,11 +68,12 @@ void genDeallocateIfAllocated(AbstractConverter &converter,
/// Create a MutableBoxValue for an allocatable or pointer entity.
/// If the variables is a local variable that is not a dummy, it will be
/// initialized to unallocated/diassociated status.
-fir::MutableBoxValue
-createMutableBox(AbstractConverter &converter, mlir::Location loc,
- const pft::Variable &var, mlir::Value boxAddr,
- mlir::ValueRange nonDeferredParams,
- unsigned allocator = kDefaultAllocator);
+fir::MutableBoxValue createMutableBox(AbstractConverter &converter,
+ mlir::Location loc,
+ const pft::Variable &var,
+ mlir::Value boxAddr,
+ mlir::ValueRange nonDeferredParams,
+ unsigned allocator = kDefaultAllocator);
/// Assign a boxed value to a boxed variable, \p box (known as a
/// MutableBoxValue). Expression \p source will be lowered to build the
diff --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp
index faa49417d23ec..8ca861105ce23 100644
--- a/flang/lib/Lower/Allocatable.cpp
+++ b/flang/lib/Lower/Allocatable.cpp
@@ -1011,7 +1011,8 @@ fir::MutableBoxValue Fortran::lower::createMutableBox(
Fortran::lower::AbstractConverter &converter, mlir::Location loc,
const Fortran::lower::pft::Variable &var, mlir::Value boxAddr,
mlir::ValueRange nonDeferredParams, unsigned allocator) {
- fir::MutableBoxValue box(boxAddr, nonDeferredParams, /*mutableProperties=*/{});
+ fir::MutableBoxValue box(boxAddr, nonDeferredParams,
+ /*mutableProperties=*/{});
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
if (!var.isGlobal() && !Fortran::semantics::IsDummy(var.getSymbol()))
fir::factory::disassociateMutableBox(builder, loc, box,
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index 377952555ec4f..97483518ceff6 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -2074,9 +2074,9 @@ static void genBoxDeclare(Fortran::lower::AbstractConverter &converter,
llvm::ArrayRef<mlir::Value> explicitExtents,
bool replace = false) {
fir::BoxValue boxValue{box, lbounds, explicitParams, explicitExtents};
- Fortran::lower::genDeclareSymbol(
- converter, symMap, sym, std::move(boxValue),
- fir::FortranVariableFlagsEnum::None, replace);
+ Fortran::lower::genDeclareSymbol(converter, symMap, sym, std::move(boxValue),
+ fir::FortranVariableFlagsEnum::None,
+ replace);
}
/// Lower specification expressions and attributes of variable \p var and
More information about the flang-commits
mailing list