Skip to content

Commit aa8af04

Browse files
authored
[flang] Switch lowering to use the HLFIR step by default (llvm#72090)
Patch 3/3 of the transition step 1 described in https://discourse.llvm.org/t/rfc-enabling-the-hlfir-lowering-by-default/72778/7 This patch changes bbc and flang-new driver to use HLFIR lowering by default. `-hlfir=false` can be used with bbc and `-flang-deprecated-no-hlfir` with flang-new to get the previous default lowering behavior, but these options will only be available for a limited period of time. If any user needs these options to workaround bugs, they should open an issue against flang in llvm github repo so that the regression can be fixed in HLFIR.
1 parent 8e8bad7 commit aa8af04

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

flang/include/flang/Lower/LoweringOptions.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ ENUM_LOWERINGOPT(OptimizeTranspose, unsigned, 1, 1)
2727
/// If true, enable polymorphic type lowering feature. Off by default.
2828
ENUM_LOWERINGOPT(PolymorphicTypeImpl, unsigned, 1, 0)
2929

30-
/// If true, lower to High level FIR before lowering to FIR.
31-
/// Off by default until fully ready.
32-
ENUM_LOWERINGOPT(LowerToHighLevelFIR, unsigned, 1, 0)
30+
/// If true, lower to High level FIR before lowering to FIR. On by default.
31+
ENUM_LOWERINGOPT(LowerToHighLevelFIR, unsigned, 1, 1)
3332

3433
/// If true, reverse PowerPC native vector element order.
3534
ENUM_LOWERINGOPT(NoPPCNativeVecElemOrder, unsigned, 1, 0)
3635

37-
/// If true, assume external names will be suffixed with an underscore. On by default.
36+
/// If true, assume external names will be suffixed with an underscore.
37+
/// On by default.
3838
ENUM_LOWERINGOPT(Underscoring, unsigned, 1, 1)
3939

4040
#undef LOWERINGOPT

flang/test/HLFIR/hlfir-flags.f90

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
! Test -flang-experimental-hlfir (flang-new), -hlfir (bbc), -emit-hlfir, -emit-fir flags
1+
! Test -flang-deprecated-hlfir, -flang-experimental-hlfir (flang-new), and
2+
! -hlfir (bbc), -emit-hlfir, -emit-fir flags
23
! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck --check-prefix HLFIR --check-prefix ALL %s
34
! RUN: bbc -emit-hlfir -o - %s | FileCheck --check-prefix HLFIR --check-prefix ALL %s
4-
! RUN: %flang_fc1 -emit-hlfir -flang-experimental-hlfir -o - %s | FileCheck --check-prefix HLFIR --check-prefix ALL %s
5+
! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck --check-prefix HLFIR --check-prefix ALL %s
56
! RUN: bbc -emit-hlfir -hlfir -o - %s | FileCheck --check-prefix HLFIR --check-prefix ALL %s
6-
! RUN: %flang_fc1 -emit-fir -o - %s | FileCheck %s --check-prefix NO-HLFIR --check-prefix ALL
7+
! RUN: %flang_fc1 -emit-fir -o - %s | FileCheck --check-prefix FIR --check-prefix ALL %s
78
! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir -o - %s | FileCheck %s --check-prefix NO-HLFIR --check-prefix ALL
8-
! RUN: bbc -emit-fir -o - %s | FileCheck %s --check-prefix NO-HLFIR --check-prefix ALL
9-
! RUN: %flang_fc1 -emit-fir -flang-experimental-hlfir -o - %s | FileCheck --check-prefix FIR --check-prefix ALL %s
10-
! RUN: bbc -emit-fir -hlfir -o - %s | FileCheck --check-prefix FIR --check-prefix ALL %s
9+
! RUN: %flang_fc1 -emit-fir -flang-experimental-hlfir -o - %s | FileCheck %s --check-prefix FIR --check-prefix ALL
10+
! RUN: bbc -emit-fir -o - %s | FileCheck --check-prefix FIR --check-prefix ALL %s
11+
! RUN: bbc -emit-fir -hlfir=false -o - %s | FileCheck %s --check-prefix NO-HLFIR --check-prefix ALL
1112

12-
! | Action | -flang-experimental-hlfir / -hlfir? | Result |
13-
! | =========== | =================================== | =============================== |
14-
! | -emit-hlfir | N | Outputs HLFIR |
15-
! | -emit-hlfir | Y | Outputs HLFIR |
16-
! | -emit-fir | N | Outputs FIR, using old lowering |
17-
! | -emit-fir | Y | Outputs FIR, lowering via HLFIR |
13+
! | Action | -flang-deprecated-no-hlfir | Result |
14+
! | | / -hlfir=false? | |
15+
! | =========== | =========================== | =============================== |
16+
! | -emit-hlfir | N | Outputs HLFIR |
17+
! | -emit-hlfir | Y | Outputs HLFIR |
18+
! | -emit-fir | N | Outputs FIR, lowering via HLFIR |
19+
! | -emit-fir | Y | Outputs FIR, using old lowering |
1820

1921
subroutine test(a, res)
2022
real :: a(:), res

flang/tools/bbc/bbc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static llvm::cl::opt<bool> enableNoPPCNativeVecElemOrder(
193193

194194
static llvm::cl::opt<bool> useHLFIR("hlfir",
195195
llvm::cl::desc("Lower to high level FIR"),
196-
llvm::cl::init(false));
196+
llvm::cl::init(true));
197197

198198
static llvm::cl::opt<bool> enableCUDA("fcuda",
199199
llvm::cl::desc("enable CUDA Fortran"),

0 commit comments

Comments
 (0)