Skip to content

Commit

Permalink
Disable old trans access via -Z orbit, #[rustc_no_mir] or --disable-o…
Browse files Browse the repository at this point in the history
…rbit.
  • Loading branch information
eddyb committed Aug 24, 2016
1 parent a66fa96 commit cb9b0ed
Show file tree
Hide file tree
Showing 81 changed files with 68 additions and 422 deletions.
2 changes: 0 additions & 2 deletions configure
Expand Up @@ -733,8 +733,6 @@ 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_DISABLE_ORBIT" ]; then putvar CFG_DISABLE_ORBIT; fi

step_msg "looking for build programs"

probe_need CFG_CURL curl
Expand Down
6 changes: 0 additions & 6 deletions mk/main.mk
Expand Up @@ -162,12 +162,6 @@ ifdef CFG_ENABLE_DEBUGINFO
CFG_RUSTC_FLAGS += -g
endif

ifdef CFG_DISABLE_ORBIT
$(info cfg: HOLD HOLD HOLD (CFG_DISABLE_ORBIT))
RUSTFLAGS_STAGE1 += -Z orbit=off
RUSTFLAGS_STAGE2 += -Z orbit=off
endif

ifdef SAVE_TEMPS
CFG_RUSTC_FLAGS += -C save-temps
endif
Expand Down
35 changes: 1 addition & 34 deletions src/librustc/session/config.rs
Expand Up @@ -605,8 +605,6 @@ macro_rules! options {
pub const parse_bool: Option<&'static str> = None;
pub const parse_opt_bool: Option<&'static str> =
Some("one of: `y`, `yes`, `on`, `n`, `no`, or `off`");
pub const parse_all_bool: Option<&'static str> =
Some("one of: `y`, `yes`, `on`, `n`, `no`, or `off`");
pub const parse_string: Option<&'static str> = Some("a string");
pub const parse_opt_string: Option<&'static str> = Some("a string");
pub const parse_list: Option<&'static str> = Some("a space-separated list of strings");
Expand Down Expand Up @@ -656,25 +654,6 @@ macro_rules! options {
}
}

fn parse_all_bool(slot: &mut bool, v: Option<&str>) -> bool {
match v {
Some(s) => {
match s {
"n" | "no" | "off" => {
*slot = false;
}
"y" | "yes" | "on" => {
*slot = true;
}
_ => { return false; }
}

true
},
None => { *slot = true; true }
}
}

fn parse_opt_string(slot: &mut Option<String>, v: Option<&str>) -> bool {
match v {
Some(s) => { *slot = Some(s.to_string()); true },
Expand Down Expand Up @@ -930,8 +909,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"dump MIR state at various points in translation"),
dump_mir_dir: Option<String> = (None, parse_opt_string, [UNTRACKED],
"the directory the MIR is dumped into"),
orbit: bool = (true, parse_all_bool, [UNTRACKED],
"get MIR where it belongs - everywhere; most importantly, in orbit"),
}

pub fn default_lib_output() -> CrateType {
Expand Down Expand Up @@ -1324,15 +1301,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
})
});

let mut debugging_opts = build_debugging_options(matches, error_format);

// Incremental compilation only works reliably when translation is done via
// MIR, so let's enable -Z orbit if necessary (see #34973).
if debugging_opts.incremental.is_some() && !debugging_opts.orbit {
early_warn(error_format, "Automatically enabling `-Z orbit` because \
`-Z incremental` was specified");
debugging_opts.orbit = true;
}
let debugging_opts = build_debugging_options(matches, error_format);

let mir_opt_level = debugging_opts.mir_opt_level.unwrap_or(1);

Expand Down Expand Up @@ -2424,8 +2393,6 @@ mod tests {
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.debugging_opts.dump_mir_dir = Some(String::from("abc"));
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
opts.debugging_opts.orbit = false;
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());

// Make sure changing a [TRACKED] option changes the hash
opts = reference.clone();
Expand Down
25 changes: 9 additions & 16 deletions src/librustc_trans/base.rs
Expand Up @@ -1424,26 +1424,17 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
false
};

let check_attrs = |attrs: &[ast::Attribute]| {
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)),
attrs.iter().any(|item| item.check_name("no_debug")))
};

