[mir-opt] Introduce a new flag to enable experimental/unsound mir opts
This commit is contained in:
parent
7f7a1cbfd3
commit
b9d0ea95c8
20 changed files with 397 additions and 359 deletions
|
@ -31,9 +31,11 @@ pub struct CopyPropagation;
|
|||
|
||||
impl<'tcx> MirPass<'tcx> for CopyPropagation {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, _source: MirSource<'tcx>, body: &mut Body<'tcx>) {
|
||||
let opts = &tcx.sess.opts.debugging_opts;
|
||||
// We only run when the MIR optimization level is > 1.
|
||||
// This avoids a slow pass, and messing up debug info.
|
||||
if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 {
|
||||
// FIXME(76740): This optimization is buggy and can cause unsoundness.
|
||||
if opts.mir_opt_level <= 1 || !opts.unsound_mir_opts {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1115,6 +1115,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
|||
`hir,typed` (HIR with types for each node),
|
||||
`hir-tree` (dump the raw HIR),
|
||||
`mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
|
||||
unsound_mir_opts: bool = (false, parse_bool, [TRACKED],
|
||||
"enable unsound and buggy MIR optimizations (default: no)"),
|
||||
unstable_options: bool = (false, parse_bool, [UNTRACKED],
|
||||
"adds unstable command line options to rustc interface (default: no)"),
|
||||
use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue