Skip to content
Permalink
Browse files

minor refactor

  • Loading branch information...
Dante-Broggi committed Aug 27, 2019
1 parent e585cf5 commit 6392f3ac6314008cade2d1c324b4416883f341ad
Showing with 12 additions and 18 deletions.
  1. +10 −16 src/librustc_codegen_llvm/debuginfo/metadata.rs
  2. +2 −2 src/librustc_codegen_ssa/mir/place.rs
@@ -655,12 +655,11 @@ pub fn type_metadata(
// type is going to see *somthing* weird - the only
// question is what exactly it will see
let mem_pos = cx.size_and_align_of(t);
let (size, align) = (mem_pos.size, mem_pos.align);
llvm::LLVMRustDIBuilderCreateBasicType(
DIB(cx),
SmallCStr::new("<recur_type>").as_ptr(),
size.bits(),
align.bits() as u32,
mem_pos.size.bits(),
mem_pos.align.bits() as u32,
DW_ATE_unsigned)
}
};
@@ -853,14 +852,13 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
};

let mem_pos = cx.size_and_align_of(t);
let (size, align) = (mem_pos.size, mem_pos.align);
let name = SmallCStr::new(name);
let ty_metadata = unsafe {
llvm::LLVMRustDIBuilderCreateBasicType(
DIB(cx),
name.as_ptr(),
size.bits(),
align.bits() as u32,
mem_pos.size.bits(),
mem_pos.align.bits() as u32,
encoding)
};

@@ -884,15 +882,14 @@ fn pointer_type_metadata(
pointee_type_metadata: &'ll DIType,
) -> &'ll DIType {
let pointer_mem_pos = cx.size_and_align_of(pointer_type);
let (pointer_size, pointer_align) = (pointer_mem_pos.size, pointer_mem_pos.align);
let name = compute_debuginfo_type_name(cx.tcx, pointer_type, false);
let name = SmallCStr::new(&name);
unsafe {
llvm::LLVMRustDIBuilderCreatePointerType(
DIB(cx),
pointee_type_metadata,
pointer_size.bits(),
pointer_align.bits() as u32,
pointer_mem_pos.size.bits(),
pointer_mem_pos.align.bits() as u32,
name.as_ptr())
}
}
@@ -1923,8 +1920,6 @@ fn prepare_enum_metadata(
} => {
let discr_type = discr.value.to_ty(cx.tcx);
let mem_pos = cx.size_and_align_of(discr_type);
let (size, align) = (mem_pos.size, mem_pos.align);


let discr_metadata = basic_type_metadata(cx, discr_type);
unsafe {
@@ -1934,8 +1929,8 @@ fn prepare_enum_metadata(
discriminator_name,
file_metadata,
UNKNOWN_LINE_NUMBER,
size.bits(),
align.bits() as u32,
mem_pos.size.bits(),
mem_pos.align.bits() as u32,
layout.fields.offset(discr_index).bits(),
DIFlags::FlagArtificial,
discr_metadata))
@@ -2139,7 +2134,6 @@ fn create_struct_stub(
containing_scope: Option<&'ll DIScope>,
) -> &'ll DICompositeType {
let struct_mem_pos = cx.size_and_align_of(struct_type);
let (struct_size, struct_align) = (struct_mem_pos.size, struct_mem_pos.align);

let name = SmallCStr::new(struct_type_name);
let unique_type_id = SmallCStr::new(
@@ -2157,8 +2151,8 @@ fn create_struct_stub(
name.as_ptr(),
unknown_file_metadata(cx),
UNKNOWN_LINE_NUMBER,
struct_size.bits(),
struct_align.bits() as u32,
struct_mem_pos.size.bits(),
struct_mem_pos.align.bits() as u32,
DIFlags::FlagZero,
None,
empty_array,
@@ -399,8 +399,8 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
// as this will yield the lowest alignment.
let layout = self.layout.field(bx, 0);
let offset = if bx.is_const_integral(llindex) {
layout.pref_pos.size.checked_mul(bx.const_to_uint(llindex), bx)
.unwrap_or(layout.pref_pos.size)
layout.pref_pos.checked_mul(bx.const_to_uint(llindex), bx)
.unwrap_or(layout.pref_pos).size
} else {
layout.pref_pos.size
};

0 comments on commit 6392f3a

Please sign in to comment.
You can’t perform that action at this time.