location: SourceInfo,
}
-impl MirPass for Inline {
- fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
+impl<'tcx> MirPass<'tcx> for Inline {
+ fn run_pass(&self, tcx: TyCtxt<'tcx>, source: MirSource<'tcx>, body: &mut Body<'tcx>) {
if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 {
Inliner { tcx, source }.run_pass(body);
}
return false;
}
- // Do not inline {u,i}128 lang items, codegen const eval depends
- // on detecting calls to these lang items and intercepting them
- if tcx.is_binop_lang_item(callsite.callee).is_some() {
- debug!(" not inlining 128bit integer lang item");
- return false;
- }
-
let codegen_fn_attrs = tcx.codegen_fn_attrs(callsite.callee);
let hinted = match codegen_fn_attrs.inline {
}
TerminatorKind::Call {func: Operand::Constant(ref f), .. } => {
- if let ty::FnDef(def_id, _) = f.ty.sty {
+ if let ty::FnDef(def_id, _) = f.literal.ty.sty {
// Don't give intrinsics the extra penalty for calls
let f = tcx.fn_sig(def_id);
if f.abi() == Abi::RustIntrinsic || f.abi() == Abi::PlatformIntrinsic {
let mut local_map = IndexVec::with_capacity(callee_body.local_decls.len());
let mut scope_map = IndexVec::with_capacity(callee_body.source_scopes.len());
- let mut promoted_map = IndexVec::with_capacity(callee_body.promoted.len());
for mut scope in callee_body.source_scopes.iter().cloned() {
if scope.parent_scope.is_none() {
local_map.push(idx);
}
- promoted_map.extend(
- callee_body.promoted.iter().cloned().map(|p| caller_body.promoted.push(p))
- );
-
// If the call is something like `a[*i] = f(i)`, where
// `i : &mut usize`, then just duplicating the `a[*i]`
// Place could result in two different locations if `f`
args: &args,
local_map,
scope_map,
- promoted_map,
- _callsite: callsite,
+ callsite,
destination: dest,
return_block,
cleanup_block: cleanup,
- in_cleanup_block: false
+ in_cleanup_block: false,
+ tcx: self.tcx,
};
args: &'a [Local],
local_map: IndexVec<Local, Local>,
scope_map: IndexVec<SourceScope, SourceScope>,
- promoted_map: IndexVec<Promoted, Promoted>,
- _callsite: CallSite<'tcx>,
+ callsite: CallSite<'tcx>,
destination: Place<'tcx>,
return_block: BasicBlock,
cleanup_block: Option<BasicBlock>,
in_cleanup_block: bool,
+ tcx: TyCtxt<'tcx>,
}
impl<'a, 'tcx> Integrator<'a, 'tcx> {
},
Place {
base: PlaceBase::Static(box Static {
- kind: StaticKind::Promoted(promoted),
+ kind: StaticKind::Promoted(_, substs),
..
}),
projection: None,
} => {
- if let Some(p) = self.promoted_map.get(*promoted).cloned() {
- *promoted = p;
- }
+ let adjusted_substs = substs.subst(self.tcx, self.callsite.substs);
+ debug!("replacing substs {:?} with {:?}", substs, adjusted_substs);
+ *substs = adjusted_substs;
},
_ => self.super_place(place, _ctxt, _location)
}