Inline FunctionContext.mir
This commit is contained in:
parent
65f040031e
commit
9c38a54cae
4 changed files with 12 additions and 21 deletions
|
@ -752,11 +752,7 @@ pub fn trans_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, instance: Instance
|
||||||
|
|
||||||
let fcx = FunctionContext::new(ccx, lldecl, fn_ty, Some((instance, &sig, abi)), true);
|
let fcx = FunctionContext::new(ccx, lldecl, fn_ty, Some((instance, &sig, abi)), true);
|
||||||
|
|
||||||
if fcx.mir.is_none() {
|
mir::trans_mir(&fcx, ccx.tcx().item_mir(instance.def));
|
||||||
bug!("attempted translation of `{}` w/o MIR", instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
mir::trans_mir(&fcx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||||
|
|
|
@ -22,7 +22,6 @@ use rustc::hir::def::Def;
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
use rustc::hir::map::DefPathData;
|
use rustc::hir::map::DefPathData;
|
||||||
use rustc::infer::TransNormalize;
|
use rustc::infer::TransNormalize;
|
||||||
use rustc::mir::Mir;
|
|
||||||
use rustc::util::common::MemoizationMap;
|
use rustc::util::common::MemoizationMap;
|
||||||
use middle::lang_items::LangItem;
|
use middle::lang_items::LangItem;
|
||||||
use rustc::ty::subst::Substs;
|
use rustc::ty::subst::Substs;
|
||||||
|
@ -48,7 +47,6 @@ use std::borrow::Cow;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::cell::Ref;
|
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::symbol::{Symbol, InternedString};
|
use syntax::symbol::{Symbol, InternedString};
|
||||||
|
@ -237,9 +235,6 @@ impl<'a, 'tcx> VariantInfo<'tcx> {
|
||||||
|
|
||||||
// Function context. Every LLVM function we create will have one of these.
|
// Function context. Every LLVM function we create will have one of these.
|
||||||
pub struct FunctionContext<'a, 'tcx: 'a> {
|
pub struct FunctionContext<'a, 'tcx: 'a> {
|
||||||
// The MIR for this function.
|
|
||||||
pub mir: Option<Ref<'tcx, Mir<'tcx>>>,
|
|
||||||
|
|
||||||
// The ValueRef returned from a call to llvm::LLVMAddFunction; the
|
// The ValueRef returned from a call to llvm::LLVMAddFunction; the
|
||||||
// address of the first instruction in the sequence of
|
// address of the first instruction in the sequence of
|
||||||
// instructions for this function that will go in the .text
|
// instructions for this function that will go in the .text
|
||||||
|
@ -318,7 +313,6 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut fcx = FunctionContext {
|
let mut fcx = FunctionContext {
|
||||||
mir: mir,
|
|
||||||
llfn: llfndecl,
|
llfn: llfndecl,
|
||||||
llretslotptr: None,
|
llretslotptr: None,
|
||||||
param_env: ccx.tcx().empty_parameter_environment(),
|
param_env: ccx.tcx().empty_parameter_environment(),
|
||||||
|
@ -368,10 +362,6 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
|
||||||
}, self)
|
}, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mir(&self) -> Ref<'tcx, Mir<'tcx>> {
|
|
||||||
self.mir.as_ref().map(Ref::clone).expect("fcx.mir was empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new_block(&'a self, name: &str) -> BasicBlockRef {
|
pub fn new_block(&'a self, name: &str) -> BasicBlockRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
let name = CString::new(name).unwrap();
|
let name = CString::new(name).unwrap();
|
||||||
|
|
|
@ -19,6 +19,7 @@ use rustc::mir::{Mir, VisibilityScope};
|
||||||
|
|
||||||
use libc::c_uint;
|
use libc::c_uint;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use std::cell::Ref;
|
||||||
|
|
||||||
use syntax_pos::Pos;
|
use syntax_pos::Pos;
|
||||||
|
|
||||||
|
@ -44,8 +45,10 @@ impl MirDebugScope {
|
||||||
|
|
||||||
/// Produce DIScope DIEs for each MIR Scope which has variables defined in it.
|
/// Produce DIScope DIEs for each MIR Scope which has variables defined in it.
|
||||||
/// If debuginfo is disabled, the returned vector is empty.
|
/// If debuginfo is disabled, the returned vector is empty.
|
||||||
pub fn create_mir_scopes(fcx: &FunctionContext) -> IndexVec<VisibilityScope, MirDebugScope> {
|
pub fn create_mir_scopes<'tcx>(
|
||||||
let mir = fcx.mir();
|
fcx: &FunctionContext,
|
||||||
|
mir: Ref<'tcx, Mir<'tcx>>,
|
||||||
|
) -> IndexVec<VisibilityScope, MirDebugScope> {
|
||||||
let null_scope = MirDebugScope {
|
let null_scope = MirDebugScope {
|
||||||
scope_metadata: ptr::null_mut(),
|
scope_metadata: ptr::null_mut(),
|
||||||
file_start_pos: BytePos(0),
|
file_start_pos: BytePos(0),
|
||||||
|
|
|
@ -12,7 +12,7 @@ use libc::c_uint;
|
||||||
use llvm::{self, ValueRef, BasicBlockRef};
|
use llvm::{self, ValueRef, BasicBlockRef};
|
||||||
use llvm::debuginfo::DIScope;
|
use llvm::debuginfo::DIScope;
|
||||||
use rustc::ty;
|
use rustc::ty;
|
||||||
use rustc::mir;
|
use rustc::mir::{self, Mir};
|
||||||
use rustc::mir::tcx::LvalueTy;
|
use rustc::mir::tcx::LvalueTy;
|
||||||
use session::config::FullDebugInfo;
|
use session::config::FullDebugInfo;
|
||||||
use base;
|
use base;
|
||||||
|
@ -179,9 +179,11 @@ impl<'tcx> LocalRef<'tcx> {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
|
pub fn trans_mir<'blk, 'tcx: 'blk>(
|
||||||
|
fcx: &'blk FunctionContext<'blk, 'tcx>,
|
||||||
|
mir: Ref<'tcx, Mir<'tcx>>
|
||||||
|
) {
|
||||||
let bcx = fcx.get_entry_block();
|
let bcx = fcx.get_entry_block();
|
||||||
let mir = fcx.mir();
|
|
||||||
|
|
||||||
// Analyze the temps to determine which must be lvalues
|
// Analyze the temps to determine which must be lvalues
|
||||||
// FIXME
|
// FIXME
|
||||||
|
@ -199,7 +201,7 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
// Compute debuginfo scopes from MIR scopes.
|
// Compute debuginfo scopes from MIR scopes.
|
||||||
let scopes = debuginfo::create_mir_scopes(fcx);
|
let scopes = debuginfo::create_mir_scopes(fcx, Ref::clone(&mir));
|
||||||
|
|
||||||
let mut mircx = MirContext {
|
let mut mircx = MirContext {
|
||||||
mir: Ref::clone(&mir),
|
mir: Ref::clone(&mir),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue