Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] Clang stack frame is too large in specific scenarios. #87446

Closed
CoTinker opened this issue Apr 3, 2024 · 2 comments
Closed

[clang] Clang stack frame is too large in specific scenarios. #87446

CoTinker opened this issue Apr 3, 2024 · 2 comments
Labels
clang Clang issues not falling into any other category question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@CoTinker
Copy link
Contributor

CoTinker commented Apr 3, 2024

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.

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Apr 3, 2024
@efriedma-quic
Copy link
Collaborator

We currently don't do stack coloring at -O0.

(See also #45725 for more discussion of lifetime intrinsics...)

@CoTinker
Copy link
Contributor Author

CoTinker commented Apr 5, 2024

Got it, thank you.

@CoTinker CoTinker closed this as completed Apr 7, 2024
@EugeneZelenko EugeneZelenko added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

3 participants