mod.rs 22.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use libc::c_uint;
use llvm::{self, ValueRef};
13
use rustc::ty;
14 15
use rustc::mir::repr as mir;
use rustc::mir::tcx::LvalueTy;
16
use session::config::FullDebugInfo;
17
use base;
18
use common::{self, Block, BlockAndBuilder, CrateContext, FunctionContext, C_null};
19
use debuginfo::{self, declare_local, DebugLoc, VariableAccess, VariableKind, FunctionDebugContext};
20 21 22
use machine;
use type_of;

23
use syntax_pos::{DUMMY_SP, NO_EXPANSION, COMMAND_LINE_EXPN, BytePos};
24
use syntax::parse::token::keywords;
25

26 27
use std::ops::Deref;
use std::rc::Rc;
28
use std::iter;
29

30
use basic_block::BasicBlock;
31

32
use rustc_data_structures::bitvec::BitVector;
33
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
34

35 36
pub use self::constant::trans_static_initializer;

37
use self::lvalue::{LvalueRef, get_dataptr, get_meta};
38
use rustc::mir::traversal;
39

40
use self::operand::{OperandRef, OperandValue};
41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#[derive(Clone)]
pub enum CachedMir<'mir, 'tcx: 'mir> {
    Ref(&'mir mir::Mir<'tcx>),
    Owned(Rc<mir::Mir<'tcx>>)
}

impl<'mir, 'tcx: 'mir> Deref for CachedMir<'mir, 'tcx> {
    type Target = mir::Mir<'tcx>;
    fn deref(&self) -> &mir::Mir<'tcx> {
        match *self {
            CachedMir::Ref(r) => r,
            CachedMir::Owned(ref rc) => rc
        }
    }
}

58 59
/// Master context for translating MIR.
pub struct MirContext<'bcx, 'tcx:'bcx> {
60
    mir: CachedMir<'bcx, 'tcx>,
61

62 63 64
    /// Function context
    fcx: &'bcx common::FunctionContext<'bcx, 'tcx>,

65 66 67 68 69 70 71 72 73 74
    /// When unwinding is initiated, we have to store this personality
    /// value somewhere so that we can load it and re-use it in the
    /// resume instruction. The personality is (afaik) some kind of
    /// value used for C++ unwinding, which must filter by type: we
    /// don't really care about it very much. Anyway, this value
    /// contains an alloca into which the personality is stored and
    /// then later loaded when generating the DIVERGE_BLOCK.
    llpersonalityslot: Option<ValueRef>,

    /// A `Block` for each MIR `BasicBlock`
75
    blocks: IndexVec<mir::BasicBlock, Block<'bcx, 'tcx>>,
76

77
    /// The funclet status of each basic block
78
    cleanup_kinds: IndexVec<mir::BasicBlock, analyze::CleanupKind>,
79 80 81

    /// This stores the landing-pad block for a given BB, computed lazily on GNU
    /// and eagerly on MSVC.
82
    landing_pads: IndexVec<mir::BasicBlock, Option<Block<'bcx, 'tcx>>>,
83

84 85 86
    /// Cached unreachable block
    unreachable_block: Option<Block<'bcx, 'tcx>>,

87
    /// The location where each MIR arg/var/tmp/ret is stored. This is
88 89 90 91 92
    /// usually an `LvalueRef` representing an alloca, but not always:
    /// sometimes we can skip the alloca and just store the value
    /// directly using an `OperandRef`, which makes for tighter LLVM
    /// IR. The conditions for using an `OperandRef` are as follows:
    ///
93
    /// - the type of the local must be judged "immediate" by `type_is_immediate`
94 95 96 97 98
    /// - the operand must never be referenced indirectly
    ///     - we should not take its address using the `&` operator
    ///     - nor should it appear in an lvalue path like `tmp.a`
    /// - the operand must be defined by an rvalue that can generate immediate
    ///   values
N
Niko Matsakis 已提交
99 100 101
    ///
    /// Avoiding allocs can also be important for certain intrinsics,
    /// notably `expect`.
