https://github.com/kiranchandramohan updated https://github.com/llvm/llvm-project/pull/122144
>From 483501549b910d1e91dab05cce65793c44aaa6f6 Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan <kiran.chandramo...@arm.com> Date: Wed, 8 Jan 2025 17:26:24 +0000 Subject: [PATCH 1/6] [Flang][Driver] Add a flag to control zero initialization of global variables Patch adds a flag to control zero initialization of global variables without default initialization. The default is to zero initialize. --- clang/include/clang/Driver/Options.td | 3 +++ clang/lib/Driver/ToolChains/Flang.cpp | 1 + flang/include/flang/Lower/LoweringOptions.def | 3 +++ flang/lib/Frontend/CompilerInvocation.cpp | 6 ++++++ flang/lib/Lower/ConvertVariable.cpp | 6 +++++- flang/test/Driver/fno-zero-init.f90 | 5 +++++ flang/test/Lower/zero_init.f90 | 16 ++++++++++++++++ flang/test/Lower/zero_init_default_init.f90 | 18 ++++++++++++++++++ 8 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 flang/test/Driver/fno-zero-init.f90 create mode 100644 flang/test/Lower/zero_init.f90 create mode 100644 flang/test/Lower/zero_init_default_init.f90 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 52823430919de4..e8d18cf78e985a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3494,6 +3494,9 @@ def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group<f_Group>; def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group<f_Group>; def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group<f_Group>, Visibility<[ClangOption, FlangOption]>; +def fno_zero_init_global_without_init : Flag<["-"], "fno-zero-init-global-without-init">, Group<f_Group>, + Visibility<[FlangOption, FC1Option]>, + HelpText<"Do not zero initialize globals without default initialization">; def fno_pointer_tbaa : Flag<["-"], "fno-pointer-tbaa">, Group<f_Group>; def fno_temp_file : Flag<["-"], "fno-temp-file">, Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>, HelpText< diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 75b10e88371ae7..609f5315426977 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -153,6 +153,7 @@ void Flang::addCodegenOptions(const ArgList &Args, Args.addAllArgs(CmdArgs, {options::OPT_flang_experimental_hlfir, options::OPT_flang_deprecated_no_hlfir, options::OPT_fno_ppc_native_vec_elem_order, + options::OPT_fno_zero_init_global_without_init, options::OPT_fppc_native_vec_elem_order}); } diff --git a/flang/include/flang/Lower/LoweringOptions.def b/flang/include/flang/Lower/LoweringOptions.def index 5a6debfdffe030..acce21f5faab8b 100644 --- a/flang/include/flang/Lower/LoweringOptions.def +++ b/flang/include/flang/Lower/LoweringOptions.def @@ -44,5 +44,8 @@ ENUM_LOWERINGOPT(IntegerWrapAround, unsigned, 1, 0) /// If false, assume that the shapes/types/allocation-status match. ENUM_LOWERINGOPT(ReallocateLHS, unsigned, 1, 1) +/// If true, initialize globals without initialization to zero. +/// On by default. +ENUM_LOWERINGOPT(ZeroInitGlobalsWithoutInit, unsigned, 1, 1) #undef LOWERINGOPT #undef ENUM_LOWERINGOPT diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 340efb1c63a5e5..fa91a0e2642bc8 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1373,6 +1373,12 @@ bool CompilerInvocation::createFromArgs( invoc.loweringOpts.setNoPPCNativeVecElemOrder(true); } + // -fno-zero-init-global-without-init + if (args.hasArg( + clang::driver::options::OPT_fno_zero_init_global_without_init)) { + invoc.loweringOpts.setZeroInitGlobalsWithoutInit(false); + } + // Preserve all the remark options requested, i.e. -Rpass, -Rpass-missed or // -Rpass-analysis. This will be used later when processing and outputting the // remarks generated by LLVM in ExecuteCompilerInvocation.cpp. diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp index 9ee42d5cd88002..db8a57d416274c 100644 --- a/flang/lib/Lower/ConvertVariable.cpp +++ b/flang/lib/Lower/ConvertVariable.cpp @@ -635,7 +635,11 @@ static fir::GlobalOp defineGlobal(Fortran::lower::AbstractConverter &converter, global.setLinkName(builder.createCommonLinkage()); Fortran::lower::createGlobalInitialization( builder, global, [&](fir::FirOpBuilder &builder) { - mlir::Value initValue = builder.create<fir::ZeroOp>(loc, symTy); + mlir::Value initValue; + if (converter.getLoweringOptions().getZeroInitGlobalsWithoutInit()) + initValue = builder.create<fir::ZeroOp>(loc, symTy); + else + initValue = builder.create<fir::UndefOp>(loc, symTy); builder.create<fir::HasValueOp>(loc, initValue); }); } diff --git a/flang/test/Driver/fno-zero-init.f90 b/flang/test/Driver/fno-zero-init.f90 new file mode 100644 index 00000000000000..faa757b32a8dab --- /dev/null +++ b/flang/test/Driver/fno-zero-init.f90 @@ -0,0 +1,5 @@ +! Check that the driver passes through -fno-zero-init-global-without-init: +! RUN: %flang -### -S -fno-zero-init-global-without-init %s -o - 2>&1 | FileCheck %s +! Check that the compiler accepts -fno-zero-init-global-without-init: +! RUN: %flang_fc1 -emit-hlfir -fno-zero-init-global-without-init %s -o - +! CHECK: "-fc1"{{.*}}"-fno-zero-init-global-without-init" diff --git a/flang/test/Lower/zero_init.f90 b/flang/test/Lower/zero_init.f90 new file mode 100644 index 00000000000000..76201eb0f0cbd0 --- /dev/null +++ b/flang/test/Lower/zero_init.f90 @@ -0,0 +1,16 @@ +! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-DEFAULT %s +! RUN: %flang_fc1 -fno-zero-init-global-without-init -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-NO-ZERO-INIT %s + +module m1 + real :: x +end module m1 + +!CHECK-DEFAULT: fir.global @_QMm1Ex : f32 { +!CHECK-DEFAULT: %[[UNDEF:.*]] = fir.zero_bits f32 +!CHECK-DEFAULT: fir.has_value %[[UNDEF]] : f32 +!CHECK-DEFAULT: } + +!CHECK-NO-ZERO-INIT: fir.global @_QMm1Ex : f32 { +!CHECK-NO-ZERO-INIT: %[[UNDEF:.*]] = fir.undefined f32 +!CHECK-NO-ZERO-INIT: fir.has_value %[[UNDEF]] : f32 +!CHECK-NO-ZERO-INIT: } diff --git a/flang/test/Lower/zero_init_default_init.f90 b/flang/test/Lower/zero_init_default_init.f90 new file mode 100644 index 00000000000000..ac6faf37e8d1bf --- /dev/null +++ b/flang/test/Lower/zero_init_default_init.f90 @@ -0,0 +1,18 @@ +! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck %s +! RUN: %flang_fc1 -fno-zero-init-global-without-init -emit-hlfir -o - %s | FileCheck %s + +! Test that the flag does not affect globals with default init + +module m2 + type val + integer :: my_val = 1 + end type val + type(val) :: v1 +end module m2 + +!CHECK: fir.global @_QMm2Ev1 : !fir.type<_QMm2Tval{my_val:i32}> { +!CHECK: %[[V1:.*]] = fir.undefined !fir.type<_QMm2Tval{my_val:i32}> +!CHECK: %[[ONE:.*]] = arith.constant 1 : i32 +!CHECK: %[[V1_INIT:.*]] = fir.insert_value %[[V1]], %[[ONE]], ["my_val", !fir.type<_QMm2Tval{my_val:i32}>] : (!fir.type<_QMm2Tval{my_val:i32}>, i32) -> !fir.type<_QMm2Tval{my_val:i32}> +!CHECK: fir.has_value %[[V1_INIT]] : !fir.type<_QMm2Tval{my_val:i32}> +!CHECK: } >From 0887ccae49760f8ea93d6c3fffdc247855f861f1 Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan <kiran.chandramo...@arm.com> Date: Mon, 13 Jan 2025 18:06:07 +0000 Subject: [PATCH 2/6] Change name to init-global-zero and add positive flag as well --- clang/include/clang/Driver/Options.td | 9 ++++++--- clang/lib/Driver/ToolChains/Flang.cpp | 3 ++- flang/include/flang/Lower/LoweringOptions.def | 2 +- flang/lib/Frontend/CompilerInvocation.cpp | 10 +++++----- flang/lib/Lower/ConvertVariable.cpp | 2 +- flang/test/Driver/fno-zero-init.f90 | 14 +++++++++----- flang/test/Lower/zero_init.f90 | 3 ++- flang/test/Lower/zero_init_default_init.f90 | 3 ++- 8 files changed, 28 insertions(+), 18 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e8d18cf78e985a..854449bcab6364 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3494,9 +3494,12 @@ def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group<f_Group>; def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group<f_Group>; def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group<f_Group>, Visibility<[ClangOption, FlangOption]>; -def fno_zero_init_global_without_init : Flag<["-"], "fno-zero-init-global-without-init">, Group<f_Group>, - Visibility<[FlangOption, FC1Option]>, - HelpText<"Do not zero initialize globals without default initialization">; +defm init_global_zero : BoolFOption<"init-global-zero", + CodeGenOpts<"InitGlobalZero">, DefaultTrue, + NegFlag<SetFalse, [], [FlangOption, FC1Option], + "Zero initialize globals without default initialization">, + PosFlag<SetTrue, [], [FlangOption, FC1Option], + "Do not zero initialize globals without default initialization">>; def fno_pointer_tbaa : Flag<["-"], "fno-pointer-tbaa">, Group<f_Group>; def fno_temp_file : Flag<["-"], "fno-temp-file">, Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>, HelpText< diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 609f5315426977..cdce51a93bad21 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -153,7 +153,8 @@ void Flang::addCodegenOptions(const ArgList &Args, Args.addAllArgs(CmdArgs, {options::OPT_flang_experimental_hlfir, options::OPT_flang_deprecated_no_hlfir, options::OPT_fno_ppc_native_vec_elem_order, - options::OPT_fno_zero_init_global_without_init, + options::OPT_finit_global_zero, + options::OPT_fno_init_global_zero, options::OPT_fppc_native_vec_elem_order}); } diff --git a/flang/include/flang/Lower/LoweringOptions.def b/flang/include/flang/Lower/LoweringOptions.def index acce21f5faab8b..396c91948be36b 100644 --- a/flang/include/flang/Lower/LoweringOptions.def +++ b/flang/include/flang/Lower/LoweringOptions.def @@ -46,6 +46,6 @@ ENUM_LOWERINGOPT(ReallocateLHS, unsigned, 1, 1) /// If true, initialize globals without initialization to zero. /// On by default. -ENUM_LOWERINGOPT(ZeroInitGlobalsWithoutInit, unsigned, 1, 1) +ENUM_LOWERINGOPT(InitGlobalZero, unsigned, 1, 1) #undef LOWERINGOPT #undef ENUM_LOWERINGOPT diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index fa91a0e2642bc8..f9661d1bd3a229 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1373,11 +1373,11 @@ bool CompilerInvocation::createFromArgs( invoc.loweringOpts.setNoPPCNativeVecElemOrder(true); } - // -fno-zero-init-global-without-init - if (args.hasArg( - clang::driver::options::OPT_fno_zero_init_global_without_init)) { - invoc.loweringOpts.setZeroInitGlobalsWithoutInit(false); - } + // -f[no-]init-global-zero + if (!args.hasFlag(clang::driver::options::OPT_finit_global_zero, + clang::driver::options::OPT_fno_init_global_zero, + /*default=*/true)) + invoc.loweringOpts.setInitGlobalZero(false); // Preserve all the remark options requested, i.e. -Rpass, -Rpass-missed or // -Rpass-analysis. This will be used later when processing and outputting the diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp index db8a57d416274c..87236dc293ebbc 100644 --- a/flang/lib/Lower/ConvertVariable.cpp +++ b/flang/lib/Lower/ConvertVariable.cpp @@ -636,7 +636,7 @@ static fir::GlobalOp defineGlobal(Fortran::lower::AbstractConverter &converter, Fortran::lower::createGlobalInitialization( builder, global, [&](fir::FirOpBuilder &builder) { mlir::Value initValue; - if (converter.getLoweringOptions().getZeroInitGlobalsWithoutInit()) + if (converter.getLoweringOptions().getInitGlobalZero()) initValue = builder.create<fir::ZeroOp>(loc, symTy); else initValue = builder.create<fir::UndefOp>(loc, symTy); diff --git a/flang/test/Driver/fno-zero-init.f90 b/flang/test/Driver/fno-zero-init.f90 index faa757b32a8dab..2ffa10dd040d52 100644 --- a/flang/test/Driver/fno-zero-init.f90 +++ b/flang/test/Driver/fno-zero-init.f90 @@ -1,5 +1,9 @@ -! Check that the driver passes through -fno-zero-init-global-without-init: -! RUN: %flang -### -S -fno-zero-init-global-without-init %s -o - 2>&1 | FileCheck %s -! Check that the compiler accepts -fno-zero-init-global-without-init: -! RUN: %flang_fc1 -emit-hlfir -fno-zero-init-global-without-init %s -o - -! CHECK: "-fc1"{{.*}}"-fno-zero-init-global-without-init" +! Check that the driver passes through -f[no-]init-global-zero: +! RUN: %flang -### -S -finit-global-zero %s -o - 2>&1 | FileCheck --check-prefix=CHECK-POS %s +! RUN: %flang -### -S -fno-init-global-zero %s -o - 2>&1 | FileCheck --check-prefix=CHECK-NEG %s +! Check that the compiler accepts -f[no-]init-global-zero: +! RUN: %flang_fc1 -emit-hlfir -finit-global-zero %s -o - +! RUN: %flang_fc1 -emit-hlfir -fno-init-global-zero %s -o - + +! CHECK-POS: "-fc1"{{.*}}"-finit-global-zero" +! CHECK-NEG: "-fc1"{{.*}}"-fno-init-global-zero" diff --git a/flang/test/Lower/zero_init.f90 b/flang/test/Lower/zero_init.f90 index 76201eb0f0cbd0..89e6584f410f7c 100644 --- a/flang/test/Lower/zero_init.f90 +++ b/flang/test/Lower/zero_init.f90 @@ -1,5 +1,6 @@ ! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-DEFAULT %s -! RUN: %flang_fc1 -fno-zero-init-global-without-init -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-NO-ZERO-INIT %s +! RUN: %flang_fc1 -finit-global-zero -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-DEFAULT %s +! RUN: %flang_fc1 -fno-init-global-zero -emit-hlfir -o - %s | FileCheck --check-prefix=CHECK-NO-ZERO-INIT %s module m1 real :: x diff --git a/flang/test/Lower/zero_init_default_init.f90 b/flang/test/Lower/zero_init_default_init.f90 index ac6faf37e8d1bf..761052b5b08a0e 100644 --- a/flang/test/Lower/zero_init_default_init.f90 +++ b/flang/test/Lower/zero_init_default_init.f90 @@ -1,5 +1,6 @@ ! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck %s -! RUN: %flang_fc1 -fno-zero-init-global-without-init -emit-hlfir -o - %s | FileCheck %s +! RUN: %flang_fc1 -finit-global-zero -emit-hlfir -o - %s | FileCheck %s +! RUN: %flang_fc1 -fno-init-global-zero -emit-hlfir -o - %s | FileCheck %s ! Test that the flag does not affect globals with default init >From 84dd129faf7454d93cf7c49f0f0a12519837fa1e Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan <kiran.chandramo...@arm.com> Date: Tue, 14 Jan 2025 12:26:59 +0000 Subject: [PATCH 3/6] Fix formatting --- flang/lib/Frontend/CompilerInvocation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index f9661d1bd3a229..a7f598fd0ed168 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1375,8 +1375,8 @@ bool CompilerInvocation::createFromArgs( // -f[no-]init-global-zero if (!args.hasFlag(clang::driver::options::OPT_finit_global_zero, - clang::driver::options::OPT_fno_init_global_zero, - /*default=*/true)) + clang::driver::options::OPT_fno_init_global_zero, + /*default=*/true)) invoc.loweringOpts.setInitGlobalZero(false); // Preserve all the remark options requested, i.e. -Rpass, -Rpass-missed or >From 0d847f38c55423fd3bcae62c998f046a60e8287d Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan <kiran.chandramo...@arm.com> Date: Tue, 14 Jan 2025 13:46:16 +0000 Subject: [PATCH 4/6] Switch to BoolOptionWithoutMarshalling Flang does not use the Marshalling fields and the setting of CodegenOpts from Options.td. --- clang/include/clang/Driver/Options.td | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 854449bcab6364..56ffc682ee1cf7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3494,12 +3494,11 @@ def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group<f_Group>; def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group<f_Group>; def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group<f_Group>, Visibility<[ClangOption, FlangOption]>; -defm init_global_zero : BoolFOption<"init-global-zero", - CodeGenOpts<"InitGlobalZero">, DefaultTrue, +defm init_global_zero : BoolOptionWithoutMarshalling<"f", "init-global-zero", NegFlag<SetFalse, [], [FlangOption, FC1Option], "Zero initialize globals without default initialization">, PosFlag<SetTrue, [], [FlangOption, FC1Option], - "Do not zero initialize globals without default initialization">>; + "Do not zero initialize globals without default initialization (default)">>; def fno_pointer_tbaa : Flag<["-"], "fno-pointer-tbaa">, Group<f_Group>; def fno_temp_file : Flag<["-"], "fno-temp-file">, Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>, HelpText< >From 7339f631422e60579c2c271121b9399d80168bcc Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan <kiran.chandramo...@arm.com> Date: Tue, 14 Jan 2025 14:37:13 +0000 Subject: [PATCH 5/6] Fix formatting --- clang/lib/Driver/ToolChains/Flang.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 38f75e27ac00eb..c46e8222a9631a 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -156,8 +156,8 @@ void Flang::addCodegenOptions(const ArgList &Args, 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_ftime_report, options::OPT_ftime_report_EQ}); + options::OPT_fno_init_global_zero, options::OPT_ftime_report, + options::OPT_ftime_report_EQ}); } void Flang::addPicOptions(const ArgList &Args, ArgStringList &CmdArgs) const { >From 532eb671c9f71bbe8be3f44344b835c068a35b83 Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan <kiran.chandramo...@arm.com> Date: Wed, 15 Jan 2025 11:27:11 +0000 Subject: [PATCH 6/6] Minor syntax changes --- clang/include/clang/Driver/Options.td | 6 +++--- flang/lib/Frontend/CompilerInvocation.cpp | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f38c22fe973d72..7d8a161398882c 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3506,10 +3506,10 @@ def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group<f_Group>; def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group<f_Group>, Visibility<[ClangOption, FlangOption]>; defm init_global_zero : BoolOptionWithoutMarshalling<"f", "init-global-zero", - NegFlag<SetFalse, [], [FlangOption, FC1Option], - "Zero initialize globals without default initialization">, PosFlag<SetTrue, [], [FlangOption, FC1Option], - "Do not zero initialize globals without default initialization (default)">>; + "Do not zero initialize globals without default initialization (default)">, + NegFlag<SetFalse, [], [FlangOption, FC1Option], + "Zero initialize globals without default initialization">>; def fno_pointer_tbaa : Flag<["-"], "fno-pointer-tbaa">, Group<f_Group>; def fno_temp_file : Flag<["-"], "fno-temp-file">, Group<f_Group>, Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>, HelpText< diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index d70dd2c5f2dc23..78d1199c19749b 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1374,9 +1374,11 @@ bool CompilerInvocation::createFromArgs( } // -f[no-]init-global-zero - if (!args.hasFlag(clang::driver::options::OPT_finit_global_zero, - clang::driver::options::OPT_fno_init_global_zero, - /*default=*/true)) + if (args.hasFlag(clang::driver::options::OPT_finit_global_zero, + clang::driver::options::OPT_fno_init_global_zero, + /*default=*/true)) + invoc.loweringOpts.setInitGlobalZero(true); + else invoc.loweringOpts.setInitGlobalZero(false); // Preserve all the remark options requested, i.e. -Rpass, -Rpass-missed or _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits