about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/debuginfo
AgeCommit message (Collapse)AuthorLines
2023-09-13make the eval() functions on our const types return the resulting valueRalf Jung-4/+2
2023-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-9/+9
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-19/+23
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-2/+1
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-1/+1
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-3/+2
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-4/+12
2023-01-27Introduce GeneratorWitnessMIR.Camille GILLOT-0/+1
2022-12-27ADD - fixme in type_names.rs until we are able to translate InterpErrorJhonny Bill Mena-0/+1
2022-12-25fix more clippy::style findingsMatthias Krüger-1/+1
match_result_ok obfuscated_if_else single_char_add writeln_empty_string collapsible_match iter_cloned_collect unnecessary_mut_passed
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-1/+1
2022-12-13Combine identical alias armsMichael Goulet-2/+1
2022-12-13Combine projection and opaque into aliasMichael Goulet-2/+2
2022-12-13ProjectionTy.item_def_id -> ProjectionTy.def_idMichael Goulet-1/+1
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-5/+5
2022-10-31[debuginfo] Make debuginfo type names for slices and str consistent.Michael Woerister-13/+13
Before this PR, the compiler would emit the debuginfo name `slice$<T>` for all kinds of slices, regardless of whether they are behind a reference or not and regardless of the kind of reference. As a consequence, the types `Foo<&[T]>`, `Foo<[T]>`, and `Foo<&mut [T]>` would end up with the same type name `Foo<slice$<T> >` in debuginfo, making it impossible to disambiguate between them by name. Similarly, `&str` would get the name `str` in debuginfo, so the debuginfo name for `Foo<str>` and `Foo<&str>` would be the same. In contrast, `*const [bool]` and `*mut [bool]` would be `ptr_const$<slice$<bool> >` and `ptr_mut$<slice$<bool> >`, i.e. the encoding does not lose information about the type. This PR removes all special handling for slices and `str`. The types `&[bool]`, `&mut [bool]`, and `&str` thus get the names `ref$<slice2$<bool> >`, `ref_mut$<slice2$<bool> >`, and `ref$<str$>` respectively -- as one would expect.
2022-10-19Remove byte swap of valtree hash on big endianQiu Chaofan-4/+2
2022-08-12Use enum2<_> instead of enum<_> for Cpp-like debuginfo enum type names.Michael Woerister-2/+2
And add more comments about niche tag enum encoding.
2022-08-12debuginfo: Change C++-like encoding for enums.Michael Woerister-48/+4
The updated encoding should be able to handle niche layouts where more than one variant has fields.
2022-07-06Allow to create definitions inside the query system.Camille GILLOT-8/+12
2022-06-14account for endianness in debuginfo for const argsb-naber-3/+6
2022-06-14rebaseb-naber-1/+2
2022-06-14Rename the `ConstS::val` field as `kind`.Nicholas Nethercote-4/+4
And likewise for the `Const::val` method. Because its type is called `ConstKind`. Also `val` is a confusing name because `ConstKind` is an enum with seven variants, one of which is called `Value`. Also, this gives consistency with `TyS` and `PredicateS` which have `kind` fields. The commit also renames a few `Const` variables from `val` to `c`, to avoid confusion with the `ConstKind::Value` variant.
2022-04-12Remove NodeIdHashingMode.Camille GILLOT-6/+1
2022-04-05Mark scalar layout unions so that backends that do not support partially ↵Oli Scherer-3/+3
initialized scalars can special case them.
2022-03-18Auto merge of #95056 - Dylan-DPC:rollup-swtuw2n, r=Dylan-DPCbors-2/+23
Rollup of 10 pull requests Successful merges: - #91133 (Improve `unsafe` diagnostic) - #93222 (Make ErrorReported impossible to construct outside `rustc_errors`) - #93745 (Stabilize ADX target feature) - #94309 ([generator_interior] Be more precise with scopes of borrowed places) - #94698 (Remove redundant code from copy-suggestions) - #94731 (Suggest adding `{ .. }` around a const function call with arguments) - #94960 (Fix many spelling mistakes) - #94982 (Add deprecated_safe feature gate and attribute, cc #94978) - #94997 (debuginfo: Fix ICE when generating name for type that produces a layout error.) - #95000 (Fixed wrong type name in comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-16erase late-bound regions in dyn projection types for debuginfoMichael Goulet-1/+2
2022-03-16debuginfo: Fix ICE when generating name for type that produces a layout error.Michael Woerister-2/+23
2022-03-15Rollup merge of #94810 - michaelwoerister:fix-trait-pointer-debuginfo-names, ↵Matthias Krüger-3/+10
r=wesleywiser debuginfo: Fix bug in type name generation for dyn types with associated types but no other generic arguments. For types like `&dyn Future<Output=bool>` the compiler currently emits invalid types names in debuginfo. This PR fixes this. Before: ```txt // DWARF &dyn core::future::future::Future, Output=bool> // CodeView ref$<dyn$<core::future::future::Future,assoc$<Output,bool> > > > ``` After: ```txt // DWARF &dyn core::future::future::Future<Output=bool> // CodeView ref$<dyn$<core::future::future::Future<assoc$<Output,bool> > > > ``` These syntactically incorrect type names can cause downstream tools (e.g. debugger extensions) crash when trying to parse them. r? `@wesleywiser`
2022-03-14debuginfo: Refactor debuginfo generation for types -- Address review comments.Michael Woerister-1/+1
2022-03-14debuginfo: change cpp-like naming for generator environments so that NatVis ↵Michael Woerister-48/+92
works for them
2022-03-14debuginfo: Refactor debuginfo generation for typesMichael Woerister-2/+38
This commit - changes names to use di_node instead of metadata - uniformly names all functions that build new debuginfo nodes build_xyz_di_node - renames CrateDebugContext to CodegenUnitDebugContext (which is more accurate) - moves TypeMap and functions that work directly work with it to a new type_map module - moves and reimplements enum related builder functions to a new enums module - splits enum debuginfo building for the native and cpp-like cases, since they are mostly separate - uses SmallVec instead of Vec in many places - removes the old infrastructure for dealing with recursion cycles (create_and_register_recursive_type_forward_declaration(), RecursiveTypeDescription, set_members_of_composite_type(), MemberDescription, MemberDescriptionFactory, prepare_xyz_metadata(), etc) - adds type_map::build_type_with_children() as a replacement for dealing with recursion cycles - adds many (doc-)comments explaining what's going on - changes cpp-like naming for C-Style enums so they don't get a enum$<...> name (because the NatVis visualizer does not apply to them) - fixes detection of what is a C-style enum because some enums where classified as C-style even though they have fields - changes the position of discriminant debuginfo node so it is consistently nested inside the top-level union instead of, sometimes, next to it
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-7/+7
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-10debuginfo: Fix bug in type name generation for dyn types with associated ↵Michael Woerister-3/+10
types but no other generic arguments.
2022-03-07Clarify `Layout` interning.Nicholas Nethercote-1/+1
`Layout` is another type that is sometimes interned, sometimes not, and we always use references to refer to it so we can't take any advantage of the uniqueness properties for hashing or equality checks. This commit renames `Layout` as `LayoutS`, and then introduces a new `Layout` that is a newtype around an `Interned<LayoutS>`. It also interns more layouts than before. Previously layouts within layouts (via the `variants` field) were never interned, but now they are. Hence the lifetime on the new `Layout` type. Unlike other interned types, these ones are in `rustc_target` instead of `rustc_middle`. This reflects the existing structure of the code, which does layout-specific stuff in `rustc_target` while `TyAndLayout` is generic over the `Ty`, allowing the type-specific stuff to occur in `rustc_middle`. The commit also adds a `HashStable` impl for `Interned`, which was needed. It hashes the contents, unlike the `Hash` impl which hashes the pointer.
2022-03-03all: fix some typoscuishuang-1/+1
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-02-21use `List<Ty<'tcx>>` for tupleslcnr-1/+1
2022-02-15Overhaul `Const`.Nicholas Nethercote-8/+8
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
2022-02-15Overhaul `TyS` and `Ty`.Nicholas Nethercote-1/+1
Specifically, change `Ty` from this: ``` pub type Ty<'tcx> = &'tcx TyS<'tcx>; ``` to this ``` pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>); ``` There are two benefits to this. - It's now a first class type, so we can define methods on it. This means we can move a lot of methods away from `TyS`, leaving `TyS` as a barely-used type, which is appropriate given that it's not meant to be used directly. - The uniqueness requirement is now explicit, via the `Interned` type. E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather than via `TyS`, which wasn't obvious at all. Much of this commit is boring churn. The interesting changes are in these files: - compiler/rustc_middle/src/arena.rs - compiler/rustc_middle/src/mir/visit.rs - compiler/rustc_middle/src/ty/context.rs - compiler/rustc_middle/src/ty/mod.rs Specifically: - Most mentions of `TyS` are removed. It's very much a dumb struct now; `Ty` has all the smarts. - `TyS` now has `crate` visibility instead of `pub`. - `TyS::make_for_test` is removed in favour of the static `BOOL_TY`, which just works better with the new structure. - The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned` (pointer-based, for the `Equal` case) and partly on `TyS` (contents-based, for the other cases). - There are many tedious sigil adjustments, i.e. adding or removing `*` or `&`. They seem to be unavoidable.
2022-02-08debuginfo: Bring back DW_AT_containing_type for vtables -- address review ↵Michael Woerister-1/+1
comments
2022-02-03debuginfo: Bring back DW_AT_containing_type for vtables after it has ↵Michael Woerister-2/+19
accidentally been removed in https://github.com/rust-lang/rust/pull/89597. Also describe vtables as structs with a field for each entry.
2022-02-01debuginfo: Make sure that type names for closure and generator environments ↵Michael Woerister-36/+74
are unique in debuginfo. Before this change, closure/generator environments coming from different instantiations of the same generic function were all assigned the same name even though they were distinct types with potentially different data layout. Now we append the generic arguments of the originating function to the type name. This commit also emits '{closure_env#0}' as the name of these types in order to disambiguate them from the accompanying closure function '{closure#0}'. Previously both were assigned the same name.
2022-01-17Add term to ExistentialProjectionkadmin-2/+3
Also prevent ICE when adding a const in associated const equality.
2022-01-13Generate more precise generator namesEric Holk-2/+8
Currently all generators are named with a `generator$N` suffix, regardless of where they come from. This means an `async fn` shows up as a generator in stack traces, which can be surprising to async programmers since they should not need to know that async functions are implementated using generators. This change generators a different name depending on the generator kind, allowing us to tell whether the generator is the result of an async block, an async closure, an async fn, or a plain generator.
2022-01-11Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`Aaron Hill-2/+2
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2022-01-07Consolidate checking for msvc when generating debuginfoWesley Wiser-50/+51
If the target we're generating code for is msvc, then we do two main things differently: we generate type names in a C++ style instead of a Rust style and we generate debuginfo for enums differently. I've refactored the code so that there is one function (`cpp_like_debuginfo`) which determines if we should use the C++ style of naming types and other debuginfo generation or the regular Rust one.
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-2/+2
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-2/+2
2021-12-15Remove `in_band_lifetimes` from `rustc_codegen_ssa`LegionMammal978-3/+3
See #91867 for more information.
2021-11-06use matches!() macro in more placesMatthias Krüger-4/+1