102
    locals: IndexVec<mir::Local, LocalRef<'tcx>>,
103 104

    /// Debug information for MIR scopes.
105
    scopes: IndexVec<mir::VisibilityScope, debuginfo::MirDebugScope>,
106 107
}

108
impl<'blk, 'tcx> MirContext<'blk, 'tcx> {
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
    pub fn debug_loc(&mut self, source_info: mir::SourceInfo) -> DebugLoc {
        // Bail out if debug info emission is not enabled.
        match self.fcx.debug_context {
            FunctionDebugContext::DebugInfoDisabled |
            FunctionDebugContext::FunctionWithoutDebugInfo => {
                // Can't return DebugLoc::None here because intrinsic::trans_intrinsic_call()
                // relies on debug location to obtain span of the call site.
                return DebugLoc::ScopeAt(self.scopes[source_info.scope].scope_metadata,
                                         source_info.span);
            }
            FunctionDebugContext::RegularContext(_) =>{}
        }

        // In order to have a good line stepping behavior in debugger, we overwrite debug
        // locations of macro expansions with that of the outermost expansion site
        // (unless the crate is being compiled with `-Z debug-macros`).
        if source_info.span.expn_id == NO_EXPANSION ||
            source_info.span.expn_id == COMMAND_LINE_EXPN ||
            self.fcx.ccx.sess().opts.debugging_opts.debug_macros {

            let scope_metadata = self.scope_metadata_for_loc(source_info.scope,
                                                             source_info.span.lo);
            DebugLoc::ScopeAt(scope_metadata, source_info.span)
        } else {
            let cm = self.fcx.ccx.sess().codemap();
            // Walk up the macro expansion chain until we reach a non-expanded span.
            let mut span = source_info.span;
            while span.expn_id != NO_EXPANSION && span.expn_id != COMMAND_LINE_EXPN {
                if let Some(callsite_span) = cm.with_expn_info(span.expn_id,
                                                    |ei| ei.map(|ei| ei.call_site.clone())) {
                    span = callsite_span;
                } else {
                    break;
                }
            }
            let scope_metadata = self.scope_metadata_for_loc(source_info.scope, span.lo);
            // Use span of the outermost call site, while keeping the original lexical scope
            DebugLoc::ScopeAt(scope_metadata, span)
        }
    }

    // DILocations inherit source file name from the parent DIScope.  Due to macro expansions
    // it may so happen that the current span belongs to a different file than the DIScope
    // corresponding to span's containing visibility scope.  If so, we need to create a DIScope
    // "extension" into that file.
    fn scope_metadata_for_loc(&self, scope_id: mir::VisibilityScope, pos: BytePos)
                               -> llvm::debuginfo::DIScope {
        let scope_metadata = self.scopes[scope_id].scope_metadata;
        if pos < self.scopes[scope_id].file_start_pos ||
           pos >= self.scopes[scope_id].file_end_pos {
            let cm = self.fcx.ccx.sess().codemap();
            debuginfo::extend_scope_to_file(self.fcx.ccx,
                                            scope_metadata,
                                            &cm.lookup_char_pos(pos).file)
        } else {
            scope_metadata
        }
166 167 168
    }
}

