[flang-commits] [flang] [flang] Set SAVE attribute for EQUIVALENCEd symbols consistently. (PR #67078)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Fri Sep 22 15:57:01 PDT 2023


================
@@ -2390,7 +2390,7 @@ Symbol &ScopeHandler::MakeHostAssocSymbol(
   // These attributes can be redundantly reapplied without error
   // on the host-associated name, at most once (C815).
   symbol.implicitAttrs() =
-      symbol.attrs() & Attrs{Attr::ASYNCHRONOUS, Attr::VOLATILE};
+      symbol.attrs() & Attrs{Attr::ASYNCHRONOUS, Attr::VOLATILE, Attr::SAVE};
----------------
vzakhari wrote:

For this:
```
subroutine host
  integer :: x = 1
  integer :: y
  common /blk/ y
  equivalence(x,y)
contains
  subroutine inner
    save x
    save y
    x = y
  end subroutine inner
end subroutine host
```

I get this:
```
  Subprogram scope: host size=0 alignment=1 sourceRange=164 bytes
    .F18.0, SAVE (CompilerCreated) size=4 offset=0: ObjectEntity type: INTEGER(4) shape: 1_8:1_8 init:[INTEGER(4)::1_4]
    host (Subroutine): HostAssoc
    inner (Subroutine): Subprogram ()
    x, SAVE size=4 offset=0: ObjectEntity type: INTEGER(4) init:1_4
    y, SAVE size=4 offset=0: ObjectEntity type: INTEGER(4)
    Equivalence Sets: (x,y) (.F18.0,y)
    blk size=4 offset=0: CommonBlockDetails alignment=4: y
    Subprogram scope: inner size=8 alignment=4 sourceRange=57 bytes
      inner (Subroutine): HostAssoc
      x, SAVE (Implicit) size=4 offset=0: ObjectEntity type: REAL(4)
      y, SAVE (Implicit) size=4 offset=4: ObjectEntity type: REAL(4)
```

So the new symbols are created.

I will upload an update shortly.

https://github.com/llvm/llvm-project/pull/67078


More information about the flang-commits mailing list