Skip to content

Commit aab5ecb

Browse files
committed
rustc_codegen_ssa: use &'tcx mir::Body<'tcx> instead of &'a ... for the MIR body.
1 parent 2b637ef commit aab5ecb

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

src/librustc_codegen_ssa/mir/block.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ use super::operand::OperandValue::{Pair, Ref, Immediate};
2424

2525
/// Used by `FunctionCx::codegen_terminator` for emitting common patterns
2626
/// e.g., creating a basic block, calling a function, etc.
27-
struct TerminatorCodegenHelper<'a, 'tcx> {
28-
bb: &'a mir::BasicBlock,
29-
terminator: &'a mir::Terminator<'tcx>,
27+
struct TerminatorCodegenHelper<'tcx> {
28+
bb: mir::BasicBlock,
29+
terminator: &'tcx mir::Terminator<'tcx>,
3030
funclet_bb: Option<mir::BasicBlock>,
3131
}
3232

33-
impl<'a, 'tcx> TerminatorCodegenHelper<'a, 'tcx> {
33+
// FIXME(eddyb) clean up the lifetimes in this impl.
34+
impl<'tcx> TerminatorCodegenHelper<'tcx> {
3435
/// Returns the associated funclet from `FunctionCx::funclets` for the
3536
/// `funclet_bb` member if it is not `None`.
3637
fn funclet<'c, 'b, Bx: BuilderMethods<'b, 'tcx>>(
@@ -132,7 +133,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'a, 'tcx> {
132133
} else {
133134
let llret = bx.call(fn_ptr, &llargs, self.funclet(fx));
134135
bx.apply_attrs_callsite(&fn_abi, llret);
135-
if fx.mir[*self.bb].is_cleanup {
136+
if fx.mir[self.bb].is_cleanup {
136137
// Cleanup is always the cold path. Don't inline
137138
// drop glue. Also, when there is a deeply-nested
138139
// struct, there are "symmetry" issues that cause
@@ -151,15 +152,15 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'a, 'tcx> {
151152

152153
// Generate sideeffect intrinsic if jumping to any of the targets can form
153154
// a loop.
154-
fn maybe_sideeffect<'b, 'tcx2: 'b, Bx: BuilderMethods<'b, 'tcx2>>(
155+
fn maybe_sideeffect<'b, Bx: BuilderMethods<'b, 'tcx>>(
155156
&self,
156-
mir: &'b mir::Body<'tcx>,
157+
mir: &'tcx mir::Body<'tcx>,
157158
bx: &mut Bx,
158159
targets: &[mir::BasicBlock],
159160
) {
160161
if bx.tcx().sess.opts.debugging_opts.insert_sideeffect {
161-
if targets.iter().any(|target| {
162-
*target <= *self.bb
162+
if targets.iter().any(|&target| {
163+
target <= self.bb
163164
&& target
164165
.start_location()
165166
.is_predecessor_of(self.bb.start_location(), mir)
@@ -173,9 +174,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'a, 'tcx> {
173174
/// Codegen implementations for some terminator variants.
174175
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
175176
/// Generates code for a `Resume` terminator.
176-
fn codegen_resume_terminator<'b>(
177+
fn codegen_resume_terminator(
177178
&mut self,
178-
helper: TerminatorCodegenHelper<'b, 'tcx>,
179+
helper: TerminatorCodegenHelper<'tcx>,
179180
mut bx: Bx,
180181
) {
181182
if let Some(funclet) = helper.funclet(self) {
@@ -201,9 +202,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
201202
}
202203
}
203204

204-
fn codegen_switchint_terminator<'b>(
205+
fn codegen_switchint_terminator(
205206
&mut self,
206-
helper: TerminatorCodegenHelper<'b, 'tcx>,
207+
helper: TerminatorCodegenHelper<'tcx>,
207208
mut bx: Bx,
208209
discr: &mir::Operand<'tcx>,
209210
switch_ty: Ty<'tcx>,
@@ -316,9 +317,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
316317
}
317318

318319

319-
fn codegen_drop_terminator<'b>(
320+
fn codegen_drop_terminator(
320321
&mut self,
321-
helper: TerminatorCodegenHelper<'b, 'tcx>,
322+
helper: TerminatorCodegenHelper<'tcx>,
322323
mut bx: Bx,
323324
location: &mir::Place<'tcx>,
324325
target: mir::BasicBlock,
@@ -367,9 +368,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
367368
unwind);
368369
}
369370

370-
fn codegen_assert_terminator<'b>(
371+
fn codegen_assert_terminator(
371372
&mut self,
372-
helper: TerminatorCodegenHelper<'b, 'tcx>,
373+
helper: TerminatorCodegenHelper<'tcx>,
373374
mut bx: Bx,
374375
terminator: &mir::Terminator<'tcx>,
375376
cond: &mir::Operand<'tcx>,
@@ -446,9 +447,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
446447
helper.do_call(self, &mut bx, fn_abi, llfn, &args, None, cleanup);
447448
}
448449

449-
fn codegen_call_terminator<'b>(
450+
fn codegen_call_terminator(
450451
&mut self,
451-
helper: TerminatorCodegenHelper<'b, 'tcx>,
452+
helper: TerminatorCodegenHelper<'tcx>,
452453
mut bx: Bx,
453454
terminator: &mir::Terminator<'tcx>,
454455
func: &mir::Operand<'tcx>,
@@ -798,14 +799,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
798799
&mut self,
799800
mut bx: Bx,
800801
bb: mir::BasicBlock,
801-
terminator: &mir::Terminator<'tcx>
802+
terminator: &'tcx mir::Terminator<'tcx>
802803
) {
803804
debug!("codegen_terminator: {:?}", terminator);
804805

805806
// Create the cleanup bundle, if needed.
806807
let funclet_bb = self.cleanup_kinds[bb].funclet_bb(bb);
807808
let helper = TerminatorCodegenHelper {
808-
bb: &bb, terminator, funclet_bb
809+
bb, terminator, funclet_bb
809810
};
810811

811812
self.set_debug_loc(&mut bx, terminator.source_info);

src/librustc_codegen_ssa/mir/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc::ty::{self, Ty, TypeFoldable, Instance};
22
use rustc::ty::layout::{TyLayout, HasTyCtxt, FnAbiExt};
3-
use rustc::mir::{self, Body};
3+
use rustc::mir;
44
use rustc_target::abi::call::{FnAbi, PassMode};
55
use crate::base;
66
use crate::traits::*;
@@ -21,7 +21,7 @@ use self::operand::{OperandRef, OperandValue};
2121
pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
2222
instance: Instance<'tcx>,
2323

24-
mir: &'a mir::Body<'tcx>,
24+
mir: &'tcx mir::Body<'tcx>,
2525

2626
debug_context: Option<FunctionDebugContext<Bx::DIScope>>,
2727

@@ -120,7 +120,7 @@ impl<'a, 'tcx, V: CodegenObject> LocalRef<'tcx, V> {
120120
pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
121121
cx: &'a Bx::CodegenCx,
122122
llfn: Bx::Function,
123-
mir: &'a Body<'tcx>,
123+
mir: &'tcx mir::Body<'tcx>,
124124
instance: Instance<'tcx>,
125125
sig: ty::FnSig<'tcx>,
126126
) {
@@ -247,7 +247,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
247247
}
248248

249249
fn create_funclets<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
250-
mir: &'a Body<'tcx>,
250+
mir: &'tcx mir::Body<'tcx>,
251251
bx: &mut Bx,
252252
cleanup_kinds: &IndexVec<mir::BasicBlock, CleanupKind>,
253253
block_bxs: &IndexVec<mir::BasicBlock, Bx::BasicBlock>,

0 commit comments

Comments
 (0)