Skip to content

Commit

Permalink
Add -Z orbit for forcing MIR for everything, unless #[rustc_no_mir] i…
Browse files Browse the repository at this point in the history
…s used.
  • Loading branch information
eddyb committed Mar 10, 2016
1 parent b3747a5 commit f3f9de7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions configure
Expand Up @@ -607,6 +607,7 @@ opt dist-host-only 0 "only install bins for the host architecture"
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
opt llvm-version-check 1 "check if the LLVM version is supported, build anyway"
opt rustbuild 0 "use the rust and cargo based build system"
opt orbit 0 "get MIR where it belongs - everywhere; most importantly, in orbit"

# Optimization and debugging options. These may be overridden by the release channel, etc.
opt_nosave optimize 1 "build optimized rust code"
Expand Down Expand Up @@ -713,6 +714,8 @@ if [ -n "$CFG_ENABLE_DEBUG_ASSERTIONS" ]; then putvar CFG_ENABLE_DEBUG_ASSERTION
if [ -n "$CFG_ENABLE_DEBUGINFO" ]; then putvar CFG_ENABLE_DEBUGINFO; fi
if [ -n "$CFG_ENABLE_DEBUG_JEMALLOC" ]; then putvar CFG_ENABLE_DEBUG_JEMALLOC; fi

if [ -n "$CFG_ENABLE_ORBIT" ]; then putvar CFG_ENABLE_ORBIT; fi

# A magic value that allows the compiler to use unstable features
# during the bootstrap even when doing so would normally be an error
# because of feature staging or because the build turns on
Expand Down
5 changes: 5 additions & 0 deletions mk/main.mk
Expand Up @@ -134,6 +134,11 @@ ifdef CFG_ENABLE_DEBUGINFO
CFG_RUSTC_FLAGS += -g
endif

ifdef CFG_ENABLE_ORBIT
$(info cfg: launching MIR (CFG_ENABLE_ORBIT))
CFG_RUSTC_FLAGS += -Z orbit
endif

ifdef SAVE_TEMPS
CFG_RUSTC_FLAGS += --save-temps
endif
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/session/config.rs
Expand Up @@ -659,6 +659,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"print the result of the translation item collection pass"),
mir_opt_level: Option<usize> = (None, parse_opt_uint,
"set the MIR optimization level (0-3)"),
orbit: bool = (false, parse_bool,
"get MIR where it belongs - everywhere; most importantly, in orbit"),
}

pub fn default_lib_output() -> CrateType {
Expand Down
6 changes: 4 additions & 2 deletions src/librustc_trans/trans/base.rs
Expand Up @@ -1432,7 +1432,9 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
};

let check_attrs = |attrs: &[ast::Attribute]| {
attrs.iter().any(|item| item.check_name("rustc_mir"))
let default_to_mir = ccx.sess().opts.debugging_opts.orbit;
let invert = if default_to_mir { "rustc_no_mir" } else { "rustc_mir" };
default_to_mir ^ attrs.iter().any(|item| item.check_name(invert))
};

let use_mir = if let Some(id) = local_id {
Expand Down Expand Up @@ -1464,13 +1466,13 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
};

FunctionContext {
needs_ret_allocas: nested_returns && mir.is_none(),

This comment has been minimized.

Copy link
@nikomatsakis

nikomatsakis Mar 15, 2016

this was just a bug before I guess? (the case of nested_returns && mir.is_some())

This comment has been minimized.

Copy link
@eddyb

eddyb Mar 15, 2016

Author Owner

Yeah. Ideally, MIR would not use the old trans return logic, but for now there's no point duplicating it.

mir: mir,
llfn: llfndecl,
llretslotptr: Cell::new(None),
param_env: ccx.tcx().empty_parameter_environment(),
alloca_insert_pt: Cell::new(None),
llreturn: Cell::new(None),
needs_ret_allocas: nested_returns,
landingpad_alloca: Cell::new(None),
lllocals: RefCell::new(NodeMap()),
llupvars: RefCell::new(NodeMap()),
Expand Down
12 changes: 8 additions & 4 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -347,10 +347,14 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat
"the `#[rustc_move_fragments]` attribute \
is just used for rustc unit tests \
and will never be stable")),
("rustc_mir", Normal, Gated("rustc_attrs",
"the `#[rustc_mir]` attribute \
is just used for rustc unit tests \
and will never be stable")),
("rustc_mir", Whitelisted, Gated("rustc_attrs",
"the `#[rustc_mir]` attribute \
is just used for rustc unit tests \
and will never be stable")),
("rustc_no_mir", Whitelisted, Gated("rustc_attrs",
"the `#[rustc_no_mir]` attribute \
is just used to make tests pass \
and will never be stable")),

("allow_internal_unstable", Normal, Gated("allow_internal_unstable",
EXPLAIN_ALLOW_INTERNAL_UNSTABLE)),
Expand Down

0 comments on commit f3f9de7

Please sign in to comment.