Missed stack manipulation elision?

I am quite new to Rust, and was looking at compiled code to see how does it look like. The first thing I noticed, thanks to godbolt, is that small functions that are optimized to not to use the stack, still save and restore it through (in x86_64) rbp and push/pop. A very simple demonstration can be found here. Are we missing a possible elision optimization, or am I missing something?

When compiling with debug info, which godbolt needs to map the source to the assembler code, frame pointer omission is disabled. If you compile without debug info, you get the expected result.

4 Likes

Thank you! Exactly what you said. If -C debuginfo=0 is passed as option, everything is how I expected it to be! Sorry for my noobness :wink:

That's unfortunate. Many projects are compiled with at least -Cdebuginfo=1 for the backtraces even for optimized builds.

There’s an old issue:

Ideally, I’d like to see even full debuginfo with zero impact on codegen. For comparison, GCC even has the -fcompare-debug option you can use to make sure this is the case.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.