[all-commits] [llvm/llvm-project] 996ef8: [flang] Add -fno-automatic, refine IsSaved()

Peter Klausler via All-commits all-commits at lists.llvm.org
Mon Nov 22 10:06:56 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 996ef895cd3d1313665a42fc8e20d1d4e1cf2a28
      https://github.com/llvm/llvm-project/commit/996ef895cd3d1313665a42fc8e20d1d4e1cf2a28
  Author: Peter Klausler <pklausler at nvidia.com>
  Date:   2021-11-22 (Mon, 22 Nov 2021)

  Changed paths:
    M clang/include/clang/Driver/Options.td
    M clang/lib/Driver/ToolChains/Flang.cpp
    M flang/include/flang/Common/Fortran-features.h
    M flang/include/flang/Evaluate/tools.h
    M flang/include/flang/Semantics/tools.h
    M flang/lib/Evaluate/tools.cpp
    M flang/lib/Frontend/CompilerInvocation.cpp
    M flang/lib/Semantics/resolve-names-utils.cpp
    M flang/lib/Semantics/runtime-type-info.cpp
    M flang/lib/Semantics/tools.cpp
    M flang/test/Driver/driver-help-hidden.f90
    M flang/test/Driver/driver-help.f90
    M flang/test/Semantics/entry01.f90
    M flang/test/Semantics/save01.f90
    A flang/test/Semantics/save02.f90

  Log Message:
  -----------
  [flang] Add -fno-automatic, refine IsSaved()

This legacy option (available in other Fortran compilers with various
spellings) implies the SAVE attribute for local variables on subprograms
that are not explicitly RECURSIVE.  The SAVE attribute essentially implies
static rather than stack storage.  This was the default setting in Fortran
until surprisingly recently, so explicit SAVE statements & attributes
could be and often were omitted from older codes.  Note that initialized
objects already have an implied SAVE attribute, and objects in COMMON
effectively do too, as data overlays are extinct; and since objects that are
expected to survive from one invocation of a procedure to the next in static
storage should probably be explicit initialized in the first place, so the
use cases for this option are somewhat rare, and all of them could be
handled with explicit SAVE statements or attributes.

This implicit SAVE attribute must not apply to automatic (in the Fortran sense)
local objects, whose sizes cannot be known at compilation time.  To get the
semantics of IsSaved() right, the IsAutomatic() predicate was moved into
Evaluate/tools.cpp to allow for dynamic linking of the compiler.  The
redundant predicate IsAutomatic() was noticed, removed, and its uses replaced.

GNU Fortran's spelling of the option (-fno-automatic) was added to
the clang-based driver and used for basic sanity testing.

Differential Revision: https://reviews.llvm.org/D114209




More information about the All-commits mailing list