rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.15k stars 12.56k forks source link

Do debug-info-preserving optimizations even in debug mode #77803

Open pcwalton opened 3 years ago

pcwalton commented 3 years ago

Debug mode, which is key to the edit-compile-run cycle, generates a lot more LLVM IR than equivalent C/C++ code does. For example, things like calls to ptr::write actually turn into procedure calls at the machine level, whereas they should really always be inlined. We could consider actually performing a subset of MIR optimizations in debug mode, to produce simpler IR and therefore to reduce compile time and improve performance of debug mode code. Naturally, these optimizations need to be carefully written to preserve DWARF debug info, but DWARF has many features designed to enable this sort of thing.

jonas-schievink commented 3 years ago

We already run most MIR optimizations in debug mode, IIRC the plan is to do the same for inlining (perhaps with a lower threshold than when optimizations are turned on).

pcwalton commented 3 years ago

I'm surprised that doing the optimizations doesn't harm debuggability.