Skip to content

Commit 6e67af1

Browse files
committed
---
yaml --- r: 14812 b: refs/heads/try c: e54cde5 h: refs/heads/master v: v3
1 parent 7936234 commit 6e67af1

File tree

2 files changed

+25
-71
lines changed

2 files changed

+25
-71
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 463cf837ebe97423739c134f2497f89f571fa4e2
5+
refs/heads/try: e54cde52151feabf4dbcd4905f580eeae9a7f28f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/middle/trans/debuginfo.rs

Lines changed: 24 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,10 @@ fn create_block(cx: block) -> @metadata<block_md> {
268268
ret mdval;
269269
}
270270

271-
fn size_and_align_of<T>() -> (int, int) {
272-
(sys::size_of::<T>() as int, sys::align_of::<T>() as int)
271+
fn size_and_align_of(cx: crate_ctxt, t: ty::t) -> (int, int) {
272+
let llty = type_of::type_of(cx, t);
273+
(shape::llsize_of_real(cx, llty) as int,
274+
shape::llalign_of_real(cx, llty) as int)
273275
}
274276

275277
fn create_basic_type(cx: crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
@@ -282,33 +284,34 @@ fn create_basic_type(cx: crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
282284
option::none {}
283285
}
284286

285-
let (name, (size, align), encoding) = alt check ty {
286-
ast::ty_bool {("bool", size_and_align_of::<bool>(), DW_ATE_boolean)}
287+
let (name, encoding) = alt check ty {
288+
ast::ty_bool {("bool", DW_ATE_boolean)}
287289
ast::ty_int(m) { alt m {
288-
ast::ty_char {("char", size_and_align_of::<char>(), DW_ATE_unsigned)}
289-
ast::ty_i {("int", size_and_align_of::<int>(), DW_ATE_signed)}
290-
ast::ty_i8 {("i8", size_and_align_of::<i8>(), DW_ATE_signed_char)}
291-
ast::ty_i16 {("i16", size_and_align_of::<i16>(), DW_ATE_signed)}
292-
ast::ty_i32 {("i32", size_and_align_of::<i32>(), DW_ATE_signed)}
293-
ast::ty_i64 {("i64", size_and_align_of::<i64>(), DW_ATE_signed)}
290+
ast::ty_char {("char", DW_ATE_unsigned)}
291+
ast::ty_i {("int", DW_ATE_signed)}
292+
ast::ty_i8 {("i8", DW_ATE_signed_char)}
293+
ast::ty_i16 {("i16", DW_ATE_signed)}
294+
ast::ty_i32 {("i32", DW_ATE_signed)}
295+
ast::ty_i64 {("i64", DW_ATE_signed)}
294296
}}
295297
ast::ty_uint(m) { alt m {
296-
ast::ty_u {("uint", size_and_align_of::<uint>(), DW_ATE_unsigned)}
297-
ast::ty_u8 {("u8", size_and_align_of::<u8>(), DW_ATE_unsigned_char)}
298-
ast::ty_u16 {("u16", size_and_align_of::<u16>(), DW_ATE_unsigned)}
299-
ast::ty_u32 {("u32", size_and_align_of::<u32>(), DW_ATE_unsigned)}
300-
ast::ty_u64 {("u64", size_and_align_of::<u64>(), DW_ATE_unsigned)}
298+
ast::ty_u {("uint", DW_ATE_unsigned)}
299+
ast::ty_u8 {("u8", DW_ATE_unsigned_char)}
300+
ast::ty_u16 {("u16", DW_ATE_unsigned)}
301+
ast::ty_u32 {("u32", DW_ATE_unsigned)}
302+
ast::ty_u64 {("u64", DW_ATE_unsigned)}
301303
}}
302304
ast::ty_float(m) { alt m {
303-
ast::ty_f {("float", size_and_align_of::<float>(), DW_ATE_float)}
304-
ast::ty_f32 {("f32", size_and_align_of::<f32>(), DW_ATE_float)}
305-
ast::ty_f64 {("f64", size_and_align_of::<f64>(), DW_ATE_float)}
305+
ast::ty_f {("float", DW_ATE_float)}
306+
ast::ty_f32 {("f32", DW_ATE_float)}
307+
ast::ty_f64 {("f64", DW_ATE_float)}
306308
}}
307309
};
308310

309311
let fname = filename_from_span(cx, span);
310312
let file_node = create_file(cx, fname);
311313
let cu_node = create_compile_unit(cx, fname);
314+
let (size, align) = size_and_align_of(cx, t);
312315
let lldata = [lltag(tg),
313316
cu_node.node,
314317
llstr(name),
@@ -336,7 +339,7 @@ fn create_pointer_type(cx: crate_ctxt, t: ty::t, span: span,
336339
option::some(md) { ret md; }
337340
option::none {}
338341
}*/
339-
let (size, align) = size_and_align_of::<libc::intptr_t>();
342+
let (size, align) = size_and_align_of(cx, t);
340343
let fname = filename_from_span(cx, span);
341344
let file_node = create_file(cx, fname);
342345
//let cu_node = create_compile_unit(cx, fname);
@@ -410,7 +413,7 @@ fn create_record(cx: crate_ctxt, t: ty::t, fields: [ast::ty_field],
410413
for field in fields {
411414
let field_t = ty::get_field(t, field.node.ident).mt.ty;
412415
let ty_md = create_ty(cx, field_t, field.node.mt.ty);
413-
let (size, align) = member_size_and_align(cx.tcx, field.node.mt.ty);
416+
let (size, align) = size_and_align_of(cx, field_t);
414417
add_member(scx, field.node.ident,
415418
line_from_span(cx.sess.codemap, field.span) as int,
416419
size as int, align as int, ty_md.node);
@@ -492,7 +495,7 @@ fn create_vec(cx: crate_ctxt, vec_t: ty::t, elem_t: ty::t,
492495
add_member(scx, "alloc", 0, sys::size_of::<libc::size_t>() as int,
493496
sys::align_of::<libc::size_t>() as int, size_t_type.node);
494497
let subrange = llmdnode([lltag(SubrangeTag), lli64(0), lli64(0)]);
495-
let (arr_size, arr_align) = member_size_and_align(cx.tcx, elem_ty);
498+
let (arr_size, arr_align) = size_and_align_of(cx, elem_t);
496499
let data_ptr = create_composite_type(ArrayTypeTag, "", file_node.node, 0,
497500
arr_size, arr_align, 0,
498501
option::some(elem_ty_md.node),
@@ -503,55 +506,6 @@ fn create_vec(cx: crate_ctxt, vec_t: ty::t, elem_t: ty::t,
503506
ret @{node: llnode, data: {hash: ty::type_id(vec_t)}};
504507
}
505508

506-
fn member_size_and_align(tcx: ty::ctxt, ty: @ast::ty) -> (int, int) {
507-
alt ty.node {
508-
ast::ty_path(_, id) {
509-
alt check tcx.def_map.get(id) {
510-
ast::def_prim_ty(nty) {
511-
alt check nty {
512-
ast::ty_bool { size_and_align_of::<bool>() }
513-
ast::ty_int(m) { alt m {
514-
ast::ty_char { size_and_align_of::<char>() }
515-
ast::ty_i { size_and_align_of::<int>() }
516-
ast::ty_i8 { size_and_align_of::<i8>() }
517-
ast::ty_i16 { size_and_align_of::<i16>() }
518-
ast::ty_i32 { size_and_align_of::<i32>() }
519-
ast::ty_i64 { size_and_align_of::<i64>() }
520-
}}
521-
ast::ty_uint(m) { alt m {
522-
ast::ty_u { size_and_align_of::<uint>() }
523-
ast::ty_u8 { size_and_align_of::<i8>() }
524-
ast::ty_u16 { size_and_align_of::<u16>() }
525-
ast::ty_u32 { size_and_align_of::<u32>() }
526-
ast::ty_u64 { size_and_align_of::<u64>() }
527-
}}
528-
ast::ty_float(m) { alt m {
529-
ast::ty_f { size_and_align_of::<float>() }
530-
ast::ty_f32 { size_and_align_of::<f32>() }
531-
ast::ty_f64 { size_and_align_of::<f64>() }
532-
}}
533-
}
534-
}
535-
}
536-
}
537-
ast::ty_box(_) | ast::ty_uniq(_) {
538-
size_and_align_of::<libc::uintptr_t>()
539-
}
540-
ast::ty_rec(fields) {
541-
let total_size = 0;
542-
for field in fields {
543-
let (size, _) = member_size_and_align(tcx, field.node.mt.ty);
544-
total_size += size;
545-
}
546-
(total_size, 64) //XXX different align for other arches?
547-
}
548-
ast::ty_vec(_) {
549-
size_and_align_of::<libc::uintptr_t>()
550-
}
551-
_ { fail "member_size_and_align: can't handle this type"; }
552-
}
553-
}
554-
555509
fn create_ty(_cx: crate_ctxt, _t: ty::t, _ty: @ast::ty)
556510
-> @metadata<tydesc_md> {
557511
/*let cache = get_cache(cx);

0 commit comments

Comments
 (0)