let (use_mir, no_debug) = if let Some(id) = local_id {
check_attrs(ccx.tcx().map.attrs(id))
let no_debug = if let Some(id) = local_id {
ccx.tcx().map.attrs(id)
.iter().any(|item| item.check_name("no_debug"))
} else if let Some(def_id) = def_id {
check_attrs(&ccx.sess().cstore.item_attrs(def_id))
ccx.sess().cstore.item_attrs(def_id)
.iter().any(|item| item.check_name("no_debug"))
} else {
check_attrs(&[])
false
};

let mir = if use_mir {
def_id.and_then(|id| ccx.get_mir(id))
} else {
None
};
let mir = def_id.and_then(|id| ccx.get_mir(id));

let debug_context = if let (false, Some(definition)) = (no_debug, definition) {
let (instance, sig, abi, _) = definition;
Expand Down Expand Up @@ -1846,6 +1837,8 @@ pub fn trans_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,

if fcx.mir.is_some() {
return mir::trans_mir(&fcx);
} else {
span_bug!(body.span, "attempted translation of `{}` w/o MIR", instance);
}

debuginfo::fill_scope_map_for_function(&fcx, decl, body, inlined_id);
Expand Down
19 changes: 0 additions & 19 deletions src/librustc_trans/closure.rs
Expand Up @@ -181,16 +181,6 @@ fn get_or_create_closure_declaration<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
llfn
}

fn translating_closure_body_via_mir_will_fail(ccx: &CrateContext,
closure_def_id: DefId)
-> bool {
let default_to_mir = ccx.sess().opts.debugging_opts.orbit;
let invert = if default_to_mir { "rustc_no_mir" } else { "rustc_mir" };
let use_mir = default_to_mir ^ ccx.tcx().has_attr(closure_def_id, invert);

!use_mir
}

pub fn trans_closure_body_via_mir<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
closure_def_id: DefId,
closure_substs: ty::ClosureSubsts<'tcx>) {
Expand Down Expand Up @@ -362,15 +352,6 @@ pub fn trans_closure_method<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
closure_def_id,
substs);
} else {
// If the closure is defined in an upstream crate, we can only
// translate it if MIR-trans is active.

if translating_closure_body_via_mir_will_fail(ccx, closure_def_id) {
ccx.sess().fatal("You have run into a known limitation of the \
MingW toolchain. Either compile with -Zorbit or \
with -Ccodegen-units=1 to work around it.");
}

trans_closure_body_via_mir(ccx, closure_def_id, substs);
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/librustc_trans/consts.rs
Expand Up @@ -1150,12 +1150,7 @@ pub fn trans_static(ccx: &CrateContext,
let def_id = ccx.tcx().map.local_def_id(id);
let datum = get_static(ccx, def_id);

let check_attrs = |attrs: &[ast::Attribute]| {
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 = check_attrs(ccx.tcx().map.attrs(id));
let use_mir = true;

let v = if use_mir {
::mir::trans_static_initializer(ccx, def_id)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/mir/mod.rs
Expand Up @@ -145,7 +145,7 @@ impl<'tcx> LocalRef<'tcx> {
///////////////////////////////////////////////////////////////////////////

pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
let bcx = fcx.init(false, None).build();
let bcx = fcx.init(true, None).build();
let mir = bcx.mir();

// Analyze the temps to determine which must be lvalues
Expand Down
5 changes: 0 additions & 5 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -517,11 +517,6 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat
is just used for rustc unit tests \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_no_mir", Whitelisted, Gated("rustc_attrs",
"the `#[rustc_no_mir]` attribute \
is just used to make tests pass \
and will never be stable",
cfg_fn!(rustc_attrs))),
("rustc_inherit_overflow_checks", Whitelisted, Gated("rustc_attrs",
"the `#[rustc_inherit_overflow_checks]` \
attribute is just used to control \
Expand Down
8 changes: 3 additions & 5 deletions src/test/codegen/adjustments.rs
Expand Up @@ -11,7 +11,6 @@
// compile-flags: -C no-prepopulate-passes

#![crate_type = "lib"]
#![feature(rustc_attrs)]

// Hack to get the correct size for the length part in slices
// CHECK: @helper([[USIZE:i[0-9]+]])
Expand All @@ -21,13 +20,12 @@ fn helper(_: usize) {

// CHECK-LABEL: @no_op_slice_adjustment
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] {
// We used to generate an extra alloca and memcpy for the block's trailing expression value, so
// check that we copy directly to the return value slot
// CHECK: [[SRC:%[0-9]+]] = bitcast { i8*, [[USIZE]] }* %x to
// CHECK: [[DST:%[0-9]+]] = bitcast { i8*, [[USIZE]] }* %sret_slot to i8*
// CHECK: call void @llvm.memcpy.{{.*}}(i8* [[DST]], i8* [[SRC]],
// CHECK: %2 = insertvalue { i8*, [[USIZE]] } undef, i8* %0, 0
// CHECK: %3 = insertvalue { i8*, [[USIZE]] } %2, [[USIZE]] %1, 1
// CHECK: ret { i8*, [[USIZE]] } %3
{ x }
}

Expand Down
3 changes: 0 additions & 3 deletions src/test/codegen/coercions.rs
Expand Up @@ -11,22 +11,19 @@
// compile-flags: -C no-prepopulate-passes

#![crate_type = "lib"]
#![feature(rustc_attrs)]

static X: i32 = 5;

// CHECK-LABEL: @raw_ptr_to_raw_ptr_noop
// CHECK-NOT: alloca
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn raw_ptr_to_raw_ptr_noop() -> *const i32{
&X as *const i32
}

// CHECK-LABEL: @reference_to_raw_ptr_noop
// CHECK-NOT: alloca
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn reference_to_raw_ptr_noop() -> *const i32 {
&X
}
20 changes: 8 additions & 12 deletions src/test/codegen/consts.rs
Expand Up @@ -11,7 +11,6 @@
// compile-flags: -C no-prepopulate-passes

#![crate_type = "lib"]
#![feature(rustc_attrs)]

// Below, these constants are defined as enum variants that by itself would
// have a lower alignment than the enum type. Ensure that we mark them
Expand All @@ -20,11 +19,12 @@
// CHECK: @STATIC = {{.*}}, align 4

// This checks the constants from inline_enum_const
// CHECK: @const{{[0-9]+}} = {{.*}}, align 2
// CHECK: @ref{{[0-9]+}} = {{.*}}, align 2

// This checks the constants from {low,high}_align_const, they share the same
// constant, but the alignment differs, so the higher one should be used
// CHECK: @const{{[0-9]+}} = {{.*}}, align 4
// CHECK: [[LOW_HIGH:@ref[0-9]+]] = {{.*}}, align 4
// CHECK: [[LOW_HIGH_REF:@const[0-9]+]] = {{.*}} [[LOW_HIGH]]

#[derive(Copy, Clone)]

Expand All @@ -40,32 +40,28 @@ pub static STATIC: E<i16, i32> = E::A(0);

// CHECK-LABEL: @static_enum_const
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn static_enum_const() -> E<i16, i32> {
STATIC
}

// CHECK-LABEL: @inline_enum_const
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn inline_enum_const() -> E<i8, i16> {
E::A(0)
*&E::A(0)
}

// CHECK-LABEL: @low_align_const
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn low_align_const() -> E<i16, [i16; 3]> {
// Check that low_align_const and high_align_const use the same constant
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{[0-9]+}}, i8* {{.*}} [[LOW_HIGH:@const[0-9]+]]
E::A(0)
// CHECK: load {{.*}} bitcast ({ i16, i16, [4 x i8] }** [[LOW_HIGH_REF]]
*&E::A(0)
}

// CHECK-LABEL: @high_align_const
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn high_align_const() -> E<i16, i32> {
// Check that low_align_const and high_align_const use the same constant
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{[0-9]}}, i8* {{.*}} [[LOW_HIGH]]
E::A(0)
// CHECK: load {{.*}} bitcast ({ i16, i16, [4 x i8] }** [[LOW_HIGH_REF]]
*&E::A(0)
}
10 changes: 5 additions & 5 deletions src/test/codegen/drop.rs
Expand Up @@ -11,7 +11,6 @@
// compile-flags: -C no-prepopulate-passes

#![crate_type = "lib"]
#![feature(rustc_attrs)]

struct SomeUniqueName;

Expand All @@ -25,19 +24,20 @@ pub fn possibly_unwinding() {

// CHECK-LABEL: @droppy
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn droppy() {
// Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused, so
// that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the
// regular function exit. We used to have problems with quadratic growths of drop calls in such
// functions.
// CHECK: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK-NOT: invoke{{.*}}drop{{.*}}SomeUniqueName
// CHECK: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK-NOT: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK: invoke{{.*}}drop{{.*}}SomeUniqueName
// CHECK: invoke{{.*}}drop{{.*}}SomeUniqueName
// CHECK: invoke{{.*}}drop{{.*}}SomeUniqueName
// CHECK-NOT: {{(call|invoke).*}}drop{{.*}}SomeUniqueName
// The next line checks for the } that ends the function definition
// CHECK-LABEL: {{^[}]}}
let _s = SomeUniqueName;
Expand Down
4 changes: 1 addition & 3 deletions src/test/codegen/loads.rs
Expand Up @@ -11,7 +11,6 @@
// compile-flags: -C no-prepopulate-passes

#![crate_type = "lib"]
#![feature(rustc_attrs)]

pub struct Bytes {
a: u8,
Expand All @@ -22,15 +21,14 @@ pub struct Bytes {

// CHECK-LABEL: @borrow
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn borrow(x: &i32) -> &i32 {
// CHECK: load {{(i32\*, )?}}i32** %x{{.*}}, !nonnull
&x; // keep variable in an alloca
x
}

// CHECK-LABEL: @_box
#[no_mangle]
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
pub fn _box(x: Box<i32>) -> i32 {
// CHECK: load {{(i32\*, )?}}i32** %x{{.*}}, !nonnull
*x
Expand Down
2 changes: 0 additions & 2 deletions src/test/codegen/mir_zst_stores.rs
Expand Up @@ -10,7 +10,6 @@

// compile-flags: -C no-prepopulate-passes

#![feature(rustc_attrs)]
#![crate_type = "lib"]
use std::marker::PhantomData;

Expand All @@ -19,7 +18,6 @@ struct Zst { phantom: PhantomData<Zst> }

// CHECK-LABEL: @mir
#[no_mangle]
#[rustc_mir]
fn mir(){
// CHECK-NOT: getelementptr
// CHECK-NOT: store{{.*}}undef
Expand Down

0 comments on commit cb9b0ed

Please sign in to comment.