<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58729>58729</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] Slow compilation and high memory usage for htdp.f
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          hawkinsp
      </td>
    </tr>
</table>

<pre>
    The attached file is from [HTDP](https://geodesy.noaa.gov/TOOLS/Htdp/Htdp.shtml) version 3.2.5.
[htdp.zip](https://github.com/llvm/llvm-project/files/9910965/htdp.zip)

`flang-new` built from head as of today takes at least 2 minutes and more than 60GB of memory to compile this file. I don't know how much it takes in the end since I killed it once the memory usage reached that level.

Repro with`flang-new -c htdp.f`

`gfortran` compiles it reasonably quickly and compactly (25.6s, 566MB memory usage):

```
$ /usr/bin/time -v gfortran -c htdp.f
...
        Command being timed: "gfortran -c htdp.f"
        User time (seconds): 25.56
        System time (seconds): 0.46
        Percent of CPU this job got: 99%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:26.09
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 566388
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 134119
        Voluntary context switches: 11
        Involuntary context switches: 84
        Swaps: 0
        File system inputs: 0
        File system outputs: 21352
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVdtyozgQ_Rr80hUKxCXmwQ-5bHZStVNJbTLzLqABxUJikbDj-fptAZ6xvczOxIUlIfr05XSrlevysHltELi1vGiwhEpIBGGg6nULXnL76fX-2UvuPbZurO2MF9147IGeGnWJ5u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