pub fn load_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
                           ptr: ValueRef, t: Ty<'tcx>) -> ValueRef {
    if cx.unreachable.get() || type_is_zero_size(cx.ccx(), t) {
        return C_undef(type_of::type_of(cx.ccx(), t));
    }

    let ptr = to_arg_ty_ptr(cx, ptr, t);
    let align = type_of::align_of(cx.ccx(), t);

    if type_is_immediate(cx.ccx(), t) && type_of::type_of(cx.ccx(), t).is_aggregate() {
        let load = Load(cx, ptr);
        unsafe {
            llvm::LLVMSetAlignment(load, align);
        }
        return load;
    }

    unsafe {
        let global = llvm::LLVMIsAGlobalVariable(ptr);
        if !global.is_null() && llvm::LLVMIsGlobalConstant(global) == llvm::True {
            let val = llvm::LLVMGetInitializer(global);
            if !val.is_null() {
                return from_arg_ty(cx, val, t);
            }
        }
    }

    let val =  if ty::type_is_bool(t) {
        LoadRangeAssert(cx, ptr, 0, 2, llvm::False)
    } else if ty::type_is_char(t) {
        // a char is a Unicode codepoint, and so takes values from 0
        // to 0x10FFFF inclusive only.
        LoadRangeAssert(cx, ptr, 0, 0x10FFFF + 1, llvm::False)
    } else if (ty::type_is_region_ptr(t) || ty::type_is_unique(t))
        && !common::type_is_fat_ptr(cx.tcx(), t) {
            LoadNonNull(cx, ptr)
    } else {
        Load(cx, ptr)
    };

    unsafe {
        llvm::LLVMSetAlignment(val, align);
    }

    from_arg_ty(cx, val, t)
}
/// Helper for loading values from memory. Does the necessary conversion if the in-memory type
/// differs from the type used for SSA values. Also handles various special cases where the type
/// gives us better information about what we are loading.
Helper for loading values from memory. Does the necessary conversion if the in-memory type
differs from the type used for SSA values. Also handles various special cases where the type
gives us better information about what we are loading.
Helper for loading values from memory . Does the necessary conversion if the in - memory type differs from the type used for SSA values . Also handles various special cases where the type gives us better information about what we are loading .
pub fn load_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
                           ptr: ValueRef, t: Ty<'tcx>) -> ValueRef {
    if cx.unreachable.get() || type_is_zero_size(cx.ccx(), t) {
        return C_undef(type_of::type_of(cx.ccx(), t));
    }
    let ptr = to_arg_ty_ptr(cx, ptr, t);
    let align = type_of::align_of(cx.ccx(), t);
    if type_is_immediate(cx.ccx(), t) && type_of::type_of(cx.ccx(), t).is_aggregate() {
        let load = Load(cx, ptr);
        unsafe {
            llvm::LLVMSetAlignment(load, align);
        }
        return load;
    }
    unsafe {
        let global = llvm::LLVMIsAGlobalVariable(ptr);
        if !global.is_null() && llvm::LLVMIsGlobalConstant(global) == llvm::True {
            let val = llvm::LLVMGetInitializer(global);
            if !val.is_null() {
                return from_arg_ty(cx, val, t);
            }
        }
    }
    let val =  if ty::type_is_bool(t) {
        LoadRangeAssert(cx, ptr, 0, 2, llvm::False)
    } else if ty::type_is_char(t) {
        // a char is a Unicode codepoint, and so takes values from 0
        // to 0x10FFFF inclusive only.
        LoadRangeAssert(cx, ptr, 0, 0x10FFFF + 1, llvm::False)
    } else if (ty::type_is_region_ptr(t) || ty::type_is_unique(t))
        && !common::type_is_fat_ptr(cx.tcx(), t) {
            LoadNonNull(cx, ptr)
    } else {
        Load(cx, ptr)
    };
    unsafe {
        llvm::LLVMSetAlignment(val, align);
    }
    from_arg_ty(cx, val, t)
}
pub fn load_ty < ' blk , ' tcx > ( cx : Block < ' blk , ' tcx > , ptr : ValueRef , t : Ty < ' tcx > ) -> ValueRef { if cx . unreachable . get ( ) || type_is_zero_size ( cx . ccx ( ) , t ) { return C_undef ( type_of :: type_of ( cx . ccx ( ) , t ) ) ; } let ptr = to_arg_ty_ptr ( cx , ptr , t ) ; let align = type_of :: align_of ( cx . ccx ( ) , t ) ; if type_is_immediate ( cx . ccx ( ) , t ) && type_of :: type_of ( cx . ccx ( ) , t ) . is_aggregate ( ) { let load = Load ( cx , ptr ) ; unsafe { llvm :: LLVMSetAlignment ( load , align ) ; } return load ; } unsafe { let global = llvm :: LLVMIsAGlobalVariable ( ptr ) ; if ! global . is_null ( ) && llvm :: LLVMIsGlobalConstant ( global ) == llvm :: True { let val = llvm :: LLVMGetInitializer ( global ) ; if ! val . is_null ( ) { return from_arg_ty ( cx , val , t ) ; } } } let val = if ty :: type_is_bool ( t ) { LoadRangeAssert ( cx , ptr , 0 , 2 , llvm :: False ) } else if ty :: type_is_char ( t ) { // a char is a Unicode codepoint, and so takes values from 0 // to 0x10FFFF inclusive only. LoadRangeAssert ( cx , ptr , 0 , 0x10FFFF + 1 , llvm :: False ) } else if ( ty :: type_is_region_ptr ( t ) || ty :: type_is_unique ( t ) ) && ! common :: type_is_fat_ptr ( cx . tcx ( ) , t ) { LoadNonNull ( cx , ptr ) } else { Load ( cx , ptr ) } ; unsafe { llvm :: LLVMSetAlignment ( val , align ) ; } from_arg_ty ( cx , val , t ) }
Helper for loading values from memory.
Helper for loading values from memory .
cx
Block<'blk, 'tcx>
ptr
ValueRef
t
Ty<'tcx>