diff options
| author | bors <bors@rust-lang.org> | 2013-05-10 13:10:54 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-05-10 13:10:54 -0700 |
| commit | d546493096f35e68cbcd9b5d3d7654e7a9345744 (patch) | |
| tree | 1b2818b15b2d6358faf62730b1711f2c35aacfe1 | |
| parent | dba9337a48e9cb50f4323a605960c3b31df1706b (diff) | |
| parent | 923450d00c142f4f9baed042eedbe88e7004b661 (diff) | |
| download | rust-d546493096f35e68cbcd9b5d3d7654e7a9345744.tar.gz rust-d546493096f35e68cbcd9b5d3d7654e7a9345744.zip | |
auto merge of #6380 : pcwalton/rust/core-text-ice, r=pcwalton
| -rw-r--r-- | src/librustc/middle/trans/expr.rs | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index e7d47561950..1b7cdf3ac80 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -968,7 +968,10 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock { } fn get_val(bcx: block, did: ast::def_id, const_ty: ty::t) - -> ValueRef { + -> ValueRef { + // For external constants, we don't inline. + let extern_const_values = + &mut *bcx.ccx().extern_const_values; if did.crate == ast::local_crate { // The LLVM global has the type of its initializer, // which may not be equal to the enum's type for @@ -977,25 +980,24 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock { base::get_item_val(bcx.ccx(), did.node), T_ptr(type_of(bcx.ccx(), const_ty))) } else { - // For external constants, we don't inline. - match bcx.ccx().extern_const_values.find(&did) { - None => { - unsafe { - let llty = type_of(bcx.ccx(), const_ty); - let symbol = csearch::get_symbol( - bcx.ccx().sess.cstore, - did); - let llval = llvm::LLVMAddGlobal( - bcx.ccx().llmod, - llty, - transmute::<&u8,*i8>(&symbol[0])); - bcx.ccx().extern_const_values.insert( - did, - llval); - llval - } + match extern_const_values.find(&did) { + None => {} // Continue. + Some(llval) => { + return *llval; } - Some(llval) => *llval + } + + unsafe { + let llty = type_of(bcx.ccx(), const_ty); + let symbol = csearch::get_symbol( + bcx.ccx().sess.cstore, + did); + let llval = llvm::LLVMAddGlobal( + bcx.ccx().llmod, + llty, + transmute::<&u8,*i8>(&symbol[0])); + extern_const_values.insert(did, llval); + llval } } } |
