[flang-commits] [flang] 8bc593c - [flang] Address TODO from previous changes to IsSaved()

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Tue Nov 30 10:40:03 PST 2021


Author: Peter Klausler
Date: 2021-11-30T10:39:51-08:00
New Revision: 8bc593cbbb1ae6aac6443132ae2d33c6513b1a2c

URL: https://github.com/llvm/llvm-project/commit/8bc593cbbb1ae6aac6443132ae2d33c6513b1a2c
DIFF: https://github.com/llvm/llvm-project/commit/8bc593cbbb1ae6aac6443132ae2d33c6513b1a2c.diff

LOG: [flang] Address TODO from previous changes to IsSaved()

An earlier fix to evaluate::IsSaved() needed to preserve its
treatment of named constants in modules and main programs -- i.e.
they would appear to be saved -- until a correction was added
to the lowering code.  This TODO can now be resolved.

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

Added: 
    

Modified: 
    flang/lib/Evaluate/tools.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Evaluate/tools.cpp b/flang/lib/Evaluate/tools.cpp
index bbfb46e53119e..4e8054f4f6f5f 100644
--- a/flang/lib/Evaluate/tools.cpp
+++ b/flang/lib/Evaluate/tools.cpp
@@ -1207,10 +1207,8 @@ bool IsSaved(const Symbol &original) {
     return false; // this is a component
   } else if (symbol.attrs().test(Attr::SAVE)) {
     return true; // explicit SAVE attribute
-  } else if (symbol.test(Symbol::Flag::InDataStmt)) {
-    return true;
   } else if (IsDummy(symbol) || IsFunctionResult(symbol) ||
-      IsAutomatic(symbol)) {
+      IsAutomatic(symbol) || IsNamedConstant(symbol)) {
     return false;
   } else if (scopeKind == Scope::Kind::Module ||
       (scopeKind == Scope::Kind::MainProgram &&
@@ -1228,13 +1226,8 @@ bool IsSaved(const Symbol &original) {
     // -fno-automatic/-save/-Msave option applies to objects in
     // executable subprograms unless they are explicitly RECURSIVE.
     return true;
-  } else if (IsNamedConstant(symbol)) {
-    // TODO: lowering needs named constants in modules to be static,
-    // so this test for a named constant has lower precedence for the
-    // time being; when lowering is corrected, this case should be
-    // moved up above module logic, since named constants don't really
-    // have implied SAVE attributes.
-    return false;
+  } else if (symbol.test(Symbol::Flag::InDataStmt)) {
+    return true;
   } else if (const auto *object{symbol.detailsIf<ObjectEntityDetails>()};
              object && object->init()) {
     return true;


        


More information about the flang-commits mailing list