diff options
| author | ljedrz <ljedrz@gmail.com> | 2018-10-08 16:52:34 +0200 |
|---|---|---|
| committer | ljedrz <ljedrz@gmail.com> | 2018-10-08 16:52:34 +0200 |
| commit | 61f47737b503d6af656ed48eea2a03ba35547b61 (patch) | |
| tree | f1a92afb79603da5dd42a5ba937c07ea54b29262 /src/librustc_codegen_llvm | |
| parent | ef5c00d0ca027f8ef4b41fecd53177e105daa6a8 (diff) | |
| download | rust-61f47737b503d6af656ed48eea2a03ba35547b61.tar.gz rust-61f47737b503d6af656ed48eea2a03ba35547b61.zip | |
codegen_llvm: whitespace & formatting improvements
Diffstat (limited to 'src/librustc_codegen_llvm')
| -rw-r--r-- | src/librustc_codegen_llvm/abi.rs | 16 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/base.rs | 29 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/builder.rs | 16 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/consts.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/context.rs | 14 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/glue.rs | 4 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/intrinsic.rs | 46 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/lib.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/metadata.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/mir/analyze.rs | 6 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/mir/block.rs | 6 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/mono_item.rs | 4 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/type_of.rs | 2 |
13 files changed, 69 insertions, 80 deletions
diff --git a/src/librustc_codegen_llvm/abi.rs b/src/librustc_codegen_llvm/abi.rs index 684f2b35885..1b007a6d814 100644 --- a/src/librustc_codegen_llvm/abi.rs +++ b/src/librustc_codegen_llvm/abi.rs @@ -150,7 +150,7 @@ impl LlvmType for CastTarget { // Create list of fields in the main structure let mut args: Vec<_> = self.prefix.iter().flat_map(|option_kind| option_kind.map( - |kind| Reg { kind: kind, size: self.prefix_chunk }.llvm_type(cx))) + |kind| Reg { kind: kind, size: self.prefix_chunk }.llvm_type(cx))) .chain((0..rest_count).map(|_| rest_ll_unit)) .collect(); @@ -259,8 +259,7 @@ impl ArgTypeExt<'ll, 'tcx> for ArgType<'tcx, Ty<'tcx>> { } pub trait FnTypeExt<'tcx> { - fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>) - -> Self; + fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>) -> Self; fn new(cx: &CodegenCx<'ll, 'tcx>, sig: ty::FnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> Self; @@ -283,8 +282,7 @@ pub trait FnTypeExt<'tcx> { } impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> { - fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>) - -> Self { + fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>) -> Self { let fn_ty = instance.ty(cx.tcx); let sig = ty_fn_sig(cx, fn_ty); let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig); @@ -292,16 +290,16 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> { } fn new(cx: &CodegenCx<'ll, 'tcx>, - sig: ty::FnSig<'tcx>, - extra_args: &[Ty<'tcx>]) -> Self { + sig: ty::FnSig<'tcx>, + extra_args: &[Ty<'tcx>]) -> Self { FnType::new_internal(cx, sig, extra_args, |ty, _| { ArgType::new(cx.layout_of(ty)) }) } fn new_vtable(cx: &CodegenCx<'ll, 'tcx>, - sig: ty::FnSig<'tcx>, - extra_args: &[Ty<'tcx>]) -> Self { + sig: ty::FnSig<'tcx>, + extra_args: &[Ty<'tcx>]) -> Self { FnType::new_internal(cx, sig, extra_args, |ty, arg_idx| { let mut layout = cx.layout_of(ty); // Don't pass the vtable, it's not an argument of the virtual fn. diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 55dc43ec1fb..6acf884214a 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -213,8 +213,8 @@ pub fn unsized_info( vtable_ptr.llvm_type(cx)) } _ => bug!("unsized_info: invalid unsizing {:?} -> {:?}", - source, - target), + source, + target), } } @@ -340,11 +340,11 @@ pub fn cast_shift_expr_rhs( } fn cast_shift_rhs<'ll, F, G>(op: hir::BinOpKind, - lhs: &'ll Value, - rhs: &'ll Value, - trunc: F, - zext: G) - -> &'ll Value + lhs: &'ll Value, + rhs: &'ll Value, + trunc: F, + zext: G) + -> &'ll Value where F: FnOnce(&'ll Value, &'ll Type) -> &'ll Value, G: FnOnce(&'ll Value, &'ll Type) -> &'ll Value { @@ -566,8 +566,8 @@ fn maybe_create_entry_wrapper(cx: &CodegenCx) { if declare::get_defined_value(cx, "main").is_some() { // FIXME: We should be smart and show a better diagnostic here. cx.sess().struct_span_err(sp, "entry symbol `main` defined multiple times") - .help("did you use #[no_mangle] on `fn main`? Use #[start] instead") - .emit(); + .help("did you use #[no_mangle] on `fn main`? Use #[start] instead") + .emit(); cx.sess().abort_if_errors(); bug!(); } @@ -736,9 +736,9 @@ fn determine_cgu_reuse<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - rx: mpsc::Receiver<Box<dyn Any + Send>>) - -> OngoingCodegen { - + rx: mpsc::Receiver<Box<dyn Any + Send>>) + -> OngoingCodegen +{ check_for_rustc_errors_attr(tcx); if let Some(true) = tcx.sess.opts.debugging_opts.thinlto { @@ -803,8 +803,7 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // Run the monomorphization collector and partition the collected items into // codegen units. - let codegen_units = - tcx.collect_and_partition_mono_items(LOCAL_CRATE).1; + let codegen_units = tcx.collect_and_partition_mono_items(LOCAL_CRATE).1; let codegen_units = (*codegen_units).clone(); // Force all codegen_unit queries so they are already either red or green @@ -988,7 +987,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>( if mode_string != "lazy" { let message = format!("Unknown codegen-item collection mode '{}'. \ Falling back to 'lazy' mode.", - mode_string); + mode_string); tcx.sess.warn(&message); } diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 77de88997e4..964bfa15736 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -110,10 +110,10 @@ impl Builder<'a, 'll, 'tcx> { } if self.cx.sess().count_llvm_insns() { *self.cx.stats - .borrow_mut() - .llvm_insns - .entry(category.to_string()) - .or_insert(0) += 1; + .borrow_mut() + .llvm_insns + .entry(category.to_string()) + .or_insert(0) += 1; } } @@ -735,9 +735,9 @@ impl Builder<'a, 'll, 'tcx> { } pub fn inline_asm_call(&self, asm: *const c_char, cons: *const c_char, - inputs: &[&'ll Value], output: &'ll Type, - volatile: bool, alignstack: bool, - dia: AsmDialect) -> Option<&'ll Value> { + inputs: &[&'ll Value], output: &'ll Type, + volatile: bool, alignstack: bool, + dia: AsmDialect) -> Option<&'ll Value> { self.count_insn("inlineasm"); let volatile = if volatile { llvm::True } @@ -1093,7 +1093,7 @@ impl Builder<'a, 'll, 'tcx> { ) -> &'ll Value { unsafe { llvm::LLVMRustBuildAtomicCmpXchg(self.llbuilder, dst, cmp, src, - order, failure_order, weak) + order, failure_order, weak) } } pub fn atomic_rmw( diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index 522de2f15e0..487f3e0759d 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -124,7 +124,7 @@ pub fn get_static(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll Value { assert!(!defined_in_current_codegen_unit, "consts::get_static() should always hit the cache for \ statics defined in the same CGU, but did not for `{:?}`", - def_id); + def_id); let ty = instance.ty(cx.tcx); let sym = cx.tcx.symbol_name(instance).as_str(); diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs index 9547f4a190e..67f7a609c48 100644 --- a/src/librustc_codegen_llvm/context.rs +++ b/src/librustc_codegen_llvm/context.rs @@ -59,8 +59,8 @@ pub struct CodegenCx<'a, 'tcx: 'a> { /// Cache instances of monomorphic and polymorphic items pub instances: RefCell<FxHashMap<Instance<'tcx>, &'a Value>>, /// Cache generated vtables - pub vtables: RefCell<FxHashMap<(Ty<'tcx>, - Option<ty::PolyExistentialTraitRef<'tcx>>), &'a Value>>, + pub vtables: RefCell<FxHashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), + &'a Value>>, /// Cache of constant strings, pub const_cstr_cache: RefCell<FxHashMap<LocalInternedString, &'a Value>>, @@ -213,9 +213,9 @@ pub unsafe fn create_module( impl<'a, 'tcx> CodegenCx<'a, 'tcx> { crate fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, - codegen_unit: Arc<CodegenUnit<'tcx>>, - llvm_module: &'a ::ModuleLlvm) - -> CodegenCx<'a, 'tcx> { + codegen_unit: Arc<CodegenUnit<'tcx>>, + llvm_module: &'a ::ModuleLlvm) + -> CodegenCx<'a, 'tcx> { // An interesting part of Windows which MSVC forces our hand on (and // apparently MinGW didn't) is the usage of `dllimport` and `dllexport` // attributes in LLVM IR as well as native dependencies (in C these @@ -270,8 +270,8 @@ impl<'a, 'tcx> CodegenCx<'a, 'tcx> { let dbg_cx = if tcx.sess.opts.debuginfo != DebugInfo::None { let dctx = debuginfo::CrateDebugContext::new(llmod); debuginfo::metadata::compile_unit_metadata(tcx, - &codegen_unit.name().as_str(), - &dctx); + &codegen_unit.name().as_str(), + &dctx); Some(dctx) } else { None diff --git a/src/librustc_codegen_llvm/glue.rs b/src/librustc_codegen_llvm/glue.rs index ff33cec0437..842bdf3cb49 100644 --- a/src/librustc_codegen_llvm/glue.rs +++ b/src/librustc_codegen_llvm/glue.rs @@ -97,8 +97,8 @@ pub fn size_and_align_of_dst(bx: &Builder<'_, 'll, 'tcx>, t: Ty<'tcx>, info: Opt C_usize(cx, std::cmp::max(sized_align, unsized_align) as u64) } _ => bx.select(bx.icmp(llvm::IntUGT, sized_align, unsized_align), - sized_align, - unsized_align) + sized_align, + unsized_align) }; // Issue #27023: must add any necessary padding to `size` diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 5ec934ebd06..74326f8a08e 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -115,8 +115,8 @@ pub fn codegen_intrinsic_call( let llval = match name { _ if simple.is_some() => { bx.call(simple.unwrap(), - &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), - None) + &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), + None) } "unreachable" => { return; @@ -373,7 +373,6 @@ pub fn codegen_intrinsic_call( return; } } - }, "fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" => { let sty = &arg_tys[0].sty; @@ -822,8 +821,7 @@ fn codegen_msvc_try( let i64p = Type::i64(cx).ptr_to(); let ptr_align = bx.tcx().data_layout.pointer_align; let slot = bx.alloca(i64p, "slot", ptr_align); - bx.invoke(func, &[data], normal.llbb(), catchswitch.llbb(), - None); + bx.invoke(func, &[data], normal.llbb(), catchswitch.llbb(), None); normal.ret(C_i32(cx, 0)); @@ -911,8 +909,7 @@ fn codegen_gnu_try( // being thrown. The second value is a "selector" indicating which of // the landing pad clauses the exception's type had been matched to. // rust_try ignores the selector. - let lpad_ty = Type::struct_(cx, &[Type::i8p(cx), Type::i32(cx)], - false); + let lpad_ty = Type::struct_(cx, &[Type::i8p(cx), Type::i32(cx)], false); let vals = catch.landing_pad(lpad_ty, bx.cx.eh_personality(), 1); catch.add_clause(vals, C_null(Type::i8p(cx))); let ptr = catch.extract_value(vals, 0); @@ -1000,11 +997,11 @@ fn generic_simd_intrinsic( ($msg: tt, $($fmt: tt)*) => { span_invalid_monomorphization_error( bx.sess(), span, - &format!(concat!("invalid monomorphization of `{}` intrinsic: ", - $msg), + &format!(concat!("invalid monomorphization of `{}` intrinsic: ", $msg), name, $($fmt)*)); } } + macro_rules! return_error { ($($fmt: tt)*) => { { @@ -1021,14 +1018,13 @@ fn generic_simd_intrinsic( } }; } + macro_rules! require_simd { ($ty: expr, $position: expr) => { require!($ty.is_simd(), "expected SIMD {} type, found non-SIMD `{}`", $position, $ty) } } - - let tcx = bx.tcx(); let sig = tcx.normalize_erasing_late_bound_regions( ty::ParamEnv::reveal_all(), @@ -1121,8 +1117,8 @@ fn generic_simd_intrinsic( }; return Ok(bx.shuffle_vector(args[0].immediate(), - args[1].immediate(), - C_vector(&indices))) + args[1].immediate(), + C_vector(&indices))) } if name == "simd_insert" { @@ -1130,8 +1126,8 @@ fn generic_simd_intrinsic( "expected inserted type `{}` (element of input `{}`), found `{}`", in_elem, in_ty, arg_tys[2]); return Ok(bx.insert_element(args[0].immediate(), - args[2].immediate(), - args[1].immediate())) + args[2].immediate(), + args[1].immediate())) } if name == "simd_extract" { require!(ret_ty == in_elem, @@ -1150,9 +1146,7 @@ fn generic_simd_intrinsic( ); match m_elem_ty.sty { ty::Int(_) => {}, - _ => { - return_error!("mask element type is `{}`, expected `i_`", m_elem_ty); - } + _ => return_error!("mask element type is `{}`, expected `i_`", m_elem_ty) } // truncate the mask to a vector of i1s let i1 = Type::i1(bx.cx); @@ -1177,8 +1171,7 @@ fn generic_simd_intrinsic( ($msg: tt, $($fmt: tt)*) => { span_invalid_monomorphization_error( bx.sess(), span, - &format!(concat!("invalid monomorphization of `{}` intrinsic: ", - $msg), + &format!(concat!("invalid monomorphization of `{}` intrinsic: ", $msg), name, $($fmt)*)); } } @@ -1312,7 +1305,7 @@ fn generic_simd_intrinsic( } - if name == "simd_gather" { + if name == "simd_gather" { // simd_gather(values: <N x T>, pointers: <N x *_ T>, // mask: <N x i{M}>) -> <N x T> // * N: number of elements in the input vectors @@ -1360,7 +1353,7 @@ fn generic_simd_intrinsic( // to the element type of the first argument let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).sty { ty::RawPtr(p) if p.ty == in_elem => (ptr_count(arg_tys[1].simd_type(tcx)), - non_ptr(arg_tys[1].simd_type(tcx))), + non_ptr(arg_tys[1].simd_type(tcx))), _ => { require!(false, "expected element type `{}` of second argument `{}` \ to be a pointer to the element type `{}` of the first \ @@ -1414,7 +1407,7 @@ fn generic_simd_intrinsic( return Ok(v); } - if name == "simd_scatter" { + if name == "simd_scatter" { // simd_scatter(values: <N x T>, pointers: <N x *mut T>, // mask: <N x i{M}>) -> () // * N: number of elements in the input vectors @@ -1570,7 +1563,6 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, ) } } - }; Ok(bx.$float_reduce(acc, args[0].immediate())) } @@ -1750,9 +1742,9 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, _ => {}, } require!(false, - "unsupported operation on `{}` with element `{}`", - in_ty, - in_elem) + "unsupported operation on `{}` with element `{}`", + in_ty, + in_elem) })* } } diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index 71d739222b6..63a8ab077e5 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -306,7 +306,7 @@ impl ModuleCodegen { }; let bytecode_compressed = if emit_bc_compressed { Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name)) - .with_extension(RLIB_BYTECODE_EXTENSION)) + .with_extension(RLIB_BYTECODE_EXTENSION)) } else { None }; diff --git a/src/librustc_codegen_llvm/metadata.rs b/src/librustc_codegen_llvm/metadata.rs index a4526a53769..7752465d885 100644 --- a/src/librustc_codegen_llvm/metadata.rs +++ b/src/librustc_codegen_llvm/metadata.rs @@ -63,7 +63,7 @@ impl MetadataLoader for LlvmMetadataLoader { let of = ObjectFile::new(mb) .map(|of| OwningRef::new(box of)) .ok_or_else(|| format!("provided path not an object file: '{}'", - filename.display()))?; + filename.display()))?; let buf = of.try_map(|of| search_meta_section(of, target, filename))?; Ok(rustc_erase_owner!(buf)) } diff --git a/src/librustc_codegen_llvm/mir/analyze.rs b/src/librustc_codegen_llvm/mir/analyze.rs index c3e3785a724..a0d6cc46295 100644 --- a/src/librustc_codegen_llvm/mir/analyze.rs +++ b/src/librustc_codegen_llvm/mir/analyze.rs @@ -151,9 +151,9 @@ impl Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'll, 'tcx> { } fn visit_place(&mut self, - place: &mir::Place<'tcx>, - context: PlaceContext<'tcx>, - location: Location) { + place: &mir::Place<'tcx>, + context: PlaceContext<'tcx>, + location: Location) { debug!("visit_place(place={:?}, context={:?})", place, context); let cx = self.fx.cx; diff --git a/src/librustc_codegen_llvm/mir/block.rs b/src/librustc_codegen_llvm/mir/block.rs index db95b46c38e..5be176f75c9 100644 --- a/src/librustc_codegen_llvm/mir/block.rs +++ b/src/librustc_codegen_llvm/mir/block.rs @@ -49,9 +49,9 @@ impl FunctionCx<'a, 'll, 'tcx> { } fn codegen_terminator(&mut self, - mut bx: Builder<'a, 'll, 'tcx>, - bb: mir::BasicBlock, - terminator: &mir::Terminator<'tcx>) + mut bx: Builder<'a, 'll, 'tcx>, + bb: mir::BasicBlock, + terminator: &mir::Terminator<'tcx>) { debug!("codegen_terminator: {:?}", terminator); diff --git a/src/librustc_codegen_llvm/mono_item.rs b/src/librustc_codegen_llvm/mono_item.rs index a8502e92447..dab9b147cc0 100644 --- a/src/librustc_codegen_llvm/mono_item.rs +++ b/src/librustc_codegen_llvm/mono_item.rs @@ -108,8 +108,8 @@ pub trait MonoItemExt<'a, 'tcx>: fmt::Debug + BaseMonoItemExt<'a, 'tcx> { match *self.as_mono_item() { MonoItem::Fn(instance) => { format!("Fn({:?}, {})", - instance.def, - instance.substs.as_ptr() as usize) + instance.def, + instance.substs.as_ptr() as usize) } MonoItem::Static(id) => { format!("Static({:?})", id) diff --git a/src/librustc_codegen_llvm/type_of.rs b/src/librustc_codegen_llvm/type_of.rs index 765708aeafd..2fa784161bd 100644 --- a/src/librustc_codegen_llvm/type_of.rs +++ b/src/librustc_codegen_llvm/type_of.rs @@ -132,7 +132,7 @@ fn struct_llfields<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, debug!("struct_llfields: {}: {:?} offset: {:?} target_offset: {:?} \ effective_field_align: {}", - i, field, offset, target_offset, effective_field_align.abi()); + i, field, offset, target_offset, effective_field_align.abi()); assert!(target_offset >= offset); let padding = target_offset - offset; let padding_align = prev_effective_align.min(effective_field_align); |
