Inline FunctionContext.mir
This commit is contained in:
parent
65f040031e
commit
9c38a54cae
@ -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);
|
||||
|
||||
if fcx.mir.is_none() {
|
||||
bug!("attempted translation of `{}` w/o MIR", instance);
|
||||
}
|
||||
|
||||
mir::trans_mir(&fcx);
|
||||
mir::trans_mir(&fcx, ccx.tcx().item_mir(instance.def));
|
||||
}
|
||||
|
||||
pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
|
@ -22,7 +22,6 @@
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::hir::map::DefPathData;
|
||||
use rustc::infer::TransNormalize;
|
||||
use rustc::mir::Mir;
|
||||
use rustc::util::common::MemoizationMap;
|
||||
use middle::lang_items::LangItem;
|
||||
use rustc::ty::subst::Substs;
|
||||
@ -48,7 +47,6 @@
|
||||
use std::iter;
|
||||
use std::ops::Deref;
|
||||
use std::ffi::CString;
|
||||
use std::cell::Ref;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::symbol::{Symbol, InternedString};
|
||||
@ -237,9 +235,6 @@ pub fn from_ty(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
||||
// Function context. Every LLVM function we create will have one of these.
|
||||
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
|
||||
// address of the first instruction in the sequence of
|
||||
// instructions for this function that will go in the .text
|
||||
@ -318,7 +313,6 @@ pub fn new(
|
||||
};
|
||||
|
||||
let mut fcx = FunctionContext {
|
||||
mir: mir,
|
||||
llfn: llfndecl,
|
||||
llretslotptr: None,
|
||||
param_env: ccx.tcx().empty_parameter_environment(),
|
||||
@ -368,10 +362,6 @@ pub fn get_entry_block(&'a self) -> BlockAndBuilder<'a, 'tcx> {
|
||||
}, 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 {
|
||||
unsafe {
|
||||
let name = CString::new(name).unwrap();
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
use libc::c_uint;
|
||||
use std::ptr;
|
||||
use std::cell::Ref;
|
||||
|
||||
use syntax_pos::Pos;
|
||||
|
||||
@ -44,8 +45,10 @@ pub fn is_valid(&self) -> bool {
|
||||
|
||||
/// Produce DIScope DIEs for each MIR Scope which has variables defined in it.
|
||||
/// If debuginfo is disabled, the returned vector is empty.
|
||||
pub fn create_mir_scopes(fcx: &FunctionContext) -> IndexVec<VisibilityScope, MirDebugScope> {
|
||||
let mir = fcx.mir();
|
||||
pub fn create_mir_scopes<'tcx>(
|
||||
fcx: &FunctionContext,
|
||||
mir: Ref<'tcx, Mir<'tcx>>,
|
||||
) -> IndexVec<VisibilityScope, MirDebugScope> {
|
||||
let null_scope = MirDebugScope {
|
||||
scope_metadata: ptr::null_mut(),
|
||||
file_start_pos: BytePos(0),
|
||||
|
@ -12,7 +12,7 @@
|
||||
use llvm::{self, ValueRef, BasicBlockRef};
|
||||
use llvm::debuginfo::DIScope;
|
||||
use rustc::ty;
|
||||
use rustc::mir;
|
||||
use rustc::mir::{self, Mir};
|
||||
use rustc::mir::tcx::LvalueTy;
|
||||
use session::config::FullDebugInfo;
|
||||
use base;
|
||||
@ -179,9 +179,11 @@ fn new_operand<'bcx>(ccx: &CrateContext<'bcx, '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 mir = fcx.mir();
|
||||
|
||||
// Analyze the temps to determine which must be lvalues
|
||||
// FIXME
|
||||
@ -199,7 +201,7 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
|
||||
}).collect();
|
||||
|
||||
// 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 {
|
||||
mir: Ref::clone(&mir),
|
||||
|
Loading…
Reference in New Issue
Block a user