提交 9b2a4659 编写于 作者: B bors

Auto merge of #93644 - michaelwoerister:simpler-debuginfo-typemap, r=wesleywiser

debuginfo: Simplify TypeMap used during LLVM debuginfo generation.

This PR simplifies the TypeMap that is used in `rustc_codegen_llvm::debuginfo::metadata`. It was unnecessarily complicated because it was originally implemented when types were not yet normalized before codegen. So it did it's own normalization and kept track of multiple unnormalized types being mapped to a single unique id.

This PR is based on https://github.com/rust-lang/rust/pull/93503, which is not merged yet.

The PR also removes the arena used for allocating string ids and instead uses `InlinableString` from the [inlinable_string](https://crates.io/crates/inlinable_string) crate. That might not be the best choice, since that crate does not seem to be very actively maintained. The [flexible-string](https://crates.io/crates/flexible-string) crate would be an alternative.

r? `@ghost`
......@@ -3524,6 +3524,7 @@ dependencies = [
"rustc_hir",
"rustc_index",
"rustc_llvm",
"rustc_macros",
"rustc_metadata",
"rustc_middle",
"rustc_query_system",
......
......@@ -25,6 +25,7 @@ rustc_fs_util = { path = "../rustc_fs_util" }
rustc_hir = { path = "../rustc_hir" }
rustc_index = { path = "../rustc_index" }
rustc_llvm = { path = "../rustc_llvm" }
rustc_macros = { path = "../rustc_macros" }
rustc_metadata = { path = "../rustc_metadata" }
rustc_query_system = { path = "../rustc_query_system" }
rustc_session = { path = "../rustc_session" }
......
......@@ -38,6 +38,7 @@
use smallvec::SmallVec;
use std::cell::RefCell;
use std::iter;
use std::lazy::OnceCell;
use tracing::debug;
mod create_scope_map;
......@@ -63,9 +64,11 @@ pub struct CrateDebugContext<'a, 'tcx> {
created_files: RefCell<FxHashMap<(Option<String>, Option<String>), &'a DIFile>>,
created_enum_disr_types: RefCell<FxHashMap<(DefId, Primitive), &'a DIType>>,
type_map: RefCell<TypeMap<'a, 'tcx>>,
type_map: TypeMap<'a, 'tcx>,
namespace_map: RefCell<DefIdMap<&'a DIScope>>,
recursion_marker_type: OnceCell<&'a DIType>,
// This collection is used to assert that composite types (structs, enums,
// ...) have their members only set once:
composite_types_completed: RefCell<FxHashSet<&'a DIType>>,
......@@ -93,6 +96,7 @@ pub fn new(llmod: &'a llvm::Module) -> Self {
created_enum_disr_types: Default::default(),
type_map: Default::default(),
namespace_map: RefCell::new(Default::default()),
recursion_marker_type: OnceCell::new(),
composite_types_completed: Default::default(),
}
}
......
......@@ -9,10 +9,14 @@
#![feature(crate_visibility_modifier)]
#![feature(let_else)]
#![feature(extern_types)]
#![feature(once_cell)]
#![feature(nll)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_macros;
use back::write::{create_informational_target_machine, create_target_machine};
pub use llvm_util::target_features;
......
......@@ -5,7 +5,7 @@
// NONMSVC: {{.*}}DIDerivedType(tag: DW_TAG_pointer_type, name: "fn() -> <recursive_type>",{{.*}}
//
// CHECK: {{.*}}DISubroutineType{{.*}}
// CHECK: {{.*}}DIBasicType(name: "<recur_type>", encoding: DW_ATE_unsigned)
// CHECK: {{.*}}DIBasicType(name: "<recur_type>", size: {{32|64}}, encoding: DW_ATE_unsigned)
pub fn foo() -> impl Copy {
foo
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册