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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Clang stack frame is too large in specific scenarios.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    test.c
```
#define PERROR(fmt)                  \
  do {                               \
    char dbg_buffer[4096 +1]={0};    \
  } while(0);

void foo() {
  PERROR("/opt/1");
  PERROR("/opt/2");
  PERROR("/opt/3");
}
```
clang
```
% clang test.c -o test.s -S -O0
foo:                                    // @foo
        stp     x29, x30, [sp, #-32]!           // 16-byte Folded Spill
        str     x28, [sp, #16]                  // 8-byte Folded Spill
        mov     x29, sp
        sub     sp, sp, #3, lsl #12             // =12288
  ...
```
gcc
```
% gcc test.c -o test.s -S -O0
foo:
        mov     x12, 4128
        sub     sp, sp, x12
  ...
```
https://godbolt.org/z/od5Yc1zKr
clang is 12288,while gcc is only 4128. It seems that  clang is (PERROR nums * struct size), and gcc is more reasonable.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVEFvpDgT_TXFpdTILgNNHziEZpA-fYdZZfayp5UBQ3vHYIRNdpJfvzJ0MqNOWhnU6sKi6vm9Vy5L5_QwKVVAWkJaRXL1F7sUZ_unnr6rJWps91x45XzcAquAPUDGrr99SaJTvZ4U_vHl8fHrI1Dejx7ohO8eSM97DWJnEY7l-5R7-YjtRS7YNcPfzdr3aoG0TNgpQ6CSQ1qBqOBYMjhWIMqbWjhW-O9FGwWUM6ATiPJKfft_srrD3lqgPLCGY_la-CYIiIBqO3ugmm-LnyB30uj30sRNWhDwkcutkdNwx_8Ut6-4NwkPdn9zePiGh6_XtCBQPHxi-O461UA1QsJCzZv_4XF-3uIPOgGd8YdgIUBaunl7IXEQFLpB_D0gzw7Ns1dYW9OpDr_N2phb-OUKn9_i8gzS6i7X_DPk0T79StzNNxuvzR7n69d9UxGicWYjQB-aJCpOlOevcHEcf9ikob03PCkObfs7rbsjiFMgmXDKP5cUkj8hevF-dmG3Td9gu8YaH9tlAKpfwqnt0r9a_vL_5Zdjidrh7sKXGsoz5Odt2jZh2qGdzPNGMMb_eXRKjQ79RXrEt2qgfJ8OnNYxLB_CWVhbj06_KNibJqfuFXK0i8JFSWcn2RgVR10hupM4yUgV_MiJ85Q4iy4F8eSU5FlPkqcJdZ3seaayXqQpU32W5ZEuiFHCEiaYEEKwmKQKUKSaPuXNSULC1Ci1iY15GoMRkXZuVUV-TJIsMrJRxm1XJ9E-oxQGIFqKkH9o1sFBwox23v1E8Nqb7b7dK9IKz5sTzsv2O_aLHFVQ6a1FI5dBoZ7QzarVvW7RtWqSi7YujtbFFDcN0_6yNnFrR6A67HcNh3mx_6g23DgbfQdUbwr-CwAA__9Y244h">