]> git.lizzy.rs Git - rust.git/blob - src/librustc_trans/mir/mod.rs
99d8cd594ecddc032f51dedb69016fb0829e581c
[rust.git] / src / librustc_trans / mir / mod.rs
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use libc::c_uint;
12 use llvm::{self, ValueRef, BasicBlockRef};
13 use llvm::debuginfo::DIScope;
14 use rustc::ty::{self, Ty, TypeFoldable};
15 use rustc::ty::layout::{self, LayoutTyper};
16 use rustc::mir::{self, Mir};
17 use rustc::mir::tcx::LvalueTy;
18 use rustc::ty::subst::Substs;
19 use rustc::infer::TransNormalize;
20 use session::config::FullDebugInfo;
21 use base;
22 use builder::Builder;
23 use common::{self, CrateContext, Funclet};
24 use debuginfo::{self, declare_local, VariableAccess, VariableKind, FunctionDebugContext};
25 use monomorphize::{self, Instance};
26 use abi::FnType;
27 use type_of;
28
29 use syntax_pos::{DUMMY_SP, NO_EXPANSION, BytePos, Span};
30 use syntax::symbol::keywords;
31
32 use std::iter;
33
34 use rustc_data_structures::bitvec::BitVector;
35 use rustc_data_structures::indexed_vec::{IndexVec, Idx};
36
37 pub use self::constant::trans_static_initializer;
38
39 use self::analyze::CleanupKind;
40 use self::lvalue::{Alignment, LvalueRef};
41 use rustc::mir::traversal;
42
43 use self::operand::{OperandRef, OperandValue};
44
45 /// Master context for translating MIR.
46 pub struct MirContext<'a, 'tcx:'a> {
47     mir: &'a mir::Mir<'tcx>,
48
49     debug_context: debuginfo::FunctionDebugContext,
50
51     llfn: ValueRef,
52
53     ccx: &'a CrateContext<'a, 'tcx>,
54
55     fn_ty: FnType<'tcx>,
56
57     /// When unwinding is initiated, we have to store this personality
58     /// value somewhere so that we can load it and re-use it in the
59     /// resume instruction. The personality is (afaik) some kind of
60     /// value used for C++ unwinding, which must filter by type: we
61     /// don't really care about it very much. Anyway, this value
62     /// contains an alloca into which the personality is stored and
63     /// then later loaded when generating the DIVERGE_BLOCK.
64     llpersonalityslot: Option<ValueRef>,
65
66     /// A `Block` for each MIR `BasicBlock`
67     blocks: IndexVec<mir::BasicBlock, BasicBlockRef>,
68
69     /// The funclet status of each basic block
70     cleanup_kinds: IndexVec<mir::BasicBlock, analyze::CleanupKind>,
71
72     /// This stores the landing-pad block for a given BB, computed lazily on GNU
73     /// and eagerly on MSVC.
74     landing_pads: IndexVec<mir::BasicBlock, Option<BasicBlockRef>>,
75
76     /// Cached unreachable block
77     unreachable_block: Option<BasicBlockRef>,
78
79     /// The location where each MIR arg/var/tmp/ret is stored. This is
80     /// usually an `LvalueRef` representing an alloca, but not always:
81     /// sometimes we can skip the alloca and just store the value
82     /// directly using an `OperandRef`, which makes for tighter LLVM
83     /// IR. The conditions for using an `OperandRef` are as follows:
84     ///
85     /// - the type of the local must be judged "immediate" by `type_is_immediate`
86     /// - the operand must never be referenced indirectly
87     ///     - we should not take its address using the `&` operator
88     ///     - nor should it appear in an lvalue path like `tmp.a`
89     /// - the operand must be defined by an rvalue that can generate immediate
90     ///   values
91     ///
92     /// Avoiding allocs can also be important for certain intrinsics,
93     /// notably `expect`.
94     locals: IndexVec<mir::Local, LocalRef<'tcx>>,
95
96     /// Debug information for MIR scopes.
97     scopes: IndexVec<mir::VisibilityScope, debuginfo::MirDebugScope>,
98
99     /// If this function is being monomorphized, this contains the type substitutions used.
100     param_substs: &'tcx Substs<'tcx>,
101 }
102
103 impl<'a, 'tcx> MirContext<'a, 'tcx> {
104     pub fn monomorphize<T>(&self, value: &T) -> T
105         where T: TransNormalize<'tcx> {
106         monomorphize::apply_param_substs(self.ccx.shared(), self.param_substs, value)
107     }
108
109     pub fn set_debug_loc(&mut self, bcx: &Builder, source_info: mir::SourceInfo) {
110         let (scope, span) = self.debug_loc(source_info);
111         debuginfo::set_source_location(&self.debug_context, bcx, scope, span);
112     }
113
114     pub fn debug_loc(&mut self, source_info: mir::SourceInfo) -> (DIScope, Span) {
115         // Bail out if debug info emission is not enabled.
116         match self.debug_context {
117             FunctionDebugContext::DebugInfoDisabled |
118             FunctionDebugContext::FunctionWithoutDebugInfo => {
119                 return (self.scopes[source_info.scope].scope_metadata, source_info.span);
120             }
121             FunctionDebugContext::RegularContext(_) =>{}
122         }
123
124         // In order to have a good line stepping behavior in debugger, we overwrite debug
125         // locations of macro expansions with that of the outermost expansion site
126         // (unless the crate is being compiled with `-Z debug-macros`).
127         if source_info.span.ctxt == NO_EXPANSION ||
128            self.ccx.sess().opts.debugging_opts.debug_macros {
129             let scope = self.scope_metadata_for_loc(source_info.scope, source_info.span.lo);
130             (scope, source_info.span)
131         } else {
132             // Walk up the macro expansion chain until we reach a non-expanded span.
133             // We also stop at the function body level because no line stepping can occurr
134             // at the level above that.
135             let mut span = source_info.span;
136             while span.ctxt != NO_EXPANSION && span.ctxt != self.mir.span.ctxt {
137                 if let Some(info) = span.ctxt.outer().expn_info() {
138                     span = info.call_site;
139                 } else {
140                     break;
141                 }
142             }
143             let scope = self.scope_metadata_for_loc(source_info.scope, span.lo);
144             // Use span of the outermost expansion site, while keeping the original lexical scope.
145             (scope, span)
146         }
147     }
148
149     // DILocations inherit source file name from the parent DIScope.  Due to macro expansions
150     // it may so happen that the current span belongs to a different file than the DIScope
151     // corresponding to span's containing visibility scope.  If so, we need to create a DIScope
152     // "extension" into that file.
153     fn scope_metadata_for_loc(&self, scope_id: mir::VisibilityScope, pos: BytePos)
154                                -> llvm::debuginfo::DIScope {
155         let scope_metadata = self.scopes[scope_id].scope_metadata;
156         if pos < self.scopes[scope_id].file_start_pos ||
157            pos >= self.scopes[scope_id].file_end_pos {
158             let cm = self.ccx.sess().codemap();
159             debuginfo::extend_scope_to_file(self.ccx, scope_metadata, &cm.lookup_char_pos(pos).file)
160         } else {
161             scope_metadata
162         }
163     }
164 }
165
166 enum LocalRef<'tcx> {
167     Lvalue(LvalueRef<'tcx>),
168     Operand(Option<OperandRef<'tcx>>),
169 }
170
171 impl<'tcx> LocalRef<'tcx> {
172     fn new_operand<'a>(ccx: &CrateContext<'a, 'tcx>,
173                        ty: Ty<'tcx>) -> LocalRef<'tcx> {
174         if common::type_is_zero_size(ccx, ty) {
175             // Zero-size temporaries aren't always initialized, which
176             // doesn't matter because they don't contain data, but
177             // we need something in the operand.
178             LocalRef::Operand(Some(OperandRef::new_zst(ccx, ty)))
179         } else {
180             LocalRef::Operand(None)
181         }
182     }
183 }
184
185 ///////////////////////////////////////////////////////////////////////////
186
187 pub fn trans_mir<'a, 'tcx: 'a>(
188     ccx: &'a CrateContext<'a, 'tcx>,
189     llfn: ValueRef,
190     mir: &'a Mir<'tcx>,
191     instance: Instance<'tcx>,
192     sig: ty::FnSig<'tcx>,
193 ) {
194     let fn_ty = FnType::new(ccx, sig, &[]);
195     debug!("fn_ty: {:?}", fn_ty);
196     let debug_context =
197         debuginfo::create_function_debug_context(ccx, instance, sig, llfn, mir);
198     let bcx = Builder::new_block(ccx, llfn, "entry-block");
199
200     let cleanup_kinds = analyze::cleanup_kinds(&mir);
201
202     // Allocate a `Block` for every basic block
203     let block_bcxs: IndexVec<mir::BasicBlock, BasicBlockRef> =
204         mir.basic_blocks().indices().map(|bb| {
205             if bb == mir::START_BLOCK {
206                 bcx.build_sibling_block("start").llbb()
207             } else {
208                 bcx.build_sibling_block(&format!("{:?}", bb)).llbb()
209             }
210         }).collect();
211
212     // Compute debuginfo scopes from MIR scopes.
213     let scopes = debuginfo::create_mir_scopes(ccx, mir, &debug_context);
214
215     let mut mircx = MirContext {
216         mir: mir,
217         llfn: llfn,
218         fn_ty: fn_ty,
219         ccx: ccx,
220         llpersonalityslot: None,
221         blocks: block_bcxs,
222         unreachable_block: None,
223         cleanup_kinds: cleanup_kinds,
224         landing_pads: IndexVec::from_elem(None, mir.basic_blocks()),
225         scopes: scopes,
226         locals: IndexVec::new(),
227         debug_context: debug_context,
228         param_substs: {
229             assert!(!instance.substs.needs_infer());
230             instance.substs
231         },
232     };
233
234     let lvalue_locals = analyze::lvalue_locals(&mircx);
235
236     // Allocate variable and temp allocas
237     mircx.locals = {
238         let args = arg_local_refs(&bcx, &mircx, &mircx.scopes, &lvalue_locals);
239
240         let mut allocate_local = |local| {
241             let decl = &mir.local_decls[local];
242             let ty = mircx.monomorphize(&decl.ty);
243
244             if let Some(name) = decl.name {
245                 // User variable
246                 let debug_scope = mircx.scopes[decl.source_info.scope];
247                 let dbg = debug_scope.is_valid() && bcx.sess().opts.debuginfo == FullDebugInfo;
248
249                 if !lvalue_locals.contains(local.index()) && !dbg {
250                     debug!("alloc: {:?} ({}) -> operand", local, name);
251                     return LocalRef::new_operand(bcx.ccx, ty);
252                 }
253
254                 debug!("alloc: {:?} ({}) -> lvalue", local, name);
255                 assert!(!ty.has_erasable_regions());
256                 let lvalue = LvalueRef::alloca(&bcx, ty, &name.as_str());
257                 if dbg {
258                     let (scope, span) = mircx.debug_loc(decl.source_info);
259                     declare_local(&bcx, &mircx.debug_context, name, ty, scope,
260                         VariableAccess::DirectVariable { alloca: lvalue.llval },
261                         VariableKind::LocalVariable, span);
262                 }
263                 LocalRef::Lvalue(lvalue)
264             } else {
265                 // Temporary or return pointer
266                 if local == mir::RETURN_POINTER && mircx.fn_ty.ret.is_indirect() {
267                     debug!("alloc: {:?} (return pointer) -> lvalue", local);
268                     let llretptr = llvm::get_param(llfn, 0);
269                     LocalRef::Lvalue(LvalueRef::new_sized(llretptr, LvalueTy::from_ty(ty),
270                                                           Alignment::AbiAligned))
271                 } else if lvalue_locals.contains(local.index()) {
272                     debug!("alloc: {:?} -> lvalue", local);
273                     assert!(!ty.has_erasable_regions());
274                     LocalRef::Lvalue(LvalueRef::alloca(&bcx, ty,  &format!("{:?}", local)))
275                 } else {
276                     // If this is an immediate local, we do not create an
277                     // alloca in advance. Instead we wait until we see the
278                     // definition and update the operand there.
279                     debug!("alloc: {:?} -> operand", local);
280                     LocalRef::new_operand(bcx.ccx, ty)
281                 }
282             }
283         };
284
285         let retptr = allocate_local(mir::RETURN_POINTER);
286         iter::once(retptr)
287             .chain(args.into_iter())
288             .chain(mir.vars_and_temps_iter().map(allocate_local))
289             .collect()
290     };
291
292     // Branch to the START block
293     let start_bcx = mircx.blocks[mir::START_BLOCK];
294     bcx.br(start_bcx);
295
296     // Up until here, IR instructions for this function have explicitly not been annotated with
297     // source code location, so we don't step into call setup code. From here on, source location
298     // emitting should be enabled.
299     debuginfo::start_emitting_source_locations(&mircx.debug_context);
300
301     let funclets: IndexVec<mir::BasicBlock, Option<Funclet>> =
302     mircx.cleanup_kinds.iter_enumerated().map(|(bb, cleanup_kind)| {
303         if let CleanupKind::Funclet = *cleanup_kind {
304             let bcx = mircx.get_builder(bb);
305             unsafe {
306                 llvm::LLVMSetPersonalityFn(mircx.llfn, mircx.ccx.eh_personality());
307             }
308             if base::wants_msvc_seh(ccx.sess()) {
309                 return Some(Funclet::new(bcx.cleanup_pad(None, &[])));
310             }
311         }
312
313         None
314     }).collect();
315
316     let rpo = traversal::reverse_postorder(&mir);
317     let mut visited = BitVector::new(mir.basic_blocks().len());
318
319     // Translate the body of each block using reverse postorder
320     for (bb, _) in rpo {
321         visited.insert(bb.index());
322         mircx.trans_block(bb, &funclets);
323     }
324
325     // Remove blocks that haven't been visited, or have no
326     // predecessors.
327     for bb in mir.basic_blocks().indices() {
328         // Unreachable block
329         if !visited.contains(bb.index()) {
330             debug!("trans_mir: block {:?} was not visited", bb);
331             unsafe {
332                 llvm::LLVMDeleteBasicBlock(mircx.blocks[bb]);
333             }
334         }
335     }
336 }
337
338 /// Produce, for each argument, a `ValueRef` pointing at the
339 /// argument's value. As arguments are lvalues, these are always
340 /// indirect.
341 fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
342                             mircx: &MirContext<'a, 'tcx>,
343                             scopes: &IndexVec<mir::VisibilityScope, debuginfo::MirDebugScope>,
344                             lvalue_locals: &BitVector)
345                             -> Vec<LocalRef<'tcx>> {
346     let mir = mircx.mir;
347     let tcx = bcx.tcx();
348     let mut idx = 0;
349     let mut llarg_idx = mircx.fn_ty.ret.is_indirect() as usize;
350
351     // Get the argument scope, if it exists and if we need it.
352     let arg_scope = scopes[mir::ARGUMENT_VISIBILITY_SCOPE];
353     let arg_scope = if arg_scope.is_valid() && bcx.sess().opts.debuginfo == FullDebugInfo {
354         Some(arg_scope.scope_metadata)
355     } else {
356         None
357     };
358
359     mir.args_iter().enumerate().map(|(arg_index, local)| {
360         let arg_decl = &mir.local_decls[local];
361         let arg_ty = mircx.monomorphize(&arg_decl.ty);
362
363         if Some(local) == mir.spread_arg {
364             // This argument (e.g. the last argument in the "rust-call" ABI)
365             // is a tuple that was spread at the ABI level and now we have
366             // to reconstruct it into a tuple local variable, from multiple
367             // individual LLVM function arguments.
368
369             let tupled_arg_tys = match arg_ty.sty {
370                 ty::TyTuple(ref tys, _) => tys,
371                 _ => bug!("spread argument isn't a tuple?!")
372             };
373
374             let lvalue = LvalueRef::alloca(bcx, arg_ty, &format!("arg{}", arg_index));
375             for (i, &tupled_arg_ty) in tupled_arg_tys.iter().enumerate() {
376                 let (dst, _) = lvalue.trans_field_ptr(bcx, i);
377                 let arg = &mircx.fn_ty.args[idx];
378                 idx += 1;
379                 if common::type_is_fat_ptr(bcx.ccx, tupled_arg_ty) {
380                     // We pass fat pointers as two words, but inside the tuple
381                     // they are the two sub-fields of a single aggregate field.
382                     let meta = &mircx.fn_ty.args[idx];
383                     idx += 1;
384                     arg.store_fn_arg(bcx, &mut llarg_idx, base::get_dataptr(bcx, dst));
385                     meta.store_fn_arg(bcx, &mut llarg_idx, base::get_meta(bcx, dst));
386                 } else {
387                     arg.store_fn_arg(bcx, &mut llarg_idx, dst);
388                 }
389             }
390
391             // Now that we have one alloca that contains the aggregate value,
392             // we can create one debuginfo entry for the argument.
393             arg_scope.map(|scope| {
394                 let variable_access = VariableAccess::DirectVariable {
395                     alloca: lvalue.llval
396                 };
397                 declare_local(
398                     bcx,
399                     &mircx.debug_context,
400                     arg_decl.name.unwrap_or(keywords::Invalid.name()),
401                     arg_ty, scope,
402                     variable_access,
403                     VariableKind::ArgumentVariable(arg_index + 1),
404                     DUMMY_SP
405                 );
406             });
407
408             return LocalRef::Lvalue(lvalue);
409         }
410
411         let arg = &mircx.fn_ty.args[idx];
412         idx += 1;
413         let llval = if arg.is_indirect() && bcx.sess().opts.debuginfo != FullDebugInfo {
414             // Don't copy an indirect argument to an alloca, the caller
415             // already put it in a temporary alloca and gave it up, unless
416             // we emit extra-debug-info, which requires local allocas :(.
417             // FIXME: lifetimes
418             if arg.pad.is_some() {
419                 llarg_idx += 1;
420             }
421             let llarg = llvm::get_param(bcx.llfn(), llarg_idx as c_uint);
422             llarg_idx += 1;
423             llarg
424         } else if !lvalue_locals.contains(local.index()) &&
425                   !arg.is_indirect() && arg.cast.is_none() &&
426                   arg_scope.is_none() {
427             if arg.is_ignore() {
428                 return LocalRef::new_operand(bcx.ccx, arg_ty);
429             }
430
431             // We don't have to cast or keep the argument in the alloca.
432             // FIXME(eddyb): We should figure out how to use llvm.dbg.value instead
433             // of putting everything in allocas just so we can use llvm.dbg.declare.
434             if arg.pad.is_some() {
435                 llarg_idx += 1;
436             }
437             let llarg = llvm::get_param(bcx.llfn(), llarg_idx as c_uint);
438             llarg_idx += 1;
439             let val = if common::type_is_fat_ptr(bcx.ccx, arg_ty) {
440                 let meta = &mircx.fn_ty.args[idx];
441                 idx += 1;
442                 assert_eq!((meta.cast, meta.pad), (None, None));
443                 let llmeta = llvm::get_param(bcx.llfn(), llarg_idx as c_uint);
444                 llarg_idx += 1;
445
446                 // FIXME(eddyb) As we can't perfectly represent the data and/or
447                 // vtable pointer in a fat pointers in Rust's typesystem, and
448                 // because we split fat pointers into two ArgType's, they're
449                 // not the right type so we have to cast them for now.
450                 let pointee = match arg_ty.sty {
451                     ty::TyRef(_, ty::TypeAndMut{ty, ..}) |
452                     ty::TyRawPtr(ty::TypeAndMut{ty, ..}) => ty,
453                     ty::TyAdt(def, _) if def.is_box() => arg_ty.boxed_ty(),
454                     _ => bug!()
455                 };
456                 let data_llty = type_of::in_memory_type_of(bcx.ccx, pointee);
457                 let meta_llty = type_of::unsized_info_ty(bcx.ccx, pointee);
458
459                 let llarg = bcx.pointercast(llarg, data_llty.ptr_to());
460                 let llmeta = bcx.pointercast(llmeta, meta_llty);
461
462                 OperandValue::Pair(llarg, llmeta)
463             } else {
464                 OperandValue::Immediate(llarg)
465             };
466             let operand = OperandRef {
467                 val: val,
468                 ty: arg_ty
469             };
470             return LocalRef::Operand(Some(operand.unpack_if_pair(bcx)));
471         } else {
472             let lltemp = LvalueRef::alloca(bcx, arg_ty, &format!("arg{}", arg_index));
473             if common::type_is_fat_ptr(bcx.ccx, arg_ty) {
474                 // we pass fat pointers as two words, but we want to
475                 // represent them internally as a pointer to two words,
476                 // so make an alloca to store them in.
477                 let meta = &mircx.fn_ty.args[idx];
478                 idx += 1;
479                 arg.store_fn_arg(bcx, &mut llarg_idx, base::get_dataptr(bcx, lltemp.llval));
480                 meta.store_fn_arg(bcx, &mut llarg_idx, base::get_meta(bcx, lltemp.llval));
481             } else  {
482                 // otherwise, arg is passed by value, so make a
483                 // temporary and store it there
484                 arg.store_fn_arg(bcx, &mut llarg_idx, lltemp.llval);
485             }
486             lltemp.llval
487         };
488         arg_scope.map(|scope| {
489             // Is this a regular argument?
490             if arg_index > 0 || mir.upvar_decls.is_empty() {
491                 declare_local(
492                     bcx,
493                     &mircx.debug_context,
494                     arg_decl.name.unwrap_or(keywords::Invalid.name()),
495                     arg_ty,
496                     scope,
497                     VariableAccess::DirectVariable { alloca: llval },
498                     VariableKind::ArgumentVariable(arg_index + 1),
499                     DUMMY_SP
500                 );
501                 return;
502             }
503
504             // Or is it the closure environment?
505             let (closure_ty, env_ref) = if let ty::TyRef(_, mt) = arg_ty.sty {
506                 (mt.ty, true)
507             } else {
508                 (arg_ty, false)
509             };
510             let upvar_tys = if let ty::TyClosure(def_id, substs) = closure_ty.sty {
511                 substs.upvar_tys(def_id, tcx)
512             } else {
513                 bug!("upvar_decls with non-closure arg0 type `{}`", closure_ty);
514             };
515
516             // Store the pointer to closure data in an alloca for debuginfo
517             // because that's what the llvm.dbg.declare intrinsic expects.
518
519             // FIXME(eddyb) this shouldn't be necessary but SROA seems to
520             // mishandle DW_OP_plus not preceded by DW_OP_deref, i.e. it
521             // doesn't actually strip the offset when splitting the closure
522             // environment into its components so it ends up out of bounds.
523             let env_ptr = if !env_ref {
524                 let alloc = bcx.alloca(common::val_ty(llval), "__debuginfo_env_ptr");
525                 bcx.store(llval, alloc, None);
526                 alloc
527             } else {
528                 llval
529             };
530
531             let layout = bcx.ccx.layout_of(closure_ty);
532             let offsets = match *layout {
533                 layout::Univariant { ref variant, .. } => &variant.offsets[..],
534                 _ => bug!("Closures are only supposed to be Univariant")
535             };
536
537             for (i, (decl, ty)) in mir.upvar_decls.iter().zip(upvar_tys).enumerate() {
538                 let byte_offset_of_var_in_env = offsets[i].bytes();
539
540                 let ops = unsafe {
541                     [llvm::LLVMRustDIBuilderCreateOpDeref(),
542                      llvm::LLVMRustDIBuilderCreateOpPlus(),
543                      byte_offset_of_var_in_env as i64,
544                      llvm::LLVMRustDIBuilderCreateOpDeref()]
545                 };
546
547                 // The environment and the capture can each be indirect.
548
549                 // FIXME(eddyb) see above why we have to keep
550                 // a pointer in an alloca for debuginfo atm.
551                 let mut ops = if env_ref || true { &ops[..] } else { &ops[1..] };
552
553                 let ty = if let (true, &ty::TyRef(_, mt)) = (decl.by_ref, &ty.sty) {
554                     mt.ty
555                 } else {
556                     ops = &ops[..ops.len() - 1];
557                     ty
558                 };
559
560                 let variable_access = VariableAccess::IndirectVariable {
561                     alloca: env_ptr,
562                     address_operations: &ops
563                 };
564                 declare_local(
565                     bcx,
566                     &mircx.debug_context,
567                     decl.debug_name,
568                     ty,
569                     scope,
570                     variable_access,
571                     VariableKind::CapturedVariable,
572                     DUMMY_SP
573                 );
574             }
575         });
576         LocalRef::Lvalue(LvalueRef::new_sized(llval, LvalueTy::from_ty(arg_ty),
577                                               Alignment::AbiAligned))
578     }).collect()
579 }
580
581 mod analyze;
582 mod block;
583 mod constant;
584 pub mod lvalue;
585 mod operand;
586 mod rvalue;
587 mod statement;