about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
AgeCommit message (Collapse)AuthorLines
2025-08-14Rollup merge of #145266 - camsteffen:reduce-queries, r=petrochenkovGuillaume Gomez-1/+1
Reduce some queries around associated items
2025-08-14Rollup merge of #144727 - Stypox:add-tracing-to-resolve, r=RalfJungGuillaume Gomez-23/+41
Add tracing to resolve-related functions Resolve-related functions are not called often but still make up for ~3% of execution time for non-repetitive programs (as seen in the first table below, obtained from running the rust snippet at the bottom with `n=1`). On the other hand, for repetitive programs they become less relevant (I tested the same snippet but with `n=100` and got ~1.5%), and it appears that only `try_resolve` is called more often (see the last two tables). The first table was obtained by opening the trace file in https://ui.perfetto.dev and running the following query: ```sql select "TOTAL PROGRAM DURATION" as name, count(*), max(ts + dur) as "sum(dur)", 100.0 as "%", null as "min(dur)", null as "max(dur)", null as "avg(dur)", null as "stddev(dur)" from slices union select "TOTAL OVER ALL SPANS (excluding events)" as name, count(*), sum(dur), cast(cast(sum(dur) as float) / (select max(ts + dur) from slices) * 1000 as int) / 10.0 as "%", min(dur), max(dur), cast(avg(dur) as int) as "avg(dur)", cast(sqrt(avg(dur*dur)-avg(dur)*avg(dur)) as int) as "stddev(dur)" from slices where parent_id is null and name != "frame" and name != "step" and dur > 0 union select name, count(*), sum(dur), cast(cast(sum(dur) as float) / (select max(ts + dur) from slices) * 1000 as int) / 10.0 as "%", min(dur), max(dur), cast(avg(dur) as int) as "avg(dur)", cast(sqrt(avg(dur*dur)-avg(dur)*avg(dur)) as int) as "stddev(dur)" from slices where parent_id is null and name != "frame" and name != "step" group by name order by sum(dur) desc, count(*) desc ``` <img width="1687" height="242" alt="image" src="https://github.com/user-attachments/assets/4d4bd890-869b-40f3-a473-8e4c42b02da4" /> The following two tables show how many `resolve` spans there per subname/subcategory, and how much time is spent in each. The first is for `n=1` and the second for `n=100`. The query that was used is: ```sql select args.string_value as name, count(*), max(dur), avg(dur), sum(dur) from slices inner join args USING (arg_set_id) where args.key = "args." || slices.name and name = "resolve" group by args.string_value ``` <img width="1688" height="159" alt="image" src="https://github.com/user-attachments/assets/a8749856-c099-492e-a86e-6d67b146af9c" /> <img width="1688" height="159" alt="image" src="https://github.com/user-attachments/assets/ce3ac1b5-5c06-47d9-85a6-9b921aea348e" /> The snippet I tested with Miri to obtain the above traces is: ```rust fn main() { let n: usize = std::env::args().nth(1).unwrap().parse().unwrap(); let mut v = (0..n).into_iter().collect::<Vec<_>>(); for i in &mut v { *i += 1; } } ```
2025-08-13Rollup merge of #144949 - nnethercote:more-Printer-cleanups, r=davidtwcoGuillaume Gomez-12/+12
More `Printer` cleanups A sequel to rust-lang/rust#144776. r? ```@davidtwco```
2025-08-13Cleanup assoc parent utilsCameron Steffen-1/+1
2025-08-12Revert "Partially outline code inside the panic! macro".Mara Bos-4/+4
Without any tests/benchmarks that show some improvement, it's hard to know whether the change had any positive effect at all. (And if it did, whether that effect is still achieved today.)
2025-08-11Turn _span into _trace as trace span nameStypox-19/+19
_span could possibly be confused with the Span type in rustc
2025-08-11Add tracing to resolve-related functionsStypox-23/+41
2025-08-09rename `TraitRef::from_method` to `from_assoc`Deadbeef-2/+2
also add a note to `GenericArgs::truncate_to`
2025-08-07Rollup merge of #145033 - nnethercote:fix-144994, r=fmeaseStuart Cook-1/+3
Reimplement `print_region` in `type_name.rs`. Broken by rust-lang/rust#144776; this is reachable after all. Fixes rust-lang/rust#144994. The commit also adds a lot more cases to the `type-name-basic.rs`, because it's currently very anaemic. This includes some cases where region omission does very badly; these are marked with FIXME. r? `@fmease`
2025-08-07Rollup merge of #144682 - nxsaken:strict_overflow_ops, r=Mark-SimulacrumStuart Cook-1/+1
Stabilize `strict_overflow_ops` Closes rust-lang/rust#118260
2025-08-07Reimplement `print_region` in `type_name.rs`.Nicholas Nethercote-1/+3
Broken by #144776; this is reachable after all. Fixes #144994. The commit also adds a lot more cases to the `type-name-basic.rs`, because it's currently very anaemic. This includes some cases where region omission does very badly; these are marked with FIXME.
2025-08-06Rename some `PrettyPrinter` methods.Nicholas Nethercote-2/+2
More consistency.
2025-08-06Rename some `Printer` methods.Nicholas Nethercote-5/+5
I find these name clearer, and starting them all with `print_` makes things more consistent.
2025-08-05Rename most of the printers.Nicholas Nethercote-5/+5
Three of them are named `AbsolutePathPrinter`, which is confusing, so give those names that better indicate how they are used. And then there is `SymbolPrinter` and `SymbolMangler`, which are renamed as `LegacySymbolMangler` and `V0SymbolMangler`, better indicating their similarity.
2025-08-05Rollup merge of #144890 - WaffleLapkin:project_fields, r=lcnrSamuel Tardieu-13/+22
Add `InterpCx::project_fields` I was hoping for a much bigger improvement and this is lukewarm at best ^^' Still, I think this makes sense.
2025-08-05Rollup merge of #144776 - nnethercote:Printer-cleanups, r=cjgillotSamuel Tardieu-25/+12
`Printer` cleanups The trait `Printer` is implemented by six types, and the sub-trait `PrettyPrinter` is implemented by three of those types. The traits and the impls are complex and a bit of a mess. This PR starts to clean them up. r? ``@davidtwco``
2025-08-04add `project_fields` helper functionWaffle Lapkin-13/+22
2025-08-04Rollup merge of #144706 - zachs18:fix-144661, r=RalfJungStuart Cook-2/+6
Do not give function allocations alignment in consteval and Miri. We do not yet have a (clear and T-lang approved) design for how `#[align(N)]` on functions should affect function pointers' addresses on various platforms, so for now do not give function pointers alignment in consteval and Miri. ---- Old summary: Not a full solution to <https://github.com/rust-lang/rust/issues/144661>, but fixes the immediate issue by making function allocations all have alignment 1 in consteval, ignoring `#[rustc_align(N)]`, so the compiler doesn't know if any offset other than 0 is non-null. A more "principlied" solution would probably be to make function pointers to `#[instruction_set(arm::t32)]` functions be at offset 1 of an align-`max(2, align attribute)` allocation instead of at offset 0 of their allocation during consteval, and on wasm to either disallow `#[align(N)]` where N > 1, or to pad the function table such that the function pointer of a `#[align(N)]` function is a multiple of `N` at runtime.
2025-08-03Remove unused arg from `path_append_impl`.Nicholas Nethercote-1/+0
None of the impls use it.
2025-08-03Rename `Printer` variables.Nicholas Nethercote-9/+10
Currently they are mostly named `cx`, which is a terrible name for a type that impls `Printer`/`PrettyPrinter`, and is easy to confuse with other types like `TyCtxt`. This commit changes them to `p`. A couple of existing `p` variables had to be renamed to make way.
2025-08-03Remove `type_name::AbsolutePathPrinter::comma_sep`.Nicholas Nethercote-14/+1
It's equivalent to the default `PrettyPrinter::comma_sep`.
2025-08-03Mark `Printer` methods as unreachable where appropriate.Nicholas Nethercote-1/+1
This helps me understand the structure of the code a lot. If any of these are actually reachable, we can put the old code back, add a new test case, and we will have improved our test coverage.
2025-08-01Update compiler/rustc_const_eval/src/interpret/memory.rs zachs18-1/+1
Replace commented-out code with link to context for change. Co-authored-by: Ralf Jung <post@ralfj.de>
2025-07-31Add EnteredTraceSpan::or_if_tracing_disabledStypox-10/+39
2025-07-31Add tracing to more functions related to step.rsStypox-1/+23
2025-07-31Add tracing calls to eval_statement/terminatorStypox-3/+18
2025-07-31Do not give function allocations alignment in consteval or miri.Zachary S-2/+6
2025-07-31Rollup merge of #144726 - jdonszelmann:move-attr-data-structures, r=lcnrJana Dönszelmann-11/+10
merge rustc_attr_data_structures into rustc_hir this move was discussed on zulip: [#t-compiler > attribute parsing rework @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/attribute.20parsing.20rework/near/528530091) Many PRs in the attribute rework depend on this move.
2025-07-31Make Miri's enter_trace_span! call const_eval'sStypox-4/+4
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-11/+10
2025-07-31Use specific name for "frame" span fieldStypox-1/+1
Otherwise the field would be named "message" by default
2025-07-31Use new enter_trace_span! syntax for layout_of & friendsStypox-3/+3
2025-07-31Uniform enter_trace_span! and add documentationStypox-4/+63
The macro was uniformed between rustc_const_eval and miri
2025-07-30Stabilize strict_overflow_opsNurzhan Sakén-1/+1
2025-07-30const-eval: full support for pointer fragmentsRalf Jung-86/+101
2025-07-28Rename trait_of_item -> trait_of_assocCameron Steffen-3/+3
2025-07-28Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLiibors-35/+32
Some `let chains` clean-up Not sure if this kind of clean-up is welcoming because of size, but I decided to try out one r? compiler
2025-07-28use let chains in ast, borrowck, codegen, const_evalKivooeo-35/+32
2025-07-27miri: for ABI mismatch errors, say which argument is the problemRalf Jung-12/+20
2025-07-23Remove const deduplication from the interpreter.Camille GILLOT-27/+3
2025-07-23Remove useless lifetime parameter.Camille GILLOT-11/+10
2025-07-23Give an AllocId to ConstValue::Slice.Camille GILLOT-13/+13
2025-07-23Rollup merge of #144256 - oli-obk:type-id-ice, r=RalfJungMatthias Krüger-1/+1
Don't ICE on non-TypeId metadata within TypeId fixes rust-lang/rust#144253 r? ``````````@RalfJung``````````
2025-07-21Don't ICE on non-TypeId metadata within TypeIdOli Scherer-1/+1
2025-07-20fix handling of base address for TypeId allocationsRalf Jung-16/+18
2025-07-19interpret: fix TypeId pointers being considered data pointersRalf Jung-6/+4
2025-07-18Rollup merge of #144123 - oli-obk:ctfe-unsize, r=RalfJungMatthias Krüger-3/+4
Generalize `unsize` and `unsize_into` destinations Just something that I noticed during other work. We do this for most such functions, so let's do it here, too. r? ``@RalfJung``
2025-07-18Rollup merge of #142673 - oli-obk:uninit-read-mem, r=RalfJungMatthias Krüger-8/+23
Show the offset, length and memory of uninit read errors r? ``@RalfJung`` I want to improve memory dumps in general. Not sure yet how to do so best within rust diagnostics, but in a perfect world I could generate a dummy in-memory file (that contains the rendered memory dump) that we then can then provide regular rustc `Span`s to. So we'd basically report normal diagnostics for them with squiggly lines and everything.
2025-07-18Generalize `unsize` and `unsize_into` destinationsOli Scherer-3/+4
2025-07-18Show the memory of uninit readsOli Scherer-7/+22