169
enum LocalRef<'tcx> {
170 171 172 173
    Lvalue(LvalueRef<'tcx>),
    Operand(Option<OperandRef<'tcx>>),
}

174
impl<'tcx> LocalRef<'tcx> {
175
    fn new_operand<'bcx>(ccx: &CrateContext<'bcx, 'tcx>,
176
                         ty: ty::Ty<'tcx>) -> LocalRef<'tcx> {
177 178 179 180
        if common::type_is_zero_size(ccx, ty) {
            // Zero-size temporaries aren't always initialized, which
            // doesn't matter because they don't contain data, but
            // we need something in the operand.
181
            let llty = type_of::type_of(ccx, ty);
182
            let val = if common::type_is_imm_pair(ccx, ty) {
183 184
                let fields = llty.field_types();
                OperandValue::Pair(C_null(fields[0]), C_null(fields[1]))
185
            } else {
186
                OperandValue::Immediate(C_null(llty))
187
            };
188 189 190 191
            let op = OperandRef {
                val: val,
                ty: ty
            };
192
            LocalRef::Operand(Some(op))
193
        } else {
194
            LocalRef::Operand(None)
195
        }
J
James Miller 已提交
196 197 198
    }
}

199 200
///////////////////////////////////////////////////////////////////////////

201
pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
202
    let bcx = fcx.init(true).build();
203 204
    let mir = bcx.mir();

205 206
    // Analyze the temps to determine which must be lvalues
    // FIXME
207 208
    let (lvalue_locals, cleanup_kinds) = bcx.with_block(|bcx| {
        (analyze::lvalue_locals(bcx, &mir),
209
         analyze::cleanup_kinds(bcx, &mir))
210
    });
211

212 213 214 215 216 217 218 219 220 221
    // Allocate a `Block` for every basic block
    let block_bcxs: IndexVec<mir::BasicBlock, Block<'blk,'tcx>> =
        mir.basic_blocks().indices().map(|bb| {
            if bb == mir::START_BLOCK {
                fcx.new_block("start")
            } else {
                fcx.new_block(&format!("{:?}", bb))
            }
        }).collect();

222 223 224
    // Compute debuginfo scopes from MIR scopes.
    let scopes = debuginfo::create_mir_scopes(fcx);

225 226 227 228 229 230 231 232 233 234 235 236
    let mut mircx = MirContext {
        mir: mir.clone(),
        fcx: fcx,
        llpersonalityslot: None,
        blocks: block_bcxs,
        unreachable_block: None,
        cleanup_kinds: cleanup_kinds,
        landing_pads: IndexVec::from_elem(None, mir.basic_blocks()),
        scopes: scopes,
        locals: IndexVec::new(),
    };

237
    // Allocate variable and temp allocas
238 239
    mircx.locals = {
        let args = arg_local_refs(&bcx, &mir, &mircx.scopes, &lvalue_locals);
240 241 242

        let mut allocate_local = |local| {
            let decl = &mir.local_decls[local];
243 244
            let ty = bcx.monomorphize(&decl.ty);

245 246 247 248 249
            if let Some(name) = decl.name {
                // User variable
                let source_info = decl.source_info.unwrap();
                let debug_scope = mircx.scopes[source_info.scope];
                let dbg = debug_scope.is_valid() && bcx.sess().opts.debuginfo == FullDebugInfo;
250

251 252 253
                if !lvalue_locals.contains(local.index()) && !dbg {
                    debug!("alloc: {:?} ({}) -> operand", local, name);
                    return LocalRef::new_operand(bcx.ccx(), ty);
254
                }
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270

                debug!("alloc: {:?} ({}) -> lvalue", local, name);
                let lvalue = LvalueRef::alloca(&bcx, ty, &name.as_str());
                if dbg {
                    let dbg_loc = mircx.debug_loc(source_info);
                    if let DebugLoc::ScopeAt(scope, span) = dbg_loc {
                        bcx.with_block(|bcx| {
                            declare_local(bcx, name, ty, scope,
                                        VariableAccess::DirectVariable { alloca: lvalue.llval },
                                        VariableKind::LocalVariable, span);
                        });
                    } else {
                        panic!("Unexpected");
                    }
                }
                LocalRef::Lvalue(lvalue)
271
            } else {
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
                // Temporary or return pointer
                if local == mir::RETURN_POINTER && fcx.fn_ty.ret.is_indirect() {
                    debug!("alloc: {:?} (return pointer) -> lvalue", local);
                    let llretptr = llvm::get_param(fcx.llfn, 0);
                    LocalRef::Lvalue(LvalueRef::new_sized(llretptr, LvalueTy::from_ty(ty)))
                } else if lvalue_locals.contains(local.index()) {
                    debug!("alloc: {:?} -> lvalue", local);
                    LocalRef::Lvalue(LvalueRef::alloca(&bcx, ty, &format!("{:?}", local)))
                } else {
                    // If this is an immediate local, we do not create an
                    // alloca in advance. Instead we wait until we see the
                    // definition and update the operand there.
                    debug!("alloc: {:?} -> operand", local);
                    LocalRef::new_operand(bcx.ccx(), ty)
                }
287
            }
288 289 290 291 292 293 294
        };

        let retptr = allocate_local(mir::RETURN_POINTER);
        iter::once(retptr)
            .chain(args.into_iter())
            .chain(mir.var_and_temp_iter().map(&mut allocate_local))
            .collect()
295
    };
296 297

    // Branch to the START block
298
    let start_bcx = mircx.blocks[mir::START_BLOCK];
299
    bcx.br(start_bcx.llbb);
300

301 302 303 304 305
    // Up until here, IR instructions for this function have explicitly not been annotated with
    // source code location, so we don't step into call setup code. From here on, source location
    // emitting should be enabled.
    debuginfo::start_emitting_source_locations(fcx);

306
    let mut visited = BitVector::new(mir.basic_blocks().len());
307

308 309 310 311 312 313 314 315
    let mut rpo = traversal::reverse_postorder(&mir);

    // Prepare each block for translation.
    for (bb, _) in rpo.by_ref() {
        mircx.init_cpad(bb);
    }
    rpo.reset();

316 317
    // Translate the body of each block using reverse postorder
    for (bb, _) in rpo {
318
        visited.insert(bb.index());
S
Simonas Kazlauskas 已提交
319
        mircx.trans_block(bb);
320
    }
321

322 323
    // Remove blocks that haven't been visited, or have no
    // predecessors.
324
    for bb in mir.basic_blocks().indices() {
325
        let block = mircx.blocks[bb];
326 327
        let block = BasicBlock(block.llbb);
        // Unreachable block
328
        if !visited.contains(bb.index()) {
329
            debug!("trans_mir: block {:?} was not visited", bb);
330
            block.delete();
331 332 333
        }
    }

334
    DebugLoc::None.apply(fcx);
335
    fcx.cleanup();
336 337 338 339 340
}

