codegen_llvm/misc: whitespace & formatting improvements
This commit is contained in:
parent
b1a137d015
commit
8efd9dd81b
5 changed files with 46 additions and 45 deletions
|
@ -582,12 +582,12 @@ pub fn type_metadata(
|
||||||
}
|
}
|
||||||
ty::Dynamic(..) => {
|
ty::Dynamic(..) => {
|
||||||
MetadataCreationResult::new(
|
MetadataCreationResult::new(
|
||||||
trait_pointer_metadata(cx, t, None, unique_type_id),
|
trait_pointer_metadata(cx, t, None, unique_type_id),
|
||||||
false)
|
false)
|
||||||
}
|
}
|
||||||
ty::Foreign(..) => {
|
ty::Foreign(..) => {
|
||||||
MetadataCreationResult::new(
|
MetadataCreationResult::new(
|
||||||
foreign_type_metadata(cx, t, unique_type_id),
|
foreign_type_metadata(cx, t, unique_type_id),
|
||||||
false)
|
false)
|
||||||
}
|
}
|
||||||
ty::RawPtr(ty::TypeAndMut{ty, ..}) |
|
ty::RawPtr(ty::TypeAndMut{ty, ..}) |
|
||||||
|
@ -646,16 +646,16 @@ pub fn type_metadata(
|
||||||
}
|
}
|
||||||
AdtKind::Union => {
|
AdtKind::Union => {
|
||||||
prepare_union_metadata(cx,
|
prepare_union_metadata(cx,
|
||||||
t,
|
t,
|
||||||
unique_type_id,
|
unique_type_id,
|
||||||
usage_site_span).finalize(cx)
|
usage_site_span).finalize(cx)
|
||||||
}
|
}
|
||||||
AdtKind::Enum => {
|
AdtKind::Enum => {
|
||||||
prepare_enum_metadata(cx,
|
prepare_enum_metadata(cx,
|
||||||
t,
|
t,
|
||||||
def.did,
|
def.did,
|
||||||
unique_type_id,
|
unique_type_id,
|
||||||
usage_site_span).finalize(cx)
|
usage_site_span).finalize(cx)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ty::Tuple(ref elements) => {
|
ty::Tuple(ref elements) => {
|
||||||
|
@ -943,7 +943,7 @@ enum MemberDescriptionFactory<'ll, 'tcx> {
|
||||||
|
|
||||||
impl MemberDescriptionFactory<'ll, 'tcx> {
|
impl MemberDescriptionFactory<'ll, 'tcx> {
|
||||||
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
||||||
-> Vec<MemberDescription<'ll>> {
|
-> Vec<MemberDescription<'ll>> {
|
||||||
match *self {
|
match *self {
|
||||||
StructMDF(ref this) => {
|
StructMDF(ref this) => {
|
||||||
this.create_member_descriptions(cx)
|
this.create_member_descriptions(cx)
|
||||||
|
@ -977,7 +977,7 @@ struct StructMemberDescriptionFactory<'tcx> {
|
||||||
|
|
||||||
impl<'tcx> StructMemberDescriptionFactory<'tcx> {
|
impl<'tcx> StructMemberDescriptionFactory<'tcx> {
|
||||||
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
||||||
-> Vec<MemberDescription<'ll>> {
|
-> Vec<MemberDescription<'ll>> {
|
||||||
let layout = cx.layout_of(self.ty);
|
let layout = cx.layout_of(self.ty);
|
||||||
self.variant.fields.iter().enumerate().map(|(i, f)| {
|
self.variant.fields.iter().enumerate().map(|(i, f)| {
|
||||||
let name = if self.variant.ctor_kind == CtorKind::Fn {
|
let name = if self.variant.ctor_kind == CtorKind::Fn {
|
||||||
|
@ -1047,7 +1047,7 @@ struct TupleMemberDescriptionFactory<'tcx> {
|
||||||
|
|
||||||
impl<'tcx> TupleMemberDescriptionFactory<'tcx> {
|
impl<'tcx> TupleMemberDescriptionFactory<'tcx> {
|
||||||
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
||||||
-> Vec<MemberDescription<'ll>> {
|
-> Vec<MemberDescription<'ll>> {
|
||||||
let layout = cx.layout_of(self.ty);
|
let layout = cx.layout_of(self.ty);
|
||||||
self.component_types.iter().enumerate().map(|(i, &component_type)| {
|
self.component_types.iter().enumerate().map(|(i, &component_type)| {
|
||||||
let (size, align) = cx.size_and_align_of(component_type);
|
let (size, align) = cx.size_and_align_of(component_type);
|
||||||
|
@ -1101,7 +1101,7 @@ struct UnionMemberDescriptionFactory<'tcx> {
|
||||||
|
|
||||||
impl<'tcx> UnionMemberDescriptionFactory<'tcx> {
|
impl<'tcx> UnionMemberDescriptionFactory<'tcx> {
|
||||||
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
||||||
-> Vec<MemberDescription<'ll>> {
|
-> Vec<MemberDescription<'ll>> {
|
||||||
self.variant.fields.iter().enumerate().map(|(i, f)| {
|
self.variant.fields.iter().enumerate().map(|(i, f)| {
|
||||||
let field = self.layout.field(cx, i);
|
let field = self.layout.field(cx, i);
|
||||||
let (size, align) = field.size_and_align();
|
let (size, align) = field.size_and_align();
|
||||||
|
@ -1170,7 +1170,7 @@ struct EnumMemberDescriptionFactory<'ll, 'tcx> {
|
||||||
|
|
||||||
impl EnumMemberDescriptionFactory<'ll, 'tcx> {
|
impl EnumMemberDescriptionFactory<'ll, 'tcx> {
|
||||||
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
|
||||||
-> Vec<MemberDescription<'ll>> {
|
-> Vec<MemberDescription<'ll>> {
|
||||||
let adt = &self.enum_type.ty_adt_def().unwrap();
|
let adt = &self.enum_type.ty_adt_def().unwrap();
|
||||||
match self.layout.variants {
|
match self.layout.variants {
|
||||||
layout::Variants::Single { .. } if adt.variants.is_empty() => vec![],
|
layout::Variants::Single { .. } if adt.variants.is_empty() => vec![],
|
||||||
|
|
|
@ -179,7 +179,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||||
ty::GeneratorWitness(..) |
|
ty::GeneratorWitness(..) |
|
||||||
ty::Param(_) => {
|
ty::Param(_) => {
|
||||||
bug!("debuginfo: Trying to create type name for \
|
bug!("debuginfo: Trying to create type name for \
|
||||||
unexpected type: {:?}", t);
|
unexpected type: {:?}", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,9 +151,9 @@ impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_place(&mut self,
|
fn visit_place(&mut self,
|
||||||
place: &mir::Place<'tcx>,
|
place: &mir::Place<'tcx>,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
debug!("visit_place(place={:?}, context={:?})", place, context);
|
debug!("visit_place(place={:?}, context={:?})", place, context);
|
||||||
let cx = self.fx.cx;
|
let cx = self.fx.cx;
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn codegen_terminator(&mut self,
|
fn codegen_terminator(&mut self,
|
||||||
mut bx: Builder<'a, 'll, 'tcx>,
|
mut bx: Builder<'a, 'll, 'tcx>,
|
||||||
bb: mir::BasicBlock,
|
bb: mir::BasicBlock,
|
||||||
terminator: &mir::Terminator<'tcx>)
|
terminator: &mir::Terminator<'tcx>)
|
||||||
{
|
{
|
||||||
debug!("codegen_terminator: {:?}", terminator);
|
debug!("codegen_terminator: {:?}", terminator);
|
||||||
|
|
||||||
|
@ -125,10 +125,10 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
||||||
this.unreachable_block()
|
this.unreachable_block()
|
||||||
};
|
};
|
||||||
let invokeret = bx.invoke(fn_ptr,
|
let invokeret = bx.invoke(fn_ptr,
|
||||||
&llargs,
|
&llargs,
|
||||||
ret_bx,
|
ret_bx,
|
||||||
llblock(this, cleanup),
|
llblock(this, cleanup),
|
||||||
cleanup_bundle);
|
cleanup_bundle);
|
||||||
fn_ty.apply_attrs_callsite(&bx, invokeret);
|
fn_ty.apply_attrs_callsite(&bx, invokeret);
|
||||||
|
|
||||||
if let Some((ret_dest, target)) = destination {
|
if let Some((ret_dest, target)) = destination {
|
||||||
|
@ -213,7 +213,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
||||||
} else {
|
} else {
|
||||||
let (otherwise, targets) = targets.split_last().unwrap();
|
let (otherwise, targets) = targets.split_last().unwrap();
|
||||||
let switch = bx.switch(discr.immediate(),
|
let switch = bx.switch(discr.immediate(),
|
||||||
llblock(self, *otherwise), values.len());
|
llblock(self, *otherwise),
|
||||||
|
values.len());
|
||||||
let switch_llty = bx.cx.layout_of(switch_ty).immediate_llvm_type(bx.cx);
|
let switch_llty = bx.cx.layout_of(switch_ty).immediate_llvm_type(bx.cx);
|
||||||
for (&value, target) in values.iter().zip(targets) {
|
for (&value, target) in values.iter().zip(targets) {
|
||||||
let llval = C_uint_big(switch_llty, value);
|
let llval = C_uint_big(switch_llty, value);
|
||||||
|
@ -387,8 +388,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
||||||
let msg_str = Symbol::intern(str).as_str();
|
let msg_str = Symbol::intern(str).as_str();
|
||||||
let msg_str = C_str_slice(bx.cx, msg_str);
|
let msg_str = C_str_slice(bx.cx, msg_str);
|
||||||
let msg_file_line_col = C_struct(bx.cx,
|
let msg_file_line_col = C_struct(bx.cx,
|
||||||
&[msg_str, filename, line, col],
|
&[msg_str, filename, line, col],
|
||||||
false);
|
false);
|
||||||
let msg_file_line_col = consts::addr_of(bx.cx,
|
let msg_file_line_col = consts::addr_of(bx.cx,
|
||||||
msg_file_line_col,
|
msg_file_line_col,
|
||||||
align,
|
align,
|
||||||
|
@ -509,8 +510,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
||||||
let msg_str = Symbol::intern(&str).as_str();
|
let msg_str = Symbol::intern(&str).as_str();
|
||||||
let msg_str = C_str_slice(bx.cx, msg_str);
|
let msg_str = C_str_slice(bx.cx, msg_str);
|
||||||
let msg_file_line_col = C_struct(bx.cx,
|
let msg_file_line_col = C_struct(bx.cx,
|
||||||
&[msg_str, filename, line, col],
|
&[msg_str, filename, line, col],
|
||||||
false);
|
false);
|
||||||
let msg_file_line_col = consts::addr_of(bx.cx,
|
let msg_file_line_col = consts::addr_of(bx.cx,
|
||||||
msg_file_line_col,
|
msg_file_line_col,
|
||||||
align,
|
align,
|
||||||
|
@ -619,7 +620,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
||||||
|
|
||||||
let callee_ty = instance.as_ref().unwrap().ty(bx.cx.tcx);
|
let callee_ty = instance.as_ref().unwrap().ty(bx.cx.tcx);
|
||||||
codegen_intrinsic_call(&bx, callee_ty, &fn_ty, &args, dest,
|
codegen_intrinsic_call(&bx, callee_ty, &fn_ty, &args, dest,
|
||||||
terminator.source_info.span);
|
terminator.source_info.span);
|
||||||
|
|
||||||
if let ReturnDest::IndirectOperand(dst, _) = ret_dest {
|
if let ReturnDest::IndirectOperand(dst, _) = ret_dest {
|
||||||
self.store_return(&bx, ret_dest, &fn_ty.ret, dst.llval);
|
self.store_return(&bx, ret_dest, &fn_ty.ret, dst.llval);
|
||||||
|
@ -756,7 +757,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
||||||
// Have to load the argument, maybe while casting it.
|
// Have to load the argument, maybe while casting it.
|
||||||
if let PassMode::Cast(ty) = arg.mode {
|
if let PassMode::Cast(ty) = arg.mode {
|
||||||
llval = bx.load(bx.pointercast(llval, ty.llvm_type(bx.cx).ptr_to()),
|
llval = bx.load(bx.pointercast(llval, ty.llvm_type(bx.cx).ptr_to()),
|
||||||
align.min(arg.layout.align));
|
align.min(arg.layout.align));
|
||||||
} else {
|
} else {
|
||||||
// We can't use `PlaceRef::load` here because the argument
|
// We can't use `PlaceRef::load` here because the argument
|
||||||
// may have a type we don't treat as immediate, but the ABI
|
// may have a type we don't treat as immediate, but the ABI
|
||||||
|
@ -778,10 +779,10 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn codegen_arguments_untupled(&mut self,
|
fn codegen_arguments_untupled(&mut self,
|
||||||
bx: &Builder<'a, 'll, 'tcx>,
|
bx: &Builder<'a, 'll, 'tcx>,
|
||||||
operand: &mir::Operand<'tcx>,
|
operand: &mir::Operand<'tcx>,
|
||||||
llargs: &mut Vec<&'ll Value>,
|
llargs: &mut Vec<&'ll Value>,
|
||||||
args: &[ArgType<'tcx, Ty<'tcx>>]) {
|
args: &[ArgType<'tcx, Ty<'tcx>>]) {
|
||||||
let tuple = self.codegen_operand(bx, operand);
|
let tuple = self.codegen_operand(bx, operand);
|
||||||
|
|
||||||
// Handle both by-ref and immediate tuples.
|
// Handle both by-ref and immediate tuples.
|
||||||
|
@ -933,8 +934,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn codegen_transmute(&mut self, bx: &Builder<'a, 'll, 'tcx>,
|
fn codegen_transmute(&mut self, bx: &Builder<'a, 'll, 'tcx>,
|
||||||
src: &mir::Operand<'tcx>,
|
src: &mir::Operand<'tcx>,
|
||||||
dst: &mir::Place<'tcx>) {
|
dst: &mir::Place<'tcx>) {
|
||||||
if let mir::Place::Local(index) = *dst {
|
if let mir::Place::Local(index) = *dst {
|
||||||
match self.locals[index] {
|
match self.locals[index] {
|
||||||
LocalRef::Place(place) => self.codegen_transmute_into(bx, src, place),
|
LocalRef::Place(place) => self.codegen_transmute_into(bx, src, place),
|
||||||
|
@ -961,8 +962,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn codegen_transmute_into(&mut self, bx: &Builder<'a, 'll, 'tcx>,
|
fn codegen_transmute_into(&mut self, bx: &Builder<'a, 'll, 'tcx>,
|
||||||
src: &mir::Operand<'tcx>,
|
src: &mir::Operand<'tcx>,
|
||||||
dst: PlaceRef<'ll, 'tcx>) {
|
dst: PlaceRef<'ll, 'tcx>) {
|
||||||
let src = self.codegen_operand(bx, src);
|
let src = self.codegen_operand(bx, src);
|
||||||
let llty = src.layout.llvm_type(bx.cx);
|
let llty = src.layout.llvm_type(bx.cx);
|
||||||
let cast_ptr = bx.pointercast(dst.llval, llty.ptr_to());
|
let cast_ptr = bx.pointercast(dst.llval, llty.ptr_to());
|
||||||
|
|
|
@ -162,16 +162,16 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
||||||
// corresponding to span's containing source scope. If so, we need to create a DIScope
|
// corresponding to span's containing source scope. If so, we need to create a DIScope
|
||||||
// "extension" into that file.
|
// "extension" into that file.
|
||||||
fn scope_metadata_for_loc(&self, scope_id: mir::SourceScope, pos: BytePos)
|
fn scope_metadata_for_loc(&self, scope_id: mir::SourceScope, pos: BytePos)
|
||||||
-> Option<&'ll DIScope> {
|
-> Option<&'ll DIScope> {
|
||||||
let scope_metadata = self.scopes[scope_id].scope_metadata;
|
let scope_metadata = self.scopes[scope_id].scope_metadata;
|
||||||
if pos < self.scopes[scope_id].file_start_pos ||
|
if pos < self.scopes[scope_id].file_start_pos ||
|
||||||
pos >= self.scopes[scope_id].file_end_pos {
|
pos >= self.scopes[scope_id].file_end_pos {
|
||||||
let cm = self.cx.sess().source_map();
|
let cm = self.cx.sess().source_map();
|
||||||
let defining_crate = self.debug_context.get_ref(DUMMY_SP).defining_crate;
|
let defining_crate = self.debug_context.get_ref(DUMMY_SP).defining_crate;
|
||||||
Some(debuginfo::extend_scope_to_file(self.cx,
|
Some(debuginfo::extend_scope_to_file(self.cx,
|
||||||
scope_metadata.unwrap(),
|
scope_metadata.unwrap(),
|
||||||
&cm.lookup_char_pos(pos).file,
|
&cm.lookup_char_pos(pos).file,
|
||||||
defining_crate))
|
defining_crate))
|
||||||
} else {
|
} else {
|
||||||
scope_metadata
|
scope_metadata
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue