Skip to content

Commit

Permalink
Use u32 for alignments instead of u64
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan McKay committed Feb 5, 2017
1 parent b4e6f70 commit c7bea76
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
18 changes: 9 additions & 9 deletions src/librustc_trans/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ fn fixed_vec_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
llvm::LLVMRustDIBuilderCreateArrayType(
DIB(cx),
bytes_to_bits(array_size_in_bytes),
bytes_to_bits(element_type_align) as u32,
bytes_to_bits(element_type_align),
element_type_metadata,
subscripts)
};
Expand Down Expand Up @@ -730,7 +730,7 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
DIB(cx),
name.as_ptr(),
bytes_to_bits(size),
bytes_to_bits(align) as u32,
bytes_to_bits(align),
encoding)
};

Expand All @@ -750,7 +750,7 @@ fn pointer_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
DIB(cx),
pointee_type_metadata,
bytes_to_bits(pointer_size),
bytes_to_bits(pointer_align) as u32,
bytes_to_bits(pointer_align),
name.as_ptr())
};
return ptr_metadata;
Expand Down Expand Up @@ -1504,7 +1504,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
file_metadata,
UNKNOWN_LINE_NUMBER,
bytes_to_bits(discriminant_size),
bytes_to_bits(discriminant_align) as u32,
bytes_to_bits(discriminant_align),
create_DIArray(DIB(cx), &enumerators_metadata),
discriminant_base_type_metadata)
};
Expand Down Expand Up @@ -1546,7 +1546,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
file_metadata,
UNKNOWN_LINE_NUMBER,
bytes_to_bits(enum_type_size),
bytes_to_bits(enum_type_align) as u32,
bytes_to_bits(enum_type_align),
DIFlags::FlagZero,
ptr::null_mut(),
0, // RuntimeLang
Expand Down Expand Up @@ -1648,7 +1648,7 @@ fn set_members_of_composite_type(cx: &CrateContext,
unknown_file_metadata(cx),
UNKNOWN_LINE_NUMBER,
bytes_to_bits(member_size),
bytes_to_bits(member_align) as u32,
bytes_to_bits(member_align),
bytes_to_bits(member_offset),
member_description.flags,
member_description.type_metadata)
Expand Down Expand Up @@ -1691,7 +1691,7 @@ fn create_struct_stub(cx: &CrateContext,
unknown_file_metadata(cx),
UNKNOWN_LINE_NUMBER,
bytes_to_bits(struct_size),
bytes_to_bits(struct_align) as u32,
bytes_to_bits(struct_align),
DIFlags::FlagZero,
ptr::null_mut(),
empty_array,
Expand Down Expand Up @@ -1728,7 +1728,7 @@ fn create_union_stub(cx: &CrateContext,
unknown_file_metadata(cx),
UNKNOWN_LINE_NUMBER,
bytes_to_bits(union_size),
bytes_to_bits(union_align) as u32,
bytes_to_bits(union_align),
DIFlags::FlagZero,
empty_array,
0, // RuntimeLang
Expand Down Expand Up @@ -1783,7 +1783,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
is_local_to_unit,
global,
ptr::null_mut(),
global_align as u32,
global_align,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ pub fn declare_local<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
cx.sess().opts.optimize != config::OptLevel::No,
DIFlags::FlagZero,
argument_index,
align as u32,
align,
)
};
source_loc::set_debug_location(bcx,
Expand Down
11 changes: 7 additions & 4 deletions src/librustc_trans/debuginfo/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use type_::Type;
use syntax_pos::{self, Span};
use syntax::ast;

use std::ops;

pub fn is_node_local_to_unit(cx: &CrateContext, node_id: ast::NodeId) -> bool
{
// The is_local_to_unit flag indicates whether a function is local to the
Expand All @@ -49,12 +51,13 @@ pub fn span_start(cx: &CrateContext, span: Span) -> syntax_pos::Loc {
cx.sess().codemap().lookup_char_pos(span.lo)
}

pub fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (u64, u64) {
(machine::llsize_of_alloc(cx, llvm_type), machine::llalign_of_min(cx, llvm_type) as u64)
pub fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (u64, u32) {
(machine::llsize_of_alloc(cx, llvm_type), machine::llalign_of_min(cx, llvm_type))
}

pub fn bytes_to_bits(bytes: u64) -> u64 {
bytes * 8
pub fn bytes_to_bits<T>(bytes: T) -> T
where T: ops::Mul<Output=T> + From<u8> {
bytes * 8u8.into()
}

#[inline]
Expand Down

0 comments on commit c7bea76

Please sign in to comment.