Skip to content

Commit f00237a

Browse files
committed
---
yaml --- r: 40655 b: refs/heads/dist-snap c: aa3aa3b h: refs/heads/master i: 40653: 9376d99 40651: c55cef8 40647: 78f0048 40639: 27ea85b v: v3
1 parent b55e92e commit f00237a

File tree

6 files changed

+29
-9
lines changed

6 files changed

+29
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: 32ce61f947ebb1076c1fa2cd49e5d017b6ea1a0a
10+
refs/heads/dist-snap: aa3aa3b1b2b6d648af35122905d4958ad72377fb
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/trans/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,8 @@ fn trans_index(bcx: block,
10031003
// Translate index expression and cast to a suitable LLVM integer.
10041004
// Rust is less strict than LLVM in this regard.
10051005
let Result {bcx, val: ix_val} = trans_to_datum(bcx, idx).to_result();
1006-
let ix_size = shape::llsize_of_real(bcx.ccx(), val_ty(ix_val));
1007-
let int_size = shape::llsize_of_real(bcx.ccx(), ccx.int_type);
1006+
let ix_size = machine::llbitsize_of_real(bcx.ccx(), val_ty(ix_val));
1007+
let int_size = machine::llbitsize_of_real(bcx.ccx(), ccx.int_type);
10081008
let ix_val = {
10091009
if ix_size < int_size {
10101010
if ty::type_is_signed(expr_ty(bcx, idx)) {

branches/dist-snap/src/librustc/middle/trans/foreign.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -961,16 +961,17 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
961961
let tp_ty = substs.tys[0];
962962
let lltp_ty = type_of::type_of(ccx, tp_ty);
963963
let llout_ty = type_of::type_of(ccx, substs.tys[1]);
964-
let tp_sz = shape::llsize_of_real(ccx, lltp_ty),
965-
out_sz = shape::llsize_of_real(ccx, llout_ty);
964+
let tp_sz = machine::llbitsize_of_real(ccx, lltp_ty),
965+
out_sz = machine::llbitsize_of_real(ccx, llout_ty);
966966
if tp_sz != out_sz {
967967
let sp = match ccx.tcx.items.get(ref_id.get()) {
968968
ast_map::node_expr(e) => e.span,
969969
_ => fail ~"reinterpret_cast or forget has non-expr arg"
970970
};
971971
ccx.sess.span_fatal(
972972
sp, fmt!("reinterpret_cast called on types \
973-
with different size: %s (%u) to %s (%u)",
973+
with different size: %s (%u bit(s)) to %s \
974+
(%u bit(s))",
974975
ty_to_str(ccx.tcx, tp_ty), tp_sz,
975976
ty_to_str(ccx.tcx, substs.tys[1]), out_sz));
976977
}

branches/dist-snap/src/librustc/middle/trans/machine.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ pub fn llsize_of_alloc(cx: @crate_ctxt, t: TypeRef) -> uint {
8787
// bits in this number of bytes actually carry data related to the datum
8888
// with the type. Not junk, padding, accidentally-damaged words, or
8989
// whatever. Rounds up to the nearest byte though, so if you have a 1-bit
90-
// value, we return 1 here, not 0. Most of rustc works in bytes.
90+
// value, we return 1 here, not 0. Most of rustc works in bytes. Be warned
91+
// that LLVM *does* distinguish between e.g. a 1-bit value and an 8-bit value
92+
// at the codegen level! In general you should prefer `llbitsize_of_real`
93+
// below.
9194
pub fn llsize_of_real(cx: @crate_ctxt, t: TypeRef) -> uint {
9295
let nbits = llvm::LLVMSizeOfTypeInBits(cx.td.lltd, t) as uint;
9396
if nbits & 7u != 0u {
@@ -98,6 +101,11 @@ pub fn llsize_of_real(cx: @crate_ctxt, t: TypeRef) -> uint {
98101
}
99102
}
100103

104+
/// Returns the "real" size of the type in bits.
105+
pub fn llbitsize_of_real(cx: @crate_ctxt, t: TypeRef) -> uint {
106+
llvm::LLVMSizeOfTypeInBits(cx.td.lltd, t) as uint
107+
}
108+
101109
// Returns the "default" size of t, which is calculated by casting null to a
102110
// *T and then doing gep(1) on it and measuring the result. Really, look in
103111
// the LLVM sources. It does that. So this is likely similar to the ABI size

branches/dist-snap/src/librustc/middle/trans/monomorphize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
329329
!ty::type_needs_drop(ccx.tcx, subst)
330330
{
331331
let llty = type_of::type_of(ccx, subst);
332-
let size = shape::llsize_of_real(ccx, llty);
332+
let size = machine::llbitsize_of_real(ccx, llty);
333333
let align = shape::llalign_of_pref(ccx, llty);
334334
let mode = datum::appropriate_mode(subst);
335335

@@ -344,7 +344,7 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
344344

345345
// Special value for nil to prevent problems
346346
// with undef return pointers.
347-
if size == 1u && ty::type_is_nil(subst) {
347+
if size <= 8u && ty::type_is_nil(subst) {
348348
mono_repr(0u, 0u, is_float, mode)
349349
} else {
350350
mono_repr(size, align, is_float, mode)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use io::ReaderUtil;
2+
fn main() {
3+
let mut x: bool = false;
4+
// this line breaks it
5+
vec::rusti::move_val_init(&mut x, false);
6+
7+
let input = io::stdin();
8+
let line = input.read_line(); // use core's io again
9+
10+
io::println(fmt!("got %?", line));
11+
}

0 commit comments

Comments
 (0)