diff options
| author | Alexander Regueiro <alexreg@me.com> | 2019-02-28 22:43:53 +0000 |
|---|---|---|
| committer | Alexander Regueiro <alexreg@me.com> | 2019-06-05 21:09:26 +0100 |
| commit | 35585c499f1466037b3788598756e1eb0009f51f (patch) | |
| tree | 564b45c1826f5f8746b7ce8a657d1642b682beb5 /src/librustc_codegen_ssa | |
| parent | 47f4975cd751a03c941431b35cd7a6cba6201730 (diff) | |
Aggregation of drive-by cosmetic changes.
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/back/link.rs | 8 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/block.rs | 22 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/place.rs | 45 |
3 files changed, 38 insertions, 37 deletions
diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index c1ec2071789..0ba5451bd72 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -1127,10 +1127,10 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker, // For this reason, we have organized the arguments we pass to the linker as // such: // - // 1. The local object that LLVM just generated - // 2. Local native libraries - // 3. Upstream rust libraries - // 4. Upstream native libraries + // 1. The local object that LLVM just generated + // 2. Local native libraries + // 3. Upstream rust libraries + // 4. Upstream native libraries // // The rationale behind this ordering is that those items lower down in the // list can't depend on items higher up in the list. For example nothing can diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 4c9313a3309..7e5ee25d8ef 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -967,7 +967,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx.range_metadata(llval, 0..2); } } - // We store bools as i8 so we need to truncate to i1. + // We store bools as `i8` so we need to truncate to `i1`. llval = base::to_immediate(bx, llval, arg.layout); } } @@ -1097,7 +1097,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { fn_ret: &ArgType<'tcx, Ty<'tcx>>, llargs: &mut Vec<Bx::Value>, is_intrinsic: bool ) -> ReturnDest<'tcx, Bx::Value> { - // If the return is ignored, we can just return a do-nothing ReturnDest + // If the return is ignored, we can just return a do-nothing `ReturnDest`. if fn_ret.is_ignore() { return ReturnDest::Nothing; } @@ -1106,8 +1106,8 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { LocalRef::Place(dest) => dest, LocalRef::UnsizedPlace(_) => bug!("return type must be sized"), LocalRef::Operand(None) => { - // Handle temporary places, specifically Operand ones, as - // they don't have allocas + // Handle temporary places, specifically `Operand` ones, as + // they don't have `alloca`s. return if fn_ret.is_indirect() { // Odd, but possible, case, we have an operand temporary, // but the calling convention has an indirect return. @@ -1117,8 +1117,8 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ReturnDest::IndirectOperand(tmp, index) } else if is_intrinsic { // Currently, intrinsics always need a location to store - // the result. so we create a temporary alloca for the - // result + // the result, so we create a temporary `alloca` for the + // result. let tmp = PlaceRef::alloca(bx, fn_ret.layout, "tmp_ret"); tmp.storage_live(bx); ReturnDest::IndirectOperand(tmp, index) @@ -1137,7 +1137,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if dest.align < dest.layout.align.abi { // Currently, MIR code generation does not create calls // that store directly to fields of packed structs (in - // fact, the calls it creates write only to temps), + // fact, the calls it creates write only to temps). // // If someone changes that, please update this code path // to create a temporary. @@ -1232,12 +1232,12 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } enum ReturnDest<'tcx, V> { - // Do nothing, the return value is indirect or ignored + // Do nothing; the return value is indirect or ignored. Nothing, - // Store the return value to the pointer + // Store the return value to the pointer. Store(PlaceRef<'tcx, V>), - // Stores an indirect return value to an operand local place + // Store an indirect return value to an operand local place. IndirectOperand(PlaceRef<'tcx, V>, mir::Local), - // Stores a direct return value to an operand local place + // Store a direct return value to an operand local place. DirectOperand(mir::Local) } diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index cd32d6f484d..27311d0a8fb 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -120,7 +120,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { bx.struct_gep(self.llval, bx.cx().backend_field_index(self.layout, ix)) }; PlaceRef { - // HACK(eddyb) have to bitcast pointers until LLVM removes pointee types. + // HACK(eddyb): have to bitcast pointers until LLVM removes pointee types. llval: bx.pointercast(llval, bx.cx().type_ptr_to(bx.cx().backend_type(field))), llextra: if bx.cx().type_has_metadata(field.ty) { self.llextra @@ -134,7 +134,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { // Simple cases, which don't need DST adjustment: // * no metadata available - just log the case - // * known alignment - sized types, [T], str or a foreign type + // * known alignment - sized types, `[T]`, `str` or a foreign type // * packed struct - there is no alignment padding match field.ty.sty { _ if self.llextra.is_none() => { @@ -156,18 +156,19 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { } // We need to get the pointer manually now. - // We do this by casting to a *i8, then offsetting it by the appropriate amount. + // We do this by casting to a `*i8`, then offsetting it by the appropriate amount. // We do this instead of, say, simply adjusting the pointer from the result of a GEP // because the field may have an arbitrary alignment in the LLVM representation // anyway. // // To demonstrate: - // struct Foo<T: ?Sized> { - // x: u16, - // y: T - // } // - // The type Foo<Foo<Trait>> is represented in LLVM as { u16, { u16, u8 }}, meaning that + // struct Foo<T: ?Sized> { + // x: u16, + // y: T + // } + // + // The type `Foo<Foo<Trait>>` is represented in LLVM as `{ u16, { u16, u8 }}`, meaning that // the `y` field has 16-bit alignment. let meta = self.llextra; @@ -180,9 +181,9 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { // Bump the unaligned offset up to the appropriate alignment using the // following expression: // - // (unaligned offset + (align - 1)) & -align + // (unaligned offset + (align - 1)) & -align - // Calculate offset + // Calculate offset. let align_sub_1 = bx.sub(unsized_align, bx.cx().const_usize(1u64)); let and_lhs = bx.add(unaligned_offset, align_sub_1); let and_rhs = bx.neg(unsized_align); @@ -190,11 +191,11 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { debug!("struct_field_ptr: DST field offset: {:?}", offset); - // Cast and adjust pointer + // Cast and adjust pointer. let byte_ptr = bx.pointercast(self.llval, bx.cx().type_i8p()); let byte_ptr = bx.gep(byte_ptr, &[offset]); - // Finally, cast back to the type expected + // Finally, cast back to the type expected. let ll_fty = bx.cx().backend_type(field); debug!("struct_field_ptr: Field type is {:?}", ll_fty); @@ -235,7 +236,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { // We use `i1` for bytes that are always `0` or `1`, // e.g., `#[repr(i8)] enum E { A, B }`, but we can't // let LLVM interpret the `i1` as signed, because - // then `i1 1` (i.e., E::B) is effectively `i8 -1`. + // then `i1 1` (i.e., `E::B`) is effectively `i8 -1`. layout::Int(_, signed) => !discr_scalar.is_bool() && signed, _ => false }; @@ -248,9 +249,9 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { } => { let niche_llty = bx.cx().immediate_backend_type(discr.layout); if niche_variants.start() == niche_variants.end() { - // FIXME(eddyb) Check the actual primitive type here. + // FIXME(eddyb): check the actual primitive type here. let niche_llval = if niche_start == 0 { - // HACK(eddyb) Using `c_null` as it works on all types. + // HACK(eddyb): using `c_null` as it works on all types. bx.cx().const_null(niche_llty) } else { bx.cx().const_uint_big(niche_llty, niche_start) @@ -314,7 +315,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { if variant_index != dataful_variant { if bx.cx().sess().target.target.arch == "arm" || bx.cx().sess().target.target.arch == "aarch64" { - // Issue #34427: As workaround for LLVM bug on ARM, + // FIXME(#34427): as workaround for LLVM bug on ARM, // use memset of 0 before assigning niche value. let fill_byte = bx.cx().const_u8(0); let size = bx.cx().const_usize(self.layout.size.bytes()); @@ -326,9 +327,9 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { let niche_value = variant_index.as_u32() - niche_variants.start().as_u32(); let niche_value = (niche_value as u128) .wrapping_add(niche_start); - // FIXME(eddyb) Check the actual primitive type here. + // FIXME(eddyb): check the actual primitive type here. let niche_llval = if niche_value == 0 { - // HACK(eddyb) Using `c_null` as it works on all types. + // HACK(eddyb): using `c_null` as it works on all types. bx.cx().const_null(niche_llty) } else { bx.cx().const_uint_big(niche_llty, niche_value) @@ -429,10 +430,10 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { _ => bug!("promoteds should have an allocation: {:?}", val), }, Err(_) => { - // this is unreachable as long as runtime + // This is unreachable as long as runtime // and compile-time agree on values - // With floats that won't always be true - // so we generate an abort + // With floats that won't always be true, + // so we generate an abort. bx.abort(); let llval = bx.cx().const_undef( bx.cx().type_ptr_to(bx.cx().backend_type(layout)) @@ -502,7 +503,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } // Cast the place pointer type to the new - // array or slice type (*[%_; new_len]). + // array or slice type (`*[%_; new_len]`). subslice.llval = bx.pointercast(subslice.llval, bx.cx().type_ptr_to(bx.cx().backend_type(subslice.layout))); |
