diff options
| author | bors <bors@rust-lang.org> | 2022-02-24 04:07:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-02-24 04:07:48 +0000 |
| commit | e780264e1e5c1efa6ab76c7b17a9677f16add5e0 (patch) | |
| tree | c0ad8347fc2a4e2fd54ed6510123a64d568f1cca /compiler/rustc_codegen_llvm/src | |
| parent | 8ebec97e09a89760e5791bbb2ab96e2ebec19931 (diff) | |
| parent | 4e41a46f6a6894ecb4b9d968a33f73a8e321587a (diff) | |
| download | rust-e780264e1e5c1efa6ab76c7b17a9677f16add5e0.tar.gz rust-e780264e1e5c1efa6ab76c7b17a9677f16add5e0.zip | |
Auto merge of #94107 - tmiasko:fewer-types, r=davidtwco
Reapply cg_llvm: `fewer_names` in `uncached_llvm_type` r? `@davidtwco` `@erikdesjardins`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/type_of.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index 02a263637a6..da378dc6493 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -1,5 +1,6 @@ use crate::common::*; use crate::context::TypeLowering; +use crate::llvm_util::get_version; use crate::type_::Type; use rustc_codegen_ssa::traits::*; use rustc_middle::bug; @@ -42,7 +43,12 @@ fn uncached_llvm_type<'a, 'tcx>( // FIXME(eddyb) producing readable type names for trait objects can result // in problematically distinct types due to HRTB and subtyping (see #47638). // ty::Dynamic(..) | - ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Generator(..) | ty::Str => { + ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Generator(..) | ty::Str + // For performance reasons we use names only when emitting LLVM IR. Unless we are on + // LLVM < 14, where the use of unnamed types resulted in various issues, e.g., #76213, + // #79564, and #79246. + if get_version() < (14, 0, 0) || !cx.sess().fewer_names() => + { let mut name = with_no_visible_paths!(with_no_trimmed_paths!(layout.ty.to_string())); if let (&ty::Adt(def, _), &Variants::Single { index }) = (layout.ty.kind(), &layout.variants) @@ -58,6 +64,9 @@ fn uncached_llvm_type<'a, 'tcx>( } Some(name) } + // Use identified structure types for ADT. Due to pointee types in LLVM IR their definition + // might be recursive. Other cases are non-recursive and we can use literal structure types. + ty::Adt(..) => Some(String::new()), _ => None, }; |
