@@ -5,7 +5,7 @@ use std::marker::PhantomData;
55use std:: ops:: Deref ;
66use std:: str;
77
8- use rustc_abi:: { HasDataLayout , TargetDataLayout , VariantIdx } ;
8+ use rustc_abi:: { HasDataLayout , Size , TargetDataLayout , VariantIdx } ;
99use rustc_codegen_ssa:: back:: versioned_llvm_target;
1010use rustc_codegen_ssa:: base:: { wants_msvc_seh, wants_wasm_eh} ;
1111use rustc_codegen_ssa:: common:: TypeKind ;
@@ -47,6 +47,7 @@ use crate::{attributes, coverageinfo, debuginfo, llvm, llvm_util};
4747pub ( crate ) struct SCx < ' ll > {
4848 pub llmod : & ' ll llvm:: Module ,
4949 pub llcx : & ' ll llvm:: Context ,
50+ pub isize_ty : & ' ll Type ,
5051}
5152
5253impl < ' ll > Borrow < SCx < ' ll > > for FullCx < ' ll , ' _ > {
@@ -120,8 +121,6 @@ pub(crate) struct FullCx<'ll, 'tcx> {
120121 /// Mapping of scalar types to llvm types.
121122 pub scalar_lltypes : RefCell < FxHashMap < Ty < ' tcx > , & ' ll Type > > ,
122123
123- pub isize_ty : & ' ll Type ,
124-
125124 /// Extra per-CGU codegen state needed when coverage instrumentation is enabled.
126125 pub coverage_cx : Option < coverageinfo:: CguCoverageContext < ' ll , ' tcx > > ,
127126 pub dbg_cx : Option < debuginfo:: CodegenUnitDebugContext < ' ll , ' tcx > > ,
@@ -595,12 +594,10 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
595594 None
596595 } ;
597596
598- let isize_ty = Type :: ix_llcx ( llcx, tcx. data_layout . pointer_size . bits ( ) ) ;
599-
600597 GenericCx (
601598 FullCx {
602599 tcx,
603- scx : SimpleCx :: new ( llmod, llcx) ,
600+ scx : SimpleCx :: new ( llmod, llcx, tcx . data_layout . pointer_size ) ,
604601 use_dll_storage_attrs,
605602 tls_model,
606603 codegen_unit,
@@ -613,7 +610,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
613610 compiler_used_statics : RefCell :: new ( Vec :: new ( ) ) ,
614611 type_lowering : Default :: default ( ) ,
615612 scalar_lltypes : Default :: default ( ) ,
616- isize_ty,
617613 coverage_cx,
618614 dbg_cx,
619615 eh_personality : Cell :: new ( None ) ,
@@ -649,8 +645,13 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
649645}
650646
651647impl < ' ll > SimpleCx < ' ll > {
652- pub ( crate ) fn new ( llmod : & ' ll llvm:: Module , llcx : & ' ll llvm:: Context ) -> Self {
653- Self ( SCx { llmod, llcx } , PhantomData )
648+ pub ( crate ) fn new (
649+ llmod : & ' ll llvm:: Module ,
650+ llcx : & ' ll llvm:: Context ,
651+ pointer_size : Size ,
652+ ) -> Self {
653+ let isize_ty = llvm:: Type :: ix_llcx ( llcx, pointer_size. bits ( ) ) ;
654+ Self ( SCx { llmod, llcx, isize_ty } , PhantomData )
654655 }
655656
656657 pub ( crate ) fn val_ty ( & self , v : & ' ll Value ) -> & ' ll Type {
0 commit comments