Missed stack manipulation elision?


#1

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?


#2

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.


#3

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:


#4

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


#5

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.