From dc905e4b1500a8f440d0150963da1f67ad8f55b9 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Sat, 28 Aug 2021 19:37:11 -0400 Subject: [PATCH] Revert "Revert "cg_llvm: `fewer_names` in `uncached_llvm_type`"" This reverts commit 88dc58fc9bb3dddccb99fc0e9f7a917c2052f8d0. --- compiler/rustc_codegen_llvm/src/type_of.rs | 10 +++++++++- src/test/ui/const-generics/issues/issue-75763.rs | 3 +-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index 85efe3e64836c..f7dcdcac04f12 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -43,7 +43,9 @@ 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 + if !cx.sess().fewer_names() => + { let mut name = with_no_trimmed_paths(|| layout.ty.to_string()); if let (&ty::Adt(def, _), &Variants::Single { index }) = (layout.ty.kind(), &layout.variants) @@ -59,6 +61,12 @@ fn uncached_llvm_type<'a, 'tcx>( } Some(name) } + ty::Adt(..) => { + // If `Some` is returned then a named struct is created in LLVM. Name collisions are + // avoided by LLVM (with increasing suffixes). If rustc doesn't generate names then that + // can improve perf. + Some(String::new()) + } _ => None, }; diff --git a/src/test/ui/const-generics/issues/issue-75763.rs b/src/test/ui/const-generics/issues/issue-75763.rs index c311de05a1cff..2fd9f9a60de9f 100644 --- a/src/test/ui/const-generics/issues/issue-75763.rs +++ b/src/test/ui/const-generics/issues/issue-75763.rs @@ -1,5 +1,4 @@ -// ignore-test -// FIXME(const_generics): This test causes an ICE after reverting #76030. +// build-pass #![allow(incomplete_features)] #![feature(const_generics)]