Issue 87446
Summary [clang] Clang stack frame is too large in specific scenarios.
Labels clang
Assignees
Reporter CoTinker
    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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to