diff options
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs | 18 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/debuginfo/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/intrinsic.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm_util.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/type_of.rs | 4 |
6 files changed, 29 insertions, 26 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs index b2879ef4aea..98ba38356a4 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs @@ -90,7 +90,7 @@ impl<'ll, 'tcx> CoverageInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { /// call. Since the function is never called, all other `CodeRegion`s can be /// added as `unreachable_region`s. fn define_unused_fn(&self, def_id: DefId) { - let instance = declare_unused_fn(self, &def_id); + let instance = declare_unused_fn(self, def_id); codegen_unused_fn_and_counter(self, instance); add_unused_function_coverage(self, instance, def_id); } @@ -184,12 +184,12 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> { } } -fn declare_unused_fn<'tcx>(cx: &CodegenCx<'_, 'tcx>, def_id: &DefId) -> Instance<'tcx> { +fn declare_unused_fn<'tcx>(cx: &CodegenCx<'_, 'tcx>, def_id: DefId) -> Instance<'tcx> { let tcx = cx.tcx; let instance = Instance::new( - *def_id, - InternalSubsts::for_item(tcx, *def_id, |param, _| { + def_id, + InternalSubsts::for_item(tcx, def_id, |param, _| { if let ty::GenericParamDefKind::Lifetime = param.kind { tcx.lifetimes.re_erased.into() } else { diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 89fc8980037..f16a903ad2c 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -617,7 +617,9 @@ pub fn type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll ty::RawPtr(ty::TypeAndMut { ty: pointee_type, .. }) | ty::Ref(_, pointee_type, _) => { pointer_or_reference_metadata(cx, t, pointee_type, unique_type_id) } - ty::Adt(def, _) if def.is_box() => { + // Box<T, A> may have a non-ZST allocator A. In that case, we + // cannot treat Box<T, A> as just an owned alias of `*mut T`. + ty::Adt(def, substs) if def.is_box() && cx.layout_of(substs.type_at(1)).is_zst() => { pointer_or_reference_metadata(cx, t, t.boxed_ty(), unique_type_id) } ty::FnDef(..) | ty::FnPtr(_) => subroutine_type_metadata(cx, unique_type_id), @@ -639,7 +641,7 @@ pub fn type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll AdtKind::Struct => prepare_struct_metadata(cx, t, unique_type_id).finalize(cx), AdtKind::Union => prepare_union_metadata(cx, t, unique_type_id).finalize(cx), AdtKind::Enum => { - prepare_enum_metadata(cx, t, def.did, unique_type_id, vec![]).finalize(cx) + prepare_enum_metadata(cx, t, def.did(), unique_type_id, vec![]).finalize(cx) } }, ty::Tuple(tys) => { @@ -1207,7 +1209,7 @@ fn prepare_struct_metadata<'ll, 'tcx>( let struct_name = compute_debuginfo_type_name(cx.tcx, struct_type, false); let (struct_def_id, variant) = match struct_type.kind() { - ty::Adt(def, _) => (def.did, def.non_enum_variant()), + ty::Adt(def, _) => (def.did(), def.non_enum_variant()), _ => bug!("prepare_struct_metadata on a non-ADT"), }; @@ -1384,7 +1386,7 @@ fn prepare_union_metadata<'ll, 'tcx>( let union_name = compute_debuginfo_type_name(cx.tcx, union_type, false); let (union_def_id, variant) = match union_type.kind() { - ty::Adt(def, _) => (def.did, def.non_enum_variant()), + ty::Adt(def, _) => (def.did(), def.non_enum_variant()), _ => bug!("prepare_union_metadata on a non-ADT"), }; @@ -1466,7 +1468,7 @@ impl<'ll, 'tcx> EnumMemberDescriptionFactory<'ll, 'tcx> { }; let variant_info_for = |index: VariantIdx| match *self.enum_type.kind() { - ty::Adt(adt, _) => VariantInfo::Adt(&adt.variants[index], index), + ty::Adt(adt, _) => VariantInfo::Adt(&adt.variant(index), index), ty::Generator(def_id, _, _) => { let (generator_layout, generator_saved_local_names) = generator_variant_info_data.as_ref().unwrap(); @@ -1490,7 +1492,7 @@ impl<'ll, 'tcx> EnumMemberDescriptionFactory<'ll, 'tcx> { match self.layout.variants { Variants::Single { index } => { if let ty::Adt(adt, _) = self.enum_type.kind() { - if adt.variants.is_empty() { + if adt.variants().is_empty() { return vec![]; } } @@ -1940,7 +1942,7 @@ fn prepare_enum_metadata<'ll, 'tcx>( let discriminant_type_metadata = |discr: Primitive| { let enumerators_metadata: Vec<_> = match enum_type.kind() { - ty::Adt(def, _) => iter::zip(def.discriminants(tcx), &def.variants) + ty::Adt(def, _) => iter::zip(def.discriminants(tcx), def.variants()) .map(|((_, discr), v)| { let name = v.name.as_str(); let is_unsigned = match discr.ty.kind() { @@ -2311,7 +2313,7 @@ fn set_members_of_composite_type<'ll, 'tcx>( fn compute_type_parameters<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> &'ll DIArray { if let ty::Adt(def, substs) = *ty.kind() { if substs.types().next().is_some() { - let generics = cx.tcx.generics_of(def.did); + let generics = cx.tcx.generics_of(def.did()); let names = get_parameter_names(cx, generics); let template_params: Vec<_> = iter::zip(substs, names) .filter_map(|(kind, name)| { diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index 1b4a193dbf1..34013b5f737 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -524,7 +524,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { { Some(type_metadata(cx, impl_self_ty)) } else { - Some(namespace::item_namespace(cx, def.did)) + Some(namespace::item_namespace(cx, def.did())) } } _ => None, diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index e7c13e793d9..7f804ab5e63 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -300,34 +300,34 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { use abi::Abi::*; let tp_ty = substs.type_at(0); let layout = self.layout_of(tp_ty).layout; - let use_integer_compare = match layout.abi { + let use_integer_compare = match layout.abi() { Scalar(_) | ScalarPair(_, _) => true, Uninhabited | Vector { .. } => false, Aggregate { .. } => { // For rusty ABIs, small aggregates are actually passed // as `RegKind::Integer` (see `FnAbi::adjust_for_abi`), // so we re-use that same threshold here. - layout.size <= self.data_layout().pointer_size * 2 + layout.size() <= self.data_layout().pointer_size * 2 } }; let a = args[0].immediate(); let b = args[1].immediate(); - if layout.size.bytes() == 0 { + if layout.size().bytes() == 0 { self.const_bool(true) } else if use_integer_compare { - let integer_ty = self.type_ix(layout.size.bits()); + let integer_ty = self.type_ix(layout.size().bits()); let ptr_ty = self.type_ptr_to(integer_ty); let a_ptr = self.bitcast(a, ptr_ty); - let a_val = self.load(integer_ty, a_ptr, layout.align.abi); + let a_val = self.load(integer_ty, a_ptr, layout.align().abi); let b_ptr = self.bitcast(b, ptr_ty); - let b_val = self.load(integer_ty, b_ptr, layout.align.abi); + let b_val = self.load(integer_ty, b_ptr, layout.align().abi); self.icmp(IntPredicate::IntEQ, a_val, b_val) } else { let i8p_ty = self.type_i8p(); let a_ptr = self.bitcast(a, i8p_ty); let b_ptr = self.bitcast(b, i8p_ty); - let n = self.const_usize(layout.size.bytes()); + let n = self.const_usize(layout.size().bytes()); let cmp = self.call_intrinsic("memcmp", &[a_ptr, b_ptr, n]); self.icmp(IntPredicate::IntEQ, cmp, self.const_i32(0)) } diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index e9d13a4ebaf..4b324740a1f 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -527,8 +527,9 @@ pub(crate) fn should_use_new_llvm_pass_manager(user_opt: &Option<bool>, target_a // The new pass manager is enabled by default for LLVM >= 13. // This matches Clang, which also enables it since Clang 13. - // FIXME: There are some perf issues with the new pass manager - // when targeting s390x, so it is temporarily disabled for that - // arch, see https://github.com/rust-lang/rust/issues/89609 - user_opt.unwrap_or_else(|| target_arch != "s390x" && llvm_util::get_version() >= (13, 0, 0)) + // There are some perf issues with the new pass manager when targeting + // s390x with LLVM 13, so enable the new pass manager only with LLVM 14. + // See https://github.com/rust-lang/rust/issues/89609. + let min_version = if target_arch == "s390x" { 14 } else { 13 }; + user_opt.unwrap_or_else(|| llvm_util::get_version() >= (min_version, 0, 0)) } diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index da378dc6493..757aa9a1011 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -53,8 +53,8 @@ fn uncached_llvm_type<'a, 'tcx>( if let (&ty::Adt(def, _), &Variants::Single { index }) = (layout.ty.kind(), &layout.variants) { - if def.is_enum() && !def.variants.is_empty() { - write!(&mut name, "::{}", def.variants[index].name).unwrap(); + if def.is_enum() && !def.variants().is_empty() { + write!(&mut name, "::{}", def.variant(index).name).unwrap(); } } if let (&ty::Generator(_, _, _), &Variants::Single { index }) = |
