From c593e3d0f77509ce65a6f5bd744f2d1ea9935c47 Mon Sep 17 00:00:00 2001 From: Kiran Chandramohan Date: Wed, 15 Jan 2025 15:06:57 +0000 Subject: =?UTF-8?q?[Flang][Driver]=20Add=20a=20flag=20to=20control=20zero?= =?UTF-8?q?=20initialization=20of=20global=20v=E2=80=A6=20(#122144)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …ariables Patch adds a flag to control zero initialization of global variables without default initialization. The default is to zero initialize. --- flang/lib/Frontend/CompilerInvocation.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'flang/lib/Frontend/CompilerInvocation.cpp') diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 5e71273..78d1199 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1373,6 +1373,14 @@ bool CompilerInvocation::createFromArgs( invoc.loweringOpts.setNoPPCNativeVecElemOrder(true); } + // -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(true); + else + 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 // remarks generated by LLVM in ExecuteCompilerInvocation.cpp. -- cgit v1.1