summary refs log tree commit diff
path: root/compiler/rustc_symbol_mangling/src
AgeCommit message (Collapse)AuthorLines
2022-09-16Rollup merge of #101782 - ↵Michael Howell-32/+34
JhonnyBillM:refactor-symbol-mangling-diags-migration, r=davidtwco Update `symbol_mangling` diagnostics migration Addresses comments raised in #100831. r? `@eddyb` `@davidtwco`
2022-09-13Address code review commentsEric Holk-4/+11
2022-09-13UPDATE - merge and avoid translations for symbol mangling test outputJhonny Bill Mena-32/+34
2022-09-12Plumb dyn trait representation through ty::DynamicEric Holk-2/+2
2022-09-08Remove ReEmptyJack Huey-2/+1
2022-09-05Pack `Term` in the same way as `GenericArg`.Nicholas Nethercote-11/+7
This shrinks the `PredicateS` type, which is instanted frequently.
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-4/+3
by module
2022-08-30UPDATE - to support diag introduced in PR #100765Jhonny Bill Mena-4/+4
2022-08-30ADD - diagnostics lints to symbol_mangling moduleJhonny Bill Mena-0/+2
2022-08-30ADD - migrate InvalidDefPath to new diagnostics infraJhonny Bill Mena-3/+13
2022-08-30UPDATE - accept String instead of unused 'strJhonny Bill Mena-9/+9
2022-08-30ADD - migrate InvalidTraitItem and AltInvalidTraitItem errorsJhonny Bill Mena-3/+25
Thought of doing this by having a struct and an enum with Default and Alt cases, but not sure if we wanted to have the text in code instead of having “demangling()” and “demangling-alt()” in the ftl file. Don’t like the current way of having structs representing the same-ish and using long names to distinguish their expectations, instead of putting this in an enum and handling the different cases inside the type. I am fine with whichever option the team prefers; also understand having them as separate structs keeps it simple.
2022-08-30ADD - InvalidSymbolName to migrate symbol-name({}) error to new diagnostics ↵Jhonny Bill Mena-1/+18
infraestructure ADD - dependencies needed to port a module to new Diagnostics infra (rustc_macros, rustc_errors, errors file, and fluent file)
2022-08-26Change `FnAbi::fixed_count` to a `u32`.Nicholas Nethercote-1/+1
2022-07-24Auto merge of #95548 - rcvalle:rust-cfi-2, r=nagisabors-43/+949
Add fine-grained LLVM CFI support to the Rust compiler This PR improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue https://github.com/rust-lang/rust/issues/89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto). Thank you again, `@eddyb,` `@nagisa,` `@pcc,` and `@tmiasko` for all the help!
2022-07-23Add fine-grained LLVM CFI support to the Rust compilerRamon de C Valle-43/+949
This commit improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).
2022-07-20consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable)Ralf Jung-3/+3
2022-07-06Allow to create definitions inside the query system.Camille GILLOT-36/+37
2022-07-06Update TypeVisitor pathsAlan Egerton-2/+2
2022-07-05Relax constrained generics to TypeVisitableAlan Egerton-2/+2
2022-06-14Auto merge of #96285 - flip1995:pk-vfe, r=nagisabors-0/+25
Introduce `-Zvirtual-function-elimination` codegen flag Fixes #68262 This PR adds a codegen flag `-Zvirtual-function-elimination` to enable the VFE optimization in LLVM. To make this work, additonal information has to be added to vtables ([`!vcall_visibility` metadata](https://llvm.org/docs/TypeMetadata.html#vcall-visibility-metadata) and a `typeid` of the trait). Furthermore, instead of just `load`ing functions, the [`llvm.type.checked.load` intrinsic](https://llvm.org/docs/LangRef.html#llvm-type-checked-load-intrinsic) has to be used to map functions to vtables. For technical details of the changes, see the commit messages. I also tested this flag on https://github.com/tock/tock on different boards to verify that this fixes the issue https://github.com/tock/tock/issues/2594. This flag is able to improve the size of the resulting binary by about 8k-9k bytes by removing the unused debug print functions. [Rendered documentation update](https://github.com/flip1995/rust/blob/pk-vfe/src/doc/rustc/src/codegen-options/index.md#virtual-function-elimination)
2022-06-14rebaseb-naber-1/+1
2022-06-14address reviewb-naber-3/+2
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-43/+52
2022-06-14Add typeid_for_trait_ref functionflip1995-0/+25
This function computes a Itanium-like typeid for a trait_ref. This is required for the VFE optimization in LLVM. It is used to map `llvm.type.checked.load` invocations, that is loading the function from a vtable, to the vtables this function could be from. It is important to note that `typeid`s are not unique. So multiple vtables of the same trait can share `typeid`s.
2022-06-14Rename the `ConstS::val` field as `kind`.Nicholas Nethercote-5/+5
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-06-03Fully stabilize NLLJack Huey-1/+0
2022-05-14Auto merge of #96883 - jackh726:early-binder-2, r=oli-obkbors-2/+4
Add EarlyBinder Chalk has no concept of `Param` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L579) or `ReEarlyBound` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L1308). Everything is just "bound" - the equivalent of rustc's late-bound. It's not completely clear yet whether to move everything to the same time of binder in rustc or add `Param` and `ReEarlyBound` in Chalk. Either way, tracking when we have or haven't already substituted out these in rustc can be helpful. As a first step, I'm just adding a `EarlyBinder` newtype that is required to call `subst`. I also add a couple "transparent" `bound_*` wrappers around a couple query that are often immediately substituted. r? `@nikomatsakis`
2022-05-13Rollup merge of #96989 - cjgillot:defpath-use, r=davidtwcoMatthias Krüger-1/+2
Be more precise than DefPathData::Misc. This variant was used for two unrelated things. Let's make this cleaner.
2022-05-12Replace DefPathData::Misc by two appropriately-named variants.Camille GILLOT-1/+2
2022-05-10Introduce EarlyBinderJack Huey-2/+4
2022-05-10only_local: always check for misuselcnr-19/+18
2022-05-09reviewlcnr-1/+1
2022-05-09only compute `codegen_fn_attrs` where neededlcnr-14/+25
2022-04-17Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillotbors-21/+18
Refactor HIR item-like traversal (part 1) Issue #95004 - Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel; Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com> cc `@cjgillot`
2022-04-13Auto merge of #95656 - cjgillot:no-id-hashing-mode, r=Aaron1011bors-22/+19
Remove NodeIdHashingMode. r? `@ghost`
2022-04-12Remove NodeIdHashingMode.Camille GILLOT-22/+19
2022-04-10Do not access HIR to compute symbol_name.Camille GILLOT-8/+4
2022-04-08remove ItemLikeVisitor impls in incremental, interface, metadata and ↵Miguel Guarniz-29/+5
symbol_mangling crates Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08remove some uses of visit_all_item_likes in typeck, symbol_mangling and ↵Miguel Guarniz-1/+22
passes crates Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-1/+1
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-2/+3
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-07Introduce `ConstAllocation`.Nicholas Nethercote-2/+3
Currently some `Allocation`s are interned, some are not, and it's very hard to tell at a use point which is which. This commit introduces `ConstAllocation` for the known-interned ones, which makes the division much clearer. `ConstAllocation::inner()` is used to get the underlying `Allocation`. In some places it's natural to use an `Allocation`, in some it's natural to use a `ConstAllocation`, and in some places there's no clear choice. I've tried to make things look as nice as possible, while generally favouring `ConstAllocation`, which is the type that embodies more information. This does require quite a few calls to `inner()`. The commit also tweaks how `PartialOrd` works for `Interned`. The previous code was too clever by half, building on `T: Ord` to make the code shorter. That caused problems with deriving `PartialOrd` and `Ord` for `ConstAllocation`, so I changed it to build on `T: PartialOrd`, which is slightly more verbose but much more standard and avoided the problems.
2022-03-01Rollup merge of #94359 - tmiasko:legacy-verbose-const, r=petrochenkovMatthias Krüger-5/+33
Fix inconsistent symbol mangling of integers constants with -Zverbose The `PrettyPrinter` changes formatting of array size and integer constants based on `-Zverbose`, so its implementation cannot be used in legacy symbol mangling. Example symbol demangling before changes: ```console $ cat a.rs pub struct A<T>(T); impl A<[u8; 128]> { pub fn f() {} } $ rustc --crate-type=lib a.rs -Zverbose=n && nm -C ./liba.rlib 00000000 T a::A<[u8; 128]>::f $ rustc --crate-type=lib a.rs -Zverbose=y && nm -C ./liba.rlib 00000000 T a::A<[u8; Const { ty. usize, val. Value(Scalar(0x0000000000000080)) }]>::f ```
2022-02-28Fix inconsistent symbol mangling of integers constants with -ZverboseTomasz Miąsko-5/+33
The `PrettyPrinter` changes formatting of array size and integer constants based on `-Zverbose`, so its implementation cannot be used in legacy symbol mangling.
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-23Rename `region_should_not_be_omitted` to `should_print_region`Tomasz Miąsko-1/+1
to avoid double negation
2022-02-21use `List<Ty<'tcx>>` for tupleslcnr-1/+1
2022-02-16Move ty::print methods to Drop-based scope guardsMark Rousskov-1/+1
2022-02-15Overhaul `Const`.Nicholas Nethercote-13/+13
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.