Skip to content

Commit 50be80b

Browse files
committed
Improve/add comments
1 parent e899082 commit 50be80b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ pub struct CodegenCx<'ll, 'tcx> {
8080
pub isize_ty: &'ll Type,
8181

8282
/// Cache for the mapping from source index to llvm index for struct fields,
83-
/// necessary because the mapping depends on padding and thus depens on
84-
/// TyAndLayout.
83+
/// only present if synthetic fields are inserted for padding.
8584
pub field_projection_cache: RefCell<FxHashMap<TyAndLayout<'tcx>, Vec<u32>>>,
8685

8786
pub coverage_cx: Option<coverageinfo::CrateCoverageContext<'ll, 'tcx>>,

compiler/rustc_codegen_llvm/src/type_of.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
363363

364364
FieldsShape::Array { .. } => index as u64,
365365

366+
// Look up llvm field index in projection cache if present. If no projection cache
367+
// is present no padding is used and the llvm field index matches the memory index.
366368
FieldsShape::Arbitrary { .. } => match cx.field_projection_cache.borrow().get(self) {
367369
Some(projection) => projection[index] as u64,
368370
None => self.fields.memory_index(index) as u64,

0 commit comments

Comments
 (0)