about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_codegen_llvm/src/context.rs3
-rw-r--r--compiler/rustc_codegen_llvm/src/type_of.rs2
2 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs
index 52de4bcd737..b088b6e730b 100644
--- a/compiler/rustc_codegen_llvm/src/context.rs
+++ b/compiler/rustc_codegen_llvm/src/context.rs
@@ -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>>,
diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs
index da292756673..79bf51929e9 100644
--- a/compiler/rustc_codegen_llvm/src/type_of.rs
+++ b/compiler/rustc_codegen_llvm/src/type_of.rs
@@ -363,6 +363,8 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
 
             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,