<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/76478>76478</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Compilation of a derived type which has many members of other derived types needs a lot of time
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yus3710-fj
</td>
</tr>
</table>
<pre>
This is an issue from Fujitsu testsuite.
Flang-new needs a lot of time to compile the following code.
(The compilation command is executed with `ulimit -t 300` in Fujitsu testsuite.)
The following are the test program, the result of `time` command of flang-new and gfortran compilation.
```fortran
! test.f90
type x00a
integer::x00a000
type(x00e),pointer::x00e110
end type
type x00b
type(x00e),pointer::x00e110,x00e111,x00e112,x00e113,x00e114,x00e115,x00e116,x00e117,x00e118,x00e119,&
x00e120,x00e121,x00e122,x00e123,x00e124,x00e125,x00e126,x00e127,x00e128,x00e129,&
x00e130,x00e131,x00e132,x00e133,x00e134,x00e135,x00e136,x00e137,x00e138,x00e139,&
x00e140,x00e141,x00e142,x00e143,x00e144,x00e145,x00e146,x00e147,x00e148,x00e149,&
x00e150,x00e151,x00e152,x00e153,x00e154,x00e155,x00e156,x00e157,x00e158,x00e159
type(x00a),pointer::x00b000,x00b001,x00b002,x00b003,x00b004,x00b005,x00b006,x00b007,x00b008,x00b009
type(x00b),pointer::x00c000,x00c001,x00c002,x00c003,x00c004,x00c005,x00c006,x00c007,x00c008,x00c009
type(x00c),pointer::x00d000,x00d001,x00d002,x00d003,x00d004,x00d005,x00d006,x00d007,x00d008,x00d009
type(x00d),pointer::x00e000,x00e001,x00e002,x00e003,x00e004,x00e005,x00e006,x00e007,x00e008,x00e009,&
x00e010,x00e011,x00e012,x00e013,x00e014,x00e015,x00e016,x00e017,x00e018,x00e019,&
x00e020,x00e021,x00e022,x00e023,x00e024,x00e025,x00e026,x00e027,x00e028,x00e029,&
x00e030,x00e031,x00e032,x00e033,x00e034,x00e035,x00e036,x00e037,x00e038,x00e039,&
x00e040,x00e041,x00e042,x00e043,x00e044,x00e045,x00e046,x00e047,x00e048,x00e049,&
x00e050,x00e051,x00e052,x00e053,x00e054,x00e055,x00e056,x00e057,x00e058,x00e059
end type
type x00c
type(x00e),pointer::x00e110,x00e111,x00e112,x00e113,x00e114,x00e115,x00e116,x00e117,x00e118,x00e119,&
x00e120,x00e121,x00e122,x00e123,x00e124,x00e125,x00e126,x00e127,x00e128,x00e129,&
x00e130,x00e131,x00e132,x00e133,x00e134,x00e135,x00e136,x00e137,x00e138,x00e139,&
x00e140,x00e141,x00e142,x00e143,x00e144,x00e145,x00e146,x00e147,x00e148,x00e149,&
x00e150,x00e151,x00e152,x00e153,x00e154,x00e155,x00e156,x00e157,x00e158,x00e159
type(x00b),pointer::x00c000,x00c001,x00c002,x00c003,x00c004,x00c005,x00c006,x00c007,x00c008,x00c009
type(x00a),pointer::x00b000,x00b001,x00b002,x00b003,x00b004,x00b005,x00b006,x00b007,x00b008,x00b009
type(x00c),pointer::x00d000,x00d001,x00d002,x00d003,x00d004,x00d005,x00d006,x00d007,x00d008,x00d009
type(x00d),pointer::x00e000,x00e001,x00e002,x00e003,x00e004,x00e005,x00e006,x00e007,x00e008,x00e009,&
x00e010,x00e011,x00e012,x00e013,x00e014,x00e015,x00e016,x00e017,x00e018,x00e019,&
x00e020,x00e021,x00e022,x00e023,x00e024,x00e025,x00e026,x00e027,x00e028,x00e029,&
x00e030,x00e031,x00e032,x00e033,x00e034,x00e035,x00e036,x00e037,x00e038,x00e039,&
x00e040,x00e041,x00e042,x00e043,x00e044,x00e045,x00e046,x00e047,x00e048,x00e049,&
x00e050,x00e051,x00e052,x00e053,x00e054,x00e055,x00e056,x00e057,x00e058,x00e059
end type
type x00d
type(x00e),pointer::x00e110,x00e111,x00e112,x00e113,x00e114,x00e115,x00e116,x00e117,x00e118,x00e119,&
x00e120,x00e121,x00e122,x00e123,x00e124,x00e125,x00e126,x00e127,x00e128,x00e129,&
x00e130,x00e131,x00e132,x00e133,x00e134,x00e135,x00e136,x00e137,x00e138,x00e139,&
x00e140,x00e141,x00e142,x00e143,x00e144,x00e145,x00e146,x00e147,x00e148,x00e149,&
x00e150,x00e151,x00e152,x00e153,x00e154,x00e155,x00e156,x00e157,x00e158,x00e159
type(x00d),pointer::x00e010,x00e011,x00e012,x00e013,x00e014,x00e015,x00e016,x00e017,x00e018,x00e019,&
x00e020,x00e021,x00e022,x00e023,x00e024,x00e025,x00e026,x00e027,x00e028,x00e029,&
x00e030,x00e031,x00e032,x00e033,x00e034,x00e035,x00e036,x00e037,x00e038,x00e039,&
x00e040,x00e041,x00e042,x00e043,x00e044,x00e045,x00e046,x00e047,x00e048,x00e049,&
x00e050,x00e051,x00e052,x00e053,x00e054,x00e055,x00e056,x00e057,x00e058,x00e059
type(x00c),pointer::x00d000,x00d001,x00d002,x00d003,x00d004,x00d005,x00d006,x00d007,x00d008,x00d009
type(x00b),pointer::x00c000,x00c001,x00c002,x00c003,x00c004,x00c005,x00c006,x00c007,x00c008,x00c009
type(x00a),pointer::x00b000,x00b001,x00b002,x00b003,x00b004,x00b005,x00b006,x00b007,x00b008,x00b009
end type
type x00e
type(x00e),pointer::x00e110,x00e111,x00e112,x00e113,x00e114,x00e115,x00e116,x00e117,x00e118,x00e119,&
x00e120,x00e121,x00e122,x00e123,x00e124,x00e125,x00e126,x00e127,x00e128,x00e129,&
x00e130,x00e131,x00e132,x00e133,x00e134,x00e135,x00e136,x00e137,x00e138,x00e139,&
x00e140,x00e141,x00e142,x00e143,x00e144,x00e145,x00e146,x00e147,x00e148,x00e149,&
x00e150,x00e151,x00e152,x00e153,x00e154,x00e155,x00e156,x00e157,x00e158,x00e159
type(x00d),pointer::x00e010,x00e011,x00e012,x00e013,x00e014,x00e015,x00e016,x00e017,x00e018,x00e019,&
x00e020,x00e021,x00e022,x00e023,x00e024,x00e025,x00e026,x00e027,x00e028,x00e029,&
x00e030,x00e031,x00e032,x00e033,x00e034,x00e035,x00e036,x00e037,x00e038,x00e039,&
x00e040,x00e041,x00e042,x00e043,x00e044,x00e045,x00e046,x00e047,x00e048,x00e049,&
x00e050,x00e051,x00e052,x00e053,x00e054,x00e055,x00e056,x00e057,x00e058,x00e059
type(x00c),pointer::x00d000,x00d001,x00d002,x00d003,x00d004,x00d005,x00d006,x00d007,x00d008,x00d009
type(x00b),pointer::x00c000,x00c001,x00c002,x00c003,x00c004,x00c005,x00c006,x00c007,x00c008,x00c009
type(x00a),pointer::x00b000,x00b001,x00b002,x00b003,x00b004,x00b005,x00b006,x00b007,x00b008,x00b009
end type
type(x00a),pointer::p0a
end
```
```console
$ time flang-new -v test.f90
flang-new version 18.0.0git (https://github.com/llvm/llvm-project.git 0e07bf91f7e3d5a53f0a51309da12e91ea8accc9)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
Found candidate GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
Selected GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +neon -target-feature +v8a -mframe-pointer=non-leaf -o test.o -x f95-cpp-input test.f90
real 5m35.269s
user 1m7.805s
sys 4m22.249s
```
```console
$ time gfortran -v test.f90
Driving: gfortran -v test.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/8/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC)
:
real 0m0.144s
user 0m0.082s
sys 0m0.028s
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsmk9v4zjSxj-NciFolCnJfw45pO3xvC_QwAx6s9hjgyJLMtMSqSWpxJlPv6BklxO304PBDhZ9MBA4dKnE5yFN_koAJUMwjUW8z8pPWbm9k0PcO3__OoR8OQdeP91VTr_eP-5NYCYwaZkJYUBWe9ex3fBkYhhYxBDDYCLOMthm8DB97lppG27xhVlEHZhkrYvM1SyaDll0TLmuNy2yuEdWu7Z1L8Y2TDlN_YjV4x6PeTIaZ1O7k1YnL3hANUTU7MXEPcsWMLSmM5HxyHKAbAHM2GsWxfqty8d34tJPdlI6671rvOwysRljHsPQjgPIFpDGkCROflzNahpvCjS189FL-9b9u-nJFjD9HRNPQ56P4rN6DVOEMRZfe2QHAHmMGBuxQZ_lD1n-kOIA5-QpPROrAwCmwYpN79Id53ycz8_5aPV0xxQ4aVVvvv95Z2IztebUEtTKqVVQq6TWglpLaq2olQQzsTh6GWOC1ASpCVITpCZITZCaIDVBaoLUxBW1nNRyUstJLSe1nNRyUstJLSe1nNTyK2oFqRWkVpBaQWoFqRWkVpBaQWoFqRVX1EpSK0mtJLWS1EpSK0mtJLWS1EpSK9ffrR55ffVUaemOd1UAc2oJauXUKqhVUmtBrSW1VtT63kV13YUiF4pcKHKhyIUiF4pcKHKhyIUiF-qaC3XdhSYXmlxocqHJhSYXmlxocqHJhSYX-poL_cF-JhdILpBcILlAcoHkAskFkgskF5hcXK5CIHoA0QOIHkD0AKIHED2A6AFEDyB6wBV6ANEDiB5A9ACiBxA9gOgBRA8g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