/// Produce, for each argument, a `ValueRef` pointing at the
/// argument's value. As arguments are lvalues, these are always
/// indirect.
341
fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
342
                              mir: &mir::Mir<'tcx>,
343
                              scopes: &IndexVec<mir::VisibilityScope, debuginfo::MirDebugScope>,
344 345
                              lvalue_locals: &BitVector)
                              -> Vec<LocalRef<'tcx>> {
346
    let fcx = bcx.fcx();
347
    let tcx = bcx.tcx();
348 349
    let mut idx = 0;
    let mut llarg_idx = fcx.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 354
    let arg_scope = if arg_scope.is_valid() && bcx.sess().opts.debuginfo == FullDebugInfo {
        Some(arg_scope.scope_metadata)
355 356 357
    } else {
        None
    };
358

359 360
    mir.arg_iter().enumerate().map(|(arg_index, local)| {
        let arg_decl = &mir.local_decls[local];
361 362
        let arg_ty = bcx.monomorphize(&arg_decl.ty);

363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
        if let Some(spread_local) = mir.spread_arg {
            if local == spread_local {
                // This argument (e.g. the last argument in the "rust-call" ABI)
                // is a tuple that was spread at the ABI level and now we have
                // to reconstruct it into a tuple local variable, from multiple
                // individual LLVM function arguments.

                let tupled_arg_tys = match arg_ty.sty {
                    ty::TyTuple(ref tys) => tys,
                    _ => bug!("spread argument isn't a tuple?!")
                };

                let lltuplety = type_of::type_of(bcx.ccx(), arg_ty);
                let lltemp = bcx.with_block(|bcx| {
                    base::alloc_ty(bcx, arg_ty, &format!("arg{}", arg_index))
                });
                for (i, &tupled_arg_ty) in tupled_arg_tys.iter().enumerate() {
                    let dst = bcx.struct_gep(lltemp, i);
                    let arg = &fcx.fn_ty.args[idx];
382
                    idx += 1;
383 384 385 386 387 388 389 390 391 392
                    if common::type_is_fat_ptr(tcx, tupled_arg_ty) {
                        // We pass fat pointers as two words, but inside the tuple
                        // they are the two sub-fields of a single aggregate field.
                        let meta = &fcx.fn_ty.args[idx];
                        idx += 1;
                        arg.store_fn_arg(bcx, &mut llarg_idx, get_dataptr(bcx, dst));
                        meta.store_fn_arg(bcx, &mut llarg_idx, get_meta(bcx, dst));
                    } else {
                        arg.store_fn_arg(bcx, &mut llarg_idx, dst);
                    }
393

394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
                    bcx.with_block(|bcx| arg_scope.map(|scope| {
                        let byte_offset_of_var_in_tuple =
                            machine::llelement_offset(bcx.ccx(), lltuplety, i);

                        let ops = unsafe {
                            [llvm::LLVMRustDIBuilderCreateOpDeref(),
                             llvm::LLVMRustDIBuilderCreateOpPlus(),
                             byte_offset_of_var_in_tuple as i64]
                        };

                        let variable_access = VariableAccess::IndirectVariable {
                            alloca: lltemp,
                            address_operations: &ops
                        };
                        declare_local(bcx, keywords::Invalid.name(),
                                      tupled_arg_ty, scope, variable_access,
                                      VariableKind::ArgumentVariable(arg_index + i + 1),
                                      bcx.fcx().span.unwrap_or(DUMMY_SP));
                    }));
                }
                return LocalRef::Lvalue(LvalueRef::new_sized(lltemp, LvalueTy::from_ty(arg_ty)));
415
            }
416 417
        }

418 419
        let arg = &fcx.fn_ty.args[idx];
        idx += 1;
420
        let llval = if arg.is_indirect() && bcx.sess().opts.debuginfo != FullDebugInfo {
421 422 423
            // Don't copy an indirect argument to an alloca, the caller
            // already put it in a temporary alloca and gave it up, unless
            // we emit extra-debug-info, which requires local allocas :(.
424
            // FIXME: lifetimes
425 426 427
            if arg.pad.is_some() {
                llarg_idx += 1;
            }
428 429 430
            let llarg = llvm::get_param(fcx.llfn, llarg_idx as c_uint);
            llarg_idx += 1;
            llarg
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
        } else if !lvalue_locals.contains(local.index()) &&
                  !arg.is_indirect() && arg.cast.is_none() &&
                  arg_scope.is_none() {
            if arg.is_ignore() {
                return LocalRef::new_operand(bcx.ccx(), arg_ty);
            }

            // We don't have to cast or keep the argument in the alloca.
            // FIXME(eddyb): We should figure out how to use llvm.dbg.value instead
            // of putting everything in allocas just so we can use llvm.dbg.declare.
            if arg.pad.is_some() {
                llarg_idx += 1;
            }
            let llarg = llvm::get_param(fcx.llfn, llarg_idx as c_uint);
            llarg_idx += 1;
            let val = if common::type_is_fat_ptr(tcx, arg_ty) {
                let meta = &fcx.fn_ty.args[idx];
                idx += 1;
                assert_eq!((meta.cast, meta.pad), (None, None));
                let llmeta = llvm::get_param(fcx.llfn, llarg_idx as c_uint);
                llarg_idx += 1;
                OperandValue::Pair(llarg, llmeta)
            } else {
                OperandValue::Immediate(llarg)
            };
            let operand = OperandRef {
                val: val,
                ty: arg_ty
            };
            return LocalRef::Operand(Some(operand.unpack_if_pair(bcx)));
461
        } else {
462 463 464
            let lltemp = bcx.with_block(|bcx| {
                base::alloc_ty(bcx, arg_ty, &format!("arg{}", arg_index))
            });
465 466 467 468 469 470 471 472 473
            if common::type_is_fat_ptr(tcx, arg_ty) {
                // we pass fat pointers as two words, but we want to
                // represent them internally as a pointer to two words,
                // so make an alloca to store them in.
                let meta = &fcx.fn_ty.args[idx];
                idx += 1;
                arg.store_fn_arg(bcx, &mut llarg_idx, get_dataptr(bcx, lltemp));
                meta.store_fn_arg(bcx, &mut llarg_idx, get_meta(bcx, lltemp));
            } else  {
474 475
                // otherwise, arg is passed by value, so make a
                // temporary and store it there
476 477
                arg.store_fn_arg(bcx, &mut llarg_idx, lltemp);
            }
478
            lltemp
479
        };
480
        bcx.with_block(|bcx| arg_scope.map(|scope| {
481 482
            // Is this a regular argument?
            if arg_index > 0 || mir.upvar_decls.is_empty() {
483 484
                declare_local(bcx, arg_decl.name.unwrap_or(keywords::Invalid.name()), arg_ty,
                              scope, VariableAccess::DirectVariable { alloca: llval },
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
                              VariableKind::ArgumentVariable(arg_index + 1),
                              bcx.fcx().span.unwrap_or(DUMMY_SP));
                return;
            }

            // Or is it the closure environment?
            let (closure_ty, env_ref) = if let ty::TyRef(_, mt) = arg_ty.sty {
                (mt.ty, true)
            } else {
                (arg_ty, false)
            };
            let upvar_tys = if let ty::TyClosure(_, ref substs) = closure_ty.sty {
                &substs.upvar_tys[..]
            } else {
                bug!("upvar_decls with non-closure arg0 type `{}`", closure_ty);
            };

            // Store the pointer to closure data in an alloca for debuginfo
            // because that's what the llvm.dbg.declare intrinsic expects.

            // FIXME(eddyb) this shouldn't be necessary but SROA seems to
            // mishandle DW_OP_plus not preceded by DW_OP_deref, i.e. it
            // doesn't actually strip the offset when splitting the closure
            // environment into its components so it ends up out of bounds.
            let env_ptr = if !env_ref {
                use base::*;
                use build::*;
                use common::*;
                let alloc = alloca(bcx, val_ty(llval), "__debuginfo_env_ptr");
                Store(bcx, llval, alloc);
                alloc
            } else {
                llval
            };

            let llclosurety = type_of::type_of(bcx.ccx(), closure_ty);
            for (i, (decl, ty)) in mir.upvar_decls.iter().zip(upvar_tys).enumerate() {
                let byte_offset_of_var_in_env =
                    machine::llelement_offset(bcx.ccx(), llclosurety, i);

                let ops = unsafe {
526 527
                    [llvm::LLVMRustDIBuilderCreateOpDeref(),
                     llvm::LLVMRustDIBuilderCreateOpPlus(),
528
                     byte_offset_of_var_in_env as i64,
529
                     llvm::LLVMRustDIBuilderCreateOpDeref()]
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
                };

                // The environment and the capture can each be indirect.

                // FIXME(eddyb) see above why we have to keep
                // a pointer in an alloca for debuginfo atm.
                let mut ops = if env_ref || true { &ops[..] } else { &ops[1..] };

                let ty = if let (true, &ty::TyRef(_, mt)) = (decl.by_ref, &ty.sty) {
                    mt.ty
                } else {
                    ops = &ops[..ops.len() - 1];
                    ty
                };

                let variable_access = VariableAccess::IndirectVariable {
                    alloca: env_ptr,
                    address_operations: &ops
                };
                declare_local(bcx, decl.debug_name, ty, scope, variable_access,
                              VariableKind::CapturedVariable,
                              bcx.fcx().span.unwrap_or(DUMMY_SP));
            }
553
        }));
554
        LocalRef::Lvalue(LvalueRef::new_sized(llval, LvalueTy::from_ty(arg_ty)))
555
    }).collect()
556 557
}

558
mod analyze;
559 560 561 562
mod block;
mod constant;
mod lvalue;
mod operand;
563
mod rvalue;
564
mod statement;