Unstable rustc internal attribute to disable optimizations on a module/function basis #87801
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
F-rustc_attrs
Internal rustc attributes gated on the `#[rustc_attrs]` feature gate.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Occasionally, it would be nice to use a debugger with rustc. However, currently the options generally available are to either compile with optimizations enabled which makes debugging difficult but the compiler performs reasonably or to disable optimizations which greatly increases the debugability but makes rustc unbearably slow in many situations.
It would be nice if we had the ability to to selectively disable optimizations at the function or module level via an attribute like
#[rustc_optnone]
. This would allow building most all of rustc with optimizations (thus retaining reasonable speed) while still allowing them to be disabled on a very small scale for the purpose of increased debugability.Other compilers offer similar functionality:
[[clang::optnone]]
__attribute__((optimize("O0")))
#pragma optimize( "", off )
For the LLVM backend, we would just need to adjust the functions' attributes to include
optnone
.The text was updated successfully, but these errors were encountered: