[flang-commits] [PATCH] D121603: [flang] fulfill -Msave/-fno-automatic in main programs too
Jean Perier via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Mar 14 08:21:32 PDT 2022
jeanPerier created this revision.
jeanPerier added a reviewer: klausler.
jeanPerier added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.
`semantics::IsSaved()` was not applying -Msave/-fno-automatic for main programs.
This caused issues since lowering relies on it to allocate static
variables. This did not match nvfortran/gfortran behaviors where
-fno-automatic/-Msave control the static allocation of scalars in
main programs.
Some program may rely on main program scalars to be statically allocated in
bss (and therefore initialized to zero) with -Msave/-fno-automatic
flags.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121603
Files:
flang/lib/Evaluate/tools.cpp
Index: flang/lib/Evaluate/tools.cpp
===================================================================
--- flang/lib/Evaluate/tools.cpp
+++ flang/lib/Evaluate/tools.cpp
@@ -1324,12 +1324,14 @@
// BLOCK DATA entities must all be in COMMON,
// which was checked above.
return true;
- } else if (scope.kind() == Scope::Kind::Subprogram &&
- scope.context().languageFeatures().IsEnabled(
- common::LanguageFeature::DefaultSave) &&
- !(scope.symbol() && scope.symbol()->attrs().test(Attr::RECURSIVE))) {
- // -fno-automatic/-save/-Msave option applies to objects in
- // executable subprograms unless they are explicitly RECURSIVE.
+ } else if (scope.context().languageFeatures().IsEnabled(
+ common::LanguageFeature::DefaultSave) &&
+ (scopeKind == Scope::Kind::MainProgram ||
+ (scope.kind() == Scope::Kind::Subprogram &&
+ !(scope.symbol() &&
+ scope.symbol()->attrs().test(Attr::RECURSIVE))))) {
+ // -fno-automatic/-save/-Msave option applies to all objects in executable
+ // main programs and subprograms unless they are explicitly RECURSIVE.
return true;
} else if (symbol.test(Symbol::Flag::InDataStmt)) {
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121603.415098.patch
Type: text/x-patch
Size: 1245 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220314/142f348c/attachment.bin>
More information about the flang-commits
mailing list