]> git.lizzy.rs Git - rust.git/commitdiff
Improve/add comments
authorHans Kratz <hans@appfour.com>
Wed, 21 Jul 2021 10:41:27 +0000 (12:41 +0200)
committerHans Kratz <hans@appfour.com>
Wed, 4 Aug 2021 21:36:13 +0000 (23:36 +0200)
compiler/rustc_codegen_llvm/src/context.rs
compiler/rustc_codegen_llvm/src/type_of.rs

index 52de4bcd7379c987f569a13baad52d9d818a4c5e..b088b6e730bdcb832884e3525d0b88c2c76e45bc 100644 (file)
@@ -80,8 +80,7 @@ pub struct CodegenCx<'ll, 'tcx> {
     pub isize_ty: &'ll Type,
 
     /// Cache for the mapping from source index to llvm index for struct fields,
-    /// necessary because the mapping depends on padding and thus depens on
-    /// TyAndLayout.
+    /// only present if synthetic fields are inserted for padding.
     pub field_projection_cache: RefCell<FxHashMap<TyAndLayout<'tcx>, Vec<u32>>>,
 
     pub coverage_cx: Option<coverageinfo::CrateCoverageContext<'ll, 'tcx>>,
index da2927566730f11ea0b27b1a3259c2c8781be20d..79bf51929e9db76dc4f000abe36e8deda21f0336 100644 (file)
@@ -363,6 +363,8 @@ fn llvm_field_index<'a>(&self, cx: &CodegenCx<'a, 'tcx>, index: usize) -> u64 {
 
             FieldsShape::Array { .. } => index as u64,
 
+            // Look up llvm field index in projection cache if present. If no projection cache
+            // is present no padding is used and the llvm field index matches the memory index.
             FieldsShape::Arbitrary { .. } => match cx.field_projection_cache.borrow().get(self) {
                 Some(projection) => projection[index] as u64,
                 None => self.fields.memory_index(index) as u64,