Remove env_alloca hack
This is no longer necessary for LLVM >= 6.
This commit is contained in:
parent
706e67b0a0
commit
6c2d704950
3 changed files with 2 additions and 30 deletions
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
use attributes;
|
||||
use llvm;
|
||||
use llvm_util;
|
||||
use rustc::dep_graph::DepGraphSafe;
|
||||
use rustc::hir;
|
||||
use debuginfo;
|
||||
|
|
@ -447,10 +446,6 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
attributes::apply_target_cpu_attr(self, llfn)
|
||||
}
|
||||
|
||||
fn closure_env_needs_indirect_debuginfo(&self) -> bool {
|
||||
llvm_util::get_major_version() < 6
|
||||
}
|
||||
|
||||
fn create_used_variable(&self) {
|
||||
let name = const_cstr!("llvm.used");
|
||||
let section = const_cstr!("llvm.metadata");
|
||||
|
|
|
|||
|
|
@ -610,35 +610,13 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
};
|
||||
let upvar_tys = upvar_substs.upvar_tys(def_id, tcx);
|
||||
|
||||
// Store the pointer to closure data in an alloca for debuginfo
|
||||
// because that's what the llvm.dbg.declare intrinsic expects.
|
||||
|
||||
// FIXME(eddyb) this shouldn't be necessary but SROA seems to
|
||||
// mishandle DW_OP_plus not preceded by DW_OP_deref, i.e., it
|
||||
// doesn't actually strip the offset when splitting the closure
|
||||
// environment into its components so it ends up out of bounds.
|
||||
// (cuviper) It seems to be fine without the alloca on LLVM 6 and later.
|
||||
let env_alloca = !env_ref && bx.closure_env_needs_indirect_debuginfo();
|
||||
let env_ptr = if env_alloca {
|
||||
let scratch = PlaceRef::alloca(bx,
|
||||
bx.layout_of(tcx.mk_mut_ptr(arg.layout.ty)),
|
||||
"__debuginfo_env_ptr");
|
||||
bx.store(place.llval, scratch.llval, scratch.align);
|
||||
scratch.llval
|
||||
} else {
|
||||
place.llval
|
||||
};
|
||||
|
||||
for (i, (decl, ty)) in mir.upvar_decls.iter().zip(upvar_tys).enumerate() {
|
||||
let byte_offset_of_var_in_env = closure_layout.fields.offset(i).bytes();
|
||||
|
||||
let ops = bx.debuginfo_upvar_decls_ops_sequence(byte_offset_of_var_in_env);
|
||||
|
||||
// The environment and the capture can each be indirect.
|
||||
|
||||
// FIXME(eddyb) see above why we sometimes have to keep
|
||||
// a pointer in an alloca for debuginfo atm.
|
||||
let mut ops = if env_ref || env_alloca { &ops[..] } else { &ops[1..] };
|
||||
let mut ops = if env_ref { &ops[..] } else { &ops[1..] };
|
||||
|
||||
let ty = if let (true, &ty::Ref(_, ty, _)) = (decl.by_ref, &ty.sty) {
|
||||
ty
|
||||
|
|
@ -648,7 +626,7 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
};
|
||||
|
||||
let variable_access = VariableAccess::IndirectVariable {
|
||||
alloca: env_ptr,
|
||||
alloca: place.llval,
|
||||
address_operations: &ops
|
||||
};
|
||||
bx.declare_local(
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ pub trait MiscMethods<'tcx>: BackendTypes {
|
|||
fn stats(&self) -> &RefCell<Stats>;
|
||||
fn consume_stats(self) -> RefCell<Stats>;
|
||||
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
|
||||
fn closure_env_needs_indirect_debuginfo(&self) -> bool;
|
||||
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;
|
||||
fn set_frame_pointer_elimination(&self, llfn: Self::Value);
|
||||
fn apply_target_cpu_attr(&self, llfn: Self::Value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue