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

[X68] r270109 can create dead stack adjustments after noreturn calls (previously #27140 ) #42500

Closed
rnk opened this issue Aug 28, 2019 · 3 comments
Labels
backend:X86 bugzilla Issues migrated from bugzilla

Comments

@rnk
Copy link
Collaborator

rnk commented Aug 28, 2019

Bugzilla Link 43155
Resolution FIXED
Resolved on Aug 30, 2019 14:02
Version trunk
OS Windows NT
CC @topperc,@zmodem,@RKSimon,@rotateright

Extended Description

Here is my gnarly C test case to make this happen on Linux:

attribute((noreturn)) void exit_manyarg(int, int, int, int, int, int, int, int, int, int);
struct ByVal {
int vals[10];
};
struct ByVal getbyval();

void make_push_unprofitable(struct ByVal);
void bar();
extern int gv1, gv2, gv3, gv4, gv5, gv6, gv7, gv8, gv9, gv10;
int foo(int c) {
if (c)
exit_manyarg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
make_push_unprofitable(getbyval());
make_push_unprofitable(getbyval());
make_push_unprofitable(getbyval());
return 0;
}

$ clang -S -O2 check.c --target=x86_64-linux -o - -fPIC
...
callq exit_manyarg@PLT
subq $32, %rsp

This only happens with a noreturn function has stack arguments, which is rare for Linux. However for Win64, the caller must always reserve 32 bytes of stack space. Currently this bug doesn't happen on Win64, but I plan to make it stop setting TrapUnreachable, which will make it happen for all noreturn calls, and then it will matter.

@zmodem
Copy link
Collaborator

zmodem commented Aug 29, 2019

I thought r270109 was supposed to prevent this, not the other way around :-/

@rnk
Copy link
Collaborator Author

rnk commented Aug 30, 2019

r370409 should fix these cases.

I think when you were working on r270109 we were measuring code size of i686-windows-msvc for chromium, which uses /Oy- to preserve frame pointers, so the stack frame was frequently not reserved, which avoided this case.

@rnk
Copy link
Collaborator Author

rnk commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#45064

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants