Skip to content

Commit c7bea76

Browse files
author
Dylan McKay
committed
Use u32 for alignments instead of u64
1 parent b4e6f70 commit c7bea76

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/librustc_trans/debuginfo/metadata.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ fn fixed_vec_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
299299
llvm::LLVMRustDIBuilderCreateArrayType(
300300
DIB(cx),
301301
bytes_to_bits(array_size_in_bytes),
302-
bytes_to_bits(element_type_align) as u32,
302+
bytes_to_bits(element_type_align),
303303
element_type_metadata,
304304
subscripts)
305305
};
@@ -730,7 +730,7 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
730730
DIB(cx),
731731
name.as_ptr(),
732732
bytes_to_bits(size),
733-
bytes_to_bits(align) as u32,
733+
bytes_to_bits(align),
734734
encoding)
735735
};
736736

@@ -750,7 +750,7 @@ fn pointer_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
750750
DIB(cx),
751751
pointee_type_metadata,
752752
bytes_to_bits(pointer_size),
753-
bytes_to_bits(pointer_align) as u32,
753+
bytes_to_bits(pointer_align),
754754
name.as_ptr())
755755
};
756756
return ptr_metadata;
@@ -1504,7 +1504,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
15041504
file_metadata,
15051505
UNKNOWN_LINE_NUMBER,
15061506
bytes_to_bits(discriminant_size),
1507-
bytes_to_bits(discriminant_align) as u32,
1507+
bytes_to_bits(discriminant_align),
15081508
create_DIArray(DIB(cx), &enumerators_metadata),
15091509
discriminant_base_type_metadata)
15101510
};
@@ -1546,7 +1546,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
15461546
file_metadata,
15471547
UNKNOWN_LINE_NUMBER,
15481548
bytes_to_bits(enum_type_size),
1549-
bytes_to_bits(enum_type_align) as u32,
1549+
bytes_to_bits(enum_type_align),
15501550
DIFlags::FlagZero,
15511551
ptr::null_mut(),
15521552
0, // RuntimeLang
@@ -1648,7 +1648,7 @@ fn set_members_of_composite_type(cx: &CrateContext,
16481648
unknown_file_metadata(cx),
16491649
UNKNOWN_LINE_NUMBER,
16501650
bytes_to_bits(member_size),
1651-
bytes_to_bits(member_align) as u32,
1651+
bytes_to_bits(member_align),
16521652
bytes_to_bits(member_offset),
16531653
member_description.flags,
16541654
member_description.type_metadata)
@@ -1691,7 +1691,7 @@ fn create_struct_stub(cx: &CrateContext,
16911691
unknown_file_metadata(cx),
16921692
UNKNOWN_LINE_NUMBER,
16931693
bytes_to_bits(struct_size),
1694-
bytes_to_bits(struct_align) as u32,
1694+
bytes_to_bits(struct_align),
16951695
DIFlags::FlagZero,
16961696
ptr::null_mut(),
16971697
empty_array,
@@ -1728,7 +1728,7 @@ fn create_union_stub(cx: &CrateContext,
17281728
unknown_file_metadata(cx),
17291729
UNKNOWN_LINE_NUMBER,
17301730
bytes_to_bits(union_size),
1731-
bytes_to_bits(union_align) as u32,
1731+
bytes_to_bits(union_align),
17321732
DIFlags::FlagZero,
17331733
empty_array,
17341734
0, // RuntimeLang
@@ -1783,7 +1783,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
17831783
is_local_to_unit,
17841784
global,
17851785
ptr::null_mut(),
1786-
global_align as u32,
1786+
global_align,
17871787
);
17881788
}
17891789
}

src/librustc_trans/debuginfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ pub fn declare_local<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
464464
cx.sess().opts.optimize != config::OptLevel::No,
465465
DIFlags::FlagZero,
466466
argument_index,
467-
align as u32,
467+
align,
468468
)
469469
};
470470
source_loc::set_debug_location(bcx,

src/librustc_trans/debuginfo/utils.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use type_::Type;
2424
use syntax_pos::{self, Span};
2525
use syntax::ast;
2626

27+
use std::ops;
28+
2729
pub fn is_node_local_to_unit(cx: &CrateContext, node_id: ast::NodeId) -> bool
2830
{
2931
// The is_local_to_unit flag indicates whether a function is local to the
@@ -49,12 +51,13 @@ pub fn span_start(cx: &CrateContext, span: Span) -> syntax_pos::Loc {
4951
cx.sess().codemap().lookup_char_pos(span.lo)
5052
}
5153

52-
pub fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (u64, u64) {
53-
(machine::llsize_of_alloc(cx, llvm_type), machine::llalign_of_min(cx, llvm_type) as u64)
54+
pub fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (u64, u32) {
55+
(machine::llsize_of_alloc(cx, llvm_type), machine::llalign_of_min(cx, llvm_type))
5456
}
5557

56-
pub fn bytes_to_bits(bytes: u64) -> u64 {
57-
bytes * 8
58+
pub fn bytes_to_bits<T>(bytes: T) -> T
59+
where T: ops::Mul<Output=T> + From<u8> {
60+
bytes * 8u8.into()
5861
}
5962

6063
#[inline]

0 commit comments

Comments
 (0)