summary refs log tree commit diff
path: root/compiler/rustc_monomorphize/src
AgeCommit message (Collapse)AuthorLines
2024-08-29Add `warn(unreachable_pub)` to `rustc_monomorphize`.Nicholas Nethercote-17/+22
2024-08-26Stop using a special inner body for the coroutine by-move body for async ↵Michael Goulet-4/+1
closures
2024-08-25Avoid taking reference of &TyKindMichael Goulet-2/+2
2024-08-21Use bool in favor of Option<()> for diagnosticsMichael Goulet-3/+3
2024-08-19Don't generate functions with the `rustc_intrinsic_must_be_overridden` attributeDianQK-1/+3
2024-08-15Rollup merge of #129067 - cuviper:append, r=wesleywiserMatthias Krüger-2/+2
Use `append` instead of `extend(drain(..))` The first commit adds `IndexVec::append` that forwards to `Vec::append`, and uses it in a couple places. The second commit updates `indexmap` for its new `IndexMap::append`, and also uses that in a couple places. These changes are similar to what [`clippy::extend_with_drain`](https://rust-lang.github.io/rust-clippy/master/index.html#/extend_with_drain) would suggest, just for other collection types.
2024-08-13Update `indexmap` and use `IndexMap::append`Josh Stone-2/+2
2024-08-13Use is_lang_item moreMichael Goulet-1/+3
2024-08-08Rename struct_tail_erasing_lifetimes to struct_tail_for_codegenMichael Goulet-2/+2
2024-08-01MIR required_consts, mentioned_items: ensure we do not forget to fill these ↵Ralf Jung-2/+2
lists
2024-07-29Reformat `use` declarations.Nicholas Nethercote-25/+21
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28stabilize `is_sorted`Slanterns-1/+0
2024-07-15Move compiler_builtin check to the use caseMohammad Omidvar-32/+0
2024-07-15Use the hook on tcx instead of the local functionMohammad Omidvar-26/+18
2024-07-15Introduce and provide a hook for `should_codegen_locally`Mohammad Omidvar-4/+18
2024-07-08Auto merge of #113128 - WaffleLapkin:become_trully_unuwuable, r=oli-obk,RalfJungbors-1/+2
Support tail calls in mir via `TerminatorKind::TailCall` This is one of the interesting bits in tail call implementation — MIR support. This adds a new `TerminatorKind` which represents a tail call: ```rust TailCall { func: Operand<'tcx>, args: Vec<Operand<'tcx>>, fn_span: Span, }, ``` *Structurally* this is very similar to a normal `Call` but is missing a few fields: - `destination` — tail calls don't write to destination, instead they pass caller's destination to the callee (such that eventual `return` will write to the caller of the function that used tail call) - `target` — similarly to `destination` tail calls pass the caller's return address to the callee, so there is nothing to do - `unwind` — I _think_ this is applicable too, although it's a bit confusing - `call_source` — `become` forbids operators and is not created as a lowering of something else; tail calls always come from HIR (at least for now) It might be helpful to read the interpreter implementation to understand what `TailCall` means exactly, although I've tried documenting it too. ----- There are a few `FIXME`-questions still left, ideally we'd be able to answer them during review ':) ----- r? `@oli-obk` cc `@scottmcm` `@DrMeepster` `@JakobDegen`
2024-07-07Support tail calls in mir via `TerminatorKind::TailCall`Maybe Waffle-1/+2
2024-07-04Auto merge of #123781 - RalfJung:miri-fn-identity, r=oli-obkbors-4/+4
Miri function identity hack: account for possible inlining Having a non-lifetime generic is not the only reason a function can be duplicated. Another possibility is that the function may be eligible for cross-crate inlining. So also take into account the inlining attribute in this Miri hack for function pointer identity. That said, `cross_crate_inlinable` will still sometimes return true even for `inline(never)` functions: - when they are `DefKind::Ctor(..) | DefKind::Closure` -- I assume those cannot be `InlineAttr::Never` anyway? - when `cross_crate_inline_threshold == InliningThreshold::Always` so maybe this is still not quite the right criterion to use for function pointer identity.
2024-07-02Fix spansMichael Goulet-17/+7
2024-07-02Re-implement a type-size based limitMichael Goulet-79/+3
2024-07-02Give Instance::expect_resolve a spanMichael Goulet-4/+16
2024-07-02Miri function identity hack: account for possible inliningRalf Jung-4/+4
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-2/+2
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-16Rename InstanceDef -> InstanceKindMichael Goulet-53/+53
2024-06-15Rollup merge of #126410 - RalfJung:smir-const-operand, r=oli-obkGuillaume Gomez-2/+2
smir: merge identical Constant and ConstOperand types The first commit renames the const operand visitor functions on regular MIR to match the type name, that was forgotten in the original rename. The second commit changes stable MIR, fixing https://github.com/rust-lang/project-stable-mir/issues/71. Previously there were two different smir types for the MIR type `ConstOperand`, one used in `Operand` and one in `VarDebugInfoContents`. Maybe we should have done this with https://github.com/rust-lang/rust/pull/125967, so there's only a single breaking change... but I saw that PR too late. Fixes https://github.com/rust-lang/project-stable-mir/issues/71
2024-06-14Use is_lang_item more aggressivelyMichael Goulet-2/+3
2024-06-14Add TyCtxt::is_lang_itemMichael Goulet-1/+1
2024-06-13MIR visitor: constant -> const_operandRalf Jung-2/+2
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-0/+2
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-06-07Auto merge of #125928 - michaelwoerister:fix-cgu-hashstable, r=oli-obkbors-47/+56
Stabilize order of MonoItems in CGUs and disallow query_instability lint for rustc_monomorphize The HashStable impl for `CodegenUnit` was incorrect as described in [MCP 533](https://github.com/rust-lang/compiler-team/issues/533). This PR removes any indeterminism from the way codegen units are built. The changes are pretty straightforward. Part of https://github.com/rust-lang/rust/issues/84447 and [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).
2024-06-05Add `Ty` to `mir::Const::Ty`Boxy-1/+1
2024-06-03Stabilize order of MonoItems in CGUs and disallow query_instability lint for ↵Michael Woerister-47/+56
rustc_monomorphize
2024-05-24Don't eagerly monomorphize drop for types that are impossible to instantiateMichael Goulet-0/+9
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_monomorphize`.Nicholas Nethercote-3/+4
2024-05-19Add and use generics.is_empty() and generics.is_own_empty, rather than using ↵Santiago Pastorino-2/+2
generics' attributes
2024-05-10Lift `TraitRef` into `rustc_type_ir`Michael Goulet-3/+2
2024-05-09Rename Generics::params to Generics::own_paramsMichael Goulet-3/+3
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-2/+3
2024-04-17Use non-exhaustive matches for TyKindDaria Sukhonina-3/+4
Also no longer export noop async_drop_in_place_raw
2024-04-16Add simple async drop glue generationzetanumbers-2/+6
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801
2024-04-14move the LargeAssignments lint logic into its own fileRalf Jung-140/+161
2024-04-07Only collect mono items from reachable blocksBen Kimock-9/+11
2024-04-01Only allow upstream calls to LLVM intrinsics, not any link_name functionBen Kimock-2/+14
2024-03-29Auto merge of #122671 - Mark-Simulacrum:const-panic-msg, r=Nilstriebbors-10/+11
Codegen const panic messages as function calls This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting shared library (see [perf]). A sample improvement from nightly: ``` leaq str.0(%rip), %rdi leaq .Lalloc_d6aeb8e2aa19de39a7f0e861c998af13(%rip), %rdx movl $25, %esi callq *_ZN4core9panicking5panic17h17cabb89c5bcc999E@GOTPCREL(%rip) ``` to this PR: ``` leaq .Lalloc_d6aeb8e2aa19de39a7f0e861c998af13(%rip), %rdi callq *_RNvNtNtCsduqIKoij8JB_4core9panicking11panic_const23panic_const_div_by_zero@GOTPCREL(%rip) ``` [perf]: https://perf.rust-lang.org/compare.html?start=a7e4de13c1785819f4d61da41f6704ed69d5f203&end=64fbb4f0b2d621ff46d559d1e9f5ad89a8d7789b&stat=instructions:u
2024-03-25Instance is CopyMichael Goulet-20/+20
2024-03-22Auto merge of #122852 - compiler-errors:raw-ptr, r=lcnrbors-4/+2
Remove `TypeAndMut` from `ty::RawPtr` variant, make it take `Ty` and `Mutability` Pretty much mechanically converting `ty::RawPtr(ty::TypeAndMut { ty, mutbl })` to `ty::RawPtr(ty, mutbl)` and its fallout. r? lcnr cc rust-lang/types-team#124
2024-03-22Auto merge of #122580 - saethlin:compiler-builtins-can-panic, r=pnkfelixbors-1/+23
"Handle" calls to upstream monomorphizations in compiler_builtins This is pretty cooked, but I think it works. compiler-builtins has a long-standing problem that at link time, its rlib cannot contain any calls to `core`. And yet, in codegen we _love_ inserting calls to symbols in `core`, generally from various panic entrypoints. I intend this PR to attack that problem as completely as possible. When we generate a function call, we now check if we are generating a function call from `compiler_builtins` and whether the callee is a function which was not lowered in the current crate, meaning we will have to link to it. If those conditions are met, actually generating the call is asking for a linker error. So we don't. If the callee diverges, we lower to an abort with the same behavior as `core::intrinsics::abort`. If the callee does not diverge, we produce an error. This means that compiler-builtins can contain panics, but they'll SIGILL instead of panicking. I made non-diverging calls a compile error because I'm guessing that they'd mostly get into compiler-builtins by someone making a mistake while working on the crate, and compile errors are better than linker errors. We could turn such calls into aborts as well if that's preferred.
2024-03-22Programmatically convert some of the pat ctorsMichael Goulet-4/+2
2024-03-22Codegen const panic messages as function callsMark Rousskov-10/+11
This skips emitting extra arguments at every callsite (of which there can be many). For a librustc_driver build with overflow checks enabled, this cuts 0.7MB from the resulting binary.
2024-03-21rename items -> free_itemsRalf Jung-1/+1