]> git.lizzy.rs Git - rust.git/commitdiff
Use u32 for alignments instead of u64
authorDylan McKay <dylanmckay34@gmail.com>
Sun, 5 Feb 2017 07:19:27 +0000 (20:19 +1300)
committerDylan McKay <dylanmckay34@gmail.com>
Sun, 5 Feb 2017 07:19:27 +0000 (20:19 +1300)
src/librustc_trans/debuginfo/metadata.rs
src/librustc_trans/debuginfo/mod.rs
src/librustc_trans/debuginfo/utils.rs

index 69a2e67366c13529ab71fc9b7384a08dfb9a0c3e..29d04785d6fe106d4bf03a948147c6264ba3647f 100644 (file)
@@ -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)
     };
@@ -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)
     };
 
@@ -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;
@@ -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)
                 };
@@ -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
@@ -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)
@@ -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,
@@ -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
@@ -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,
         );
     }
 }
index 6765cf03776392dd1137e64473e59ea24bae83ea..6a8fc904366dc1826f743f7606fc2d49a81e613c 100644 (file)
@@ -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,
index 8d634c0e292ad7f35e5cfab404c75c89c88ecfc1..15a1c990aadc6aa674f83abde74b3cd8da235673 100644 (file)
@@ -24,6 +24,8 @@
 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
@@ -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]