Skip to content

Too many variables are created in some cases #611

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

Open
antoyo opened this issue Jan 27, 2025 · 12 comments
Open

Too many variables are created in some cases #611

antoyo opened this issue Jan 27, 2025 · 12 comments
Labels

Comments

@antoyo
Copy link
Contributor

antoyo commented Jan 27, 2025

Like in this case before this fix.

@antoyo antoyo added the perf label Jan 27, 2025
@FractalFir
Copy link
Contributor

Do you have any concrete examples of this ?

I think this is related to the huge stack usage we see when building rustc, but a smaller example would be better.

@antoyo
Copy link
Contributor Author

antoyo commented May 25, 2025

There was an AVX-512 test in stdarch that would do a stack overflow. I don't remember exactly which one, but I have talked a bit about this in this blog article.

If you revert this fix, you should be able to reproduce it.

However, I'm not sure that's related to the stack usage issue you have when building rustc because this issue is about stack usage in the resulting program.
Or maybe it is since in your case the resulting program is rustc?
Do you know which function uses a lot of stack space?
If so, you could try looking at the GIMPLE output for this function to get an idea of what's going on.

@FractalFir
Copy link
Contributor

FractalFir commented May 25, 2025 via email

@antoyo
Copy link
Contributor Author

antoyo commented May 25, 2025

Can you please tell me which function it is?
We had such a weird stack overflow in the past. Maybe it is related.

@FractalFir
Copy link
Contributor

FractalFir commented May 25, 2025 via email

@antoyo
Copy link
Contributor Author

antoyo commented May 26, 2025

Ok, so this is not the function I had issues with in the past.
Don't hesitate to ask if you need help to debug this issue.

@FractalFir
Copy link
Contributor

I was wrong: it is actually 37 K recursive calls to verify_vssa. It seems like those calls happen when compiling the function with symbol _RNvNtNtCsgG9CEInw1aP_17rustc_codegen_gcc9intrinsic4llvm9intrinsic (rustc_codegen_gcc::intrinsic::llvm::intrinsic).

That function is full of string constants - maybe we handle them inefficently?

@FractalFir
Copy link
Contributor

This seems to just be the case of "20 K string constants in one function is a lot". All I need to replicate the crash is try to compile archs.rs.

I don't know if there is a good way to fix this long-term(in cg_gcc), but, for now, we can change the way archs.rs is generated to make it more efficent(in terms of runtime and compiletime performance).

@antoyo
Copy link
Contributor Author

antoyo commented May 26, 2025

I thought verify_vssa would recurse on basic blocks (it would also make sense that the problem is a huge number of basic blocks since archs.rs contains a huge match expression).
Are you sure the problem are string constants?
Also, aren't string constants supposed to be globals?

@antoyo
Copy link
Contributor Author

antoyo commented May 26, 2025

Seems like a known issue in GCC.

@FractalFir
Copy link
Contributor

FractalFir commented May 26, 2025

I did not know it recursed on blocks, I kind of guestimated what the cause could be.

Still, we have 10 K branches of the match, so this is a problem either way. I have a commit ready that splits the function into separate, per-arch sub functions.

@antoyo
Copy link
Contributor Author

antoyo commented May 26, 2025

Ok, this is a good workaround for now.

Would you be interested in trying to fix the bug in GCC in the future?
If not, I'll look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants