Commit Graph

753 Commits

Author SHA1 Message Date
bjorn3
0417c4e028 Add comments
Co-authored-by: Ralf Jung <post@ralfj.de>
2026-08-13 14:20:02 +02:00
bjorn3
12ac752844 Don't compute FnAbi for LLVM intrinsics 2026-08-13 14:20:02 +02:00
Marcelo Dominguez
4227e93fd2 Some fixes and error when missing manifest 2026-08-12 18:06:07 +03:00
Marcelo Dominguez
55c63da345 Add tests remove extra mode and other fixes 2026-08-12 18:06:07 +03:00
Marcelo Dominguez
30dd3d499b minor fixes 2026-08-12 18:06:07 +03:00
Marcelo Dominguez
3daa8b3c70 fix 2026-08-12 18:06:07 +03:00
Marcelo Dominguez
a5a9f8cf4f Remove codegen and move manifest out of query 2026-08-12 18:06:07 +03:00
Marcelo Dominguez
4d52fe93a2 Add 3-pass compilation to support generics and remove no_mangle attr 2026-08-12 18:06:00 +03:00
Chris Denton
4641990929 Remove ensure_sufficient_stack 2026-08-09 19:58:29 +00:00
mejrs
196dd2a174 Fix up lang_items import paths 2026-08-09 15:20:29 +02:00
Ralf Jung
8bb9f279a9 refactor handling of target features in Session 2026-08-06 14:45:53 +02:00
Nicholas Nethercote
ff161b18b5 Many "predicate"-to-"clause" renamings
Lots of names weren't changed to account for the introduction of the
`Clause` type as a specialized form of `Predicate`, presumably because
it was tedious. This commit converts as many of them as I could find.
It's mostly very tedious renamings of types, functions, variables, and
queries. The more interesting ones are a couple of files
(`predicates_of.rs`, `impossible_predicates.rs`) and a MIR pass
(`ImpossiblePredicates`).
2026-07-28 11:48:45 +10:00
Jonathan Brouwer
e51da70906 Rollup merge of #159777 - oli-obk:really-comptime-this-time, r=fmease
Enforce that we don't generate code for comptime fns

... by ICEing if you try to compute a symbol for them. There are various other ways we can assert it, but they were all a bit icky or already unreachable.

r? @fmease (since you asked about it in https://github.com/rust-lang/rust/pull/159727#discussion_r3636421134)
2026-07-27 19:24:42 +02:00
Oli Scherer
574ee122de Don't codegen comptime fns 2026-07-27 17:18:00 +02:00
Jacob Pratt
0e238fd6c3 Rollup merge of #138618 - nbdd0121:asm_const_ptr, r=bjorn3
Support using const pointers in asm `const` operand

Implements [RFC#3848](https://github.com/rust-lang/rfcs/pull/3848) with tracking issue rust-lang/rust#128464

This adds support of const pointers for asm `const` in addition to plain integers.

The inline `asm!` support is implemented using `i` constraint, and the `global_asm!` and `naked_asm!` support is implemented by inserting `symbol + offset` and make `symbol` compiler-used. For unnamed consts, it will create additional internal & hidden symbols so that they can be referenced by global_asm.

~~The feature is also implemented for GCC backend but it's untested.~~ Tested now.
2026-07-26 00:21:39 -04:00
Gary Guo
1fd34e44be Give codegen units symbol names that backend can use 2026-07-22 14:34:42 +01:00
Gary Guo
4233b3bd13 Collect constants within global_asm! in collector
This is currently a no-op, but will be useful when const in `global_asm!`
can be pointers.
2026-07-22 13:47:31 +01:00
mejrs
ac91844c53 Fixup Limit imports 2026-07-21 15:26:08 +02:00
Jonathan Brouwer
09e4f79388 Rollup merge of #159183 - bjorn3:instance_llvm_intrinsic, r=RalfJung,folkertdev
Introduce InstanceKind::LlvmIntrinsic

This way codegen backends don't have to check for a magic symbol name prefix to detect LLVM intrinsic calls and thus can more easily handle them separately as necessary.
2026-07-14 16:49:04 +02:00
Jonathan Brouwer
1b6842fbd2 Rollup merge of #158723 - AsakuraMizu:windows-msvc-eii, r=bjorn3
Support EII on Windows MSVC

Tracking issue: rust-lang/rust#125418

The previous PR rust-lang/rust#158294 made function EIIs work on Windows MSVC. This PR fixes support for static EIIs, enabling full EII support on Windows MSVC.

The following fixes are included:
- Keep EII statics out of LLVM internalization
- Mark EII static symbols as `dllimport`
- Emit MSVC `__imp_<symbol>` stubs for aliases to static data

Note: `LLVMAddAlias2` was incorrectly declared in the `llvm-wrapper` extern block previously.
2026-07-14 16:49:01 +02:00
bjorn3
8c2ed2f9a1 Introduce InstanceKind::LlvmIntrinsic
This way codegen backends don't have to check for a magic symbol name
prefix to detect LLVM intrinsic calls and thus can more easily handle
them separately as necessary.
2026-07-13 14:20:37 +00:00
addie.sh
8fb83aba33 place FnDef behind a binder, instantiate w/ Dummy 2026-07-10 14:53:35 -04:00
朝倉水希
cb0ba93c85 Support EII on Windows MSVC 2026-07-10 14:03:28 +08:00
Jacob Pratt
91fc16bab6 Rollup merge of #158796 - raushan728:issues/154044, r=saethlin
Distinguish null reference production from null pointer dereference in UB checks

Closes rust-lang/rust#154044

This change distinguishes null reference production from actual null pointer dereferences in the UB checks.

Producing a reference from a null pointer (for example, `&*ptr`) is undefined behavior even if no memory is dereferenced. This change introduces a dedicated `AssertKind::NullReferenceConstructed` and runtime panic so these cases produce a more accurate diagnostic while preserving the existing panic for actual null pointer dereferences.

Summary
- Add `AssertKind::NullReferenceConstructed`.
- Emit it for null reference production in the MIR null check pass.
- Add `panic_null_reference_constructed` and its lang item.
- Keep `NullPointerDereference` for actual dereferences.
- Update the affected UI tests.
2026-07-06 22:17:40 -04:00
Raushan kumar
1a982425b6 Distinguish null reference production from null pointer dereference
Introduce a dedicated panic for null reference production to distinguish
producing a reference from a null pointer from an actual null pointer
dereference.

This emits a dedicated panic message for null reference production while
preserving the existing panic for actual dereferences.
2026-07-05 17:09:30 +00:00
Folkert de Vries
6810f13f1d add -Zforce-intrinsic-fallback flag 2026-07-05 15:32:49 +02:00
Adwin White
3dbe96a5a1 add IsRigid marker to TyKind::Alias and constants 2026-06-25 17:12:10 +08:00
Noah Lev
c329a0e6c9 Strip vestigial Shim suffix from ShimKind variants 2026-06-22 19:29:17 +00:00
Noah Lev
0eb146cbab Extract all instance shim variants into new ShimKind enum
They tend to have similar handling -- e.g., they should be the only
input to the `mir_shims` query -- so it's cleaner to group them
together. This will also make potential future refactorings easier, such
as only carrying `GenericArgsRef` for instances that actually use it
(e.g., `Item`) but not others (e.g., `CloneShim`).

Many of the shim variants still have `Shim` at the end of their names.
To make the refactoring easier and keep the diff clean, I will trim
those suffixes off in the next commit.
2026-06-22 19:28:42 +00:00
Guillaume Gomez
9dcf73ac44 Rename rustc_hir_monomorphize/src/errors.rs into rustc_hir_monomorphize/src/diagnostics.rs 2026-06-12 12:40:08 +02:00
Jacob Pratt
0831b34e2e Rollup merge of #157282 - xmakro:fix/parallel-pme-note, r=petrochenkov
Fix post-monomorphization error note race in the parallel frontend

Fixes rust-lang/rust#154260. Part of https://github.com/rust-lang/rust/issues/154314.

`collect_items_rec` decides whether to attach the note "the above error was encountered while instantiating `fn ...`" by snapshotting the error count before processing a mono item and comparing it afterwards. The mono item graph is walked in parallel (the `par_for_each_in` in `collect_crate_mono_items`), so the global error count can be bumped by an error emitted while collecting a different item on another thread between the two reads. That makes an unrelated item get blamed, which showed up as a spurious note when using parallel frontend:

```
note: the above error was encountered while instantiating `fn std::rt::lang_start::<()>`
```

This PR records the thread that emits each error alongside its `ErrorGuaranteed` in `err_guars`, `lint_err_guars`, and the stashed-diagnostics map, and add `err_count_on_current_thread`, which counts only the errors whose recorded thread is the calling thread. The collector uses it for the snapshot and comparison, so the delta is not affected by errors emitted on other threads. In serial compilation it is equivalent to a delta of `err_count`.
2026-06-11 00:34:00 -04:00
xmakro
c1cd23675f Attribute post-monomorphization error notes by emitting thread 2026-06-05 09:52:21 -07:00
Alex Crichton
c668b83eed Use a ArrayVec in CastTarget
This commit switches a fixed-size list of `[Option<Reg>; 8]` to instead
holding `ArrayVec<Reg, 8>` in the `CastTarget` type used when
calculating ABIs. This is inspired by [discussion on Zulip][link] where
I'm hoping to in the near future extend the usage of this to possibly
beyond 8 elements for a new WebAssembly ABI taking advantage of
multi-value. For now though this mostly just switches to
array/slice-like idioms of accessors rather than dealing with
`Option<Reg>` as the unit.

[link]: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Using.20.60ArgAbi.3A.3Amake_direct_deprecated.60/with/598607139
2026-06-01 07:34:12 -07:00
Camille Gillot
20d113eff1 Drop skip_move_check_fns query. 2026-05-24 12:19:59 +00:00
lcnr
3fb166fb6f tiny PR 2026-05-12 21:58:50 +02:00
Waffle Lapkin
810eae99af rename drop_in_place lang item to drop_glue 2026-05-05 12:36:39 +02:00
bors
9ab01ae53c Auto merge of #155491 - ohadravid:faster-storage-in-copyprop-and-gvn, r=saethlin
Fix performance regression introduced in #142531 by excluding `Storage{Live,Dead}` from CGU size estimation



Fix performance regression introduced in rust-lang/rust#142531 ([rust-timer comment](https://github.com/rust-lang/rust/pull/142531#issuecomment-4273712294)) by excluding `Storage{Live,Dead}` from CGU size estimation.

Also, avoid unneeded work for storage removal in non-opt builds in CopyProp and GVN
by allocating local sets for the storage accounting only when `tcx.sess.emit_lifetime_markers()`. 

r? saethlin
2026-04-21 05:35:16 +00:00
bors
c28e303778 Auto merge of #155552 - JonathanBrouwer:rollup-JKIpTuW, r=JonathanBrouwer
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#154654 (Move `std::io::ErrorKind` to `core::io`)
 - rust-lang/rust#145270 (Fix an ICE observed with an explicit tail-call in a default trait method)
 - rust-lang/rust#154895 (borrowck: Apply `user_arg_index` nomenclature more broadly)
 - rust-lang/rust#155213 (resolve: Make sure visibilities of import declarations make sense)
 - rust-lang/rust#155346 (`single_use_lifetimes`: respect `anonymous_lifetime_in_impl_trait`)
 - rust-lang/rust#155517 (Add a test for Mach-O `#[link_section]` API inherited from LLVM)
 - rust-lang/rust#155549 (Remove some unnecessary lifetimes.)
 - rust-lang/rust#154248 (resolve :  mark repr_simd as internal)
 - rust-lang/rust#154772 (slightly optimize the `non-camel-case-types` lint)
 - rust-lang/rust#155541 (Add `#[rust_analyzer::prefer_underscore_import]` to the traits in `rustc_type_ir::inherent`)
 - rust-lang/rust#155544 (bootstrap: Make "detected modifications" for download-rustc less verbose)
2026-04-20 16:15:13 +00:00
Nicholas Nethercote
5e00b8e7d5 Remove some unnecessary lifetimes.
We have a number of structs with more lifetimes than necessary. This
commit removes them.

LLM disclosure: I asked Claude Code to check for unnecessary lifetimes
in all types with three or more lifetimes, and it produced a list of
candidates (half of which were invalid). I did the modifications for the
valid cases myself, and found a couple more cases along the way.
2026-04-20 19:25:51 +10:00
Jonathan Brouwer
cccf996225 Rollup merge of #155264 - sayantn:amx-autocast, r=dianqk
Add autocast support for `x86amx`

Builds on rust-lang/rust#140763 by further adding autocasts for `x86amx` from/to vectors of size 8192 bits.

This also disables SIMD vector abi checks for the `"unadjusted"` abi because
 - This is primarily used to link with LLVM intrinsics, which don't actually lower to function calls with vector arguments. Even with other cg backends, this is true.
 - This ABI is internal and perma-unstable (and also super specific), so it is very unlikely that this will cause breakages.
 - (The primary reason) Without doing this we can't actually use 8192 bit long vectors to represent `x86amx`

> Why do we need a bypass for `x86amx`? Can't we use a `#[lang_item]` or something?

If `x86amx` was a normal LLVM type, this approach would've worked and I would also prefer it. But LLVM specifies that

> No instruction is allowed for this type. There are no arguments, arrays, pointers, vectors or constants of this type.

So we can't treat it like a normal type at all -- even if we add it like a lang-item, we would still have to special-case everywhere to check if we are passing to the correct LLVM intrinsic, and only then use the `x86amx` type. IMO this is needlessly complex, and way worse than this solution, which just adds it to the autocast list in cg_llvm

r? codegen
2026-04-20 08:14:10 +02:00
Adwin White
6279106e72 fix all errors 2026-04-20 00:18:28 +08:00
Ohad Ravid
846974e1b0 Don't count storage statements in size_estimate query 2026-04-19 11:05:17 +03:00
sayantn
1a28bc4529 Disable ABI checks for the unadjusted ABI 2026-04-14 03:25:02 +05:30
Folkert de Vries
6f428df8df preseve SIMD element type information
and provide it to LLVM for better optimization
2026-04-13 13:26:50 +02:00
Nicholas Nethercote
3ff4201fd1 Move rustc_middle::mir::mono to rustc_middle::mono
Because the things in this module aren't MIR and don't use anything
from `rustc_middle::mir`. Also, modules that use `mono` often don't use
anything else from `rustc_middle::mir`.
2026-04-07 08:33:54 +10:00
Nicholas Nethercote
ff1795fe49 Remove Clone impl for StableHashingContext.
`HashStable::hash_stable` takes a `&mut Hcx`. In contrast,
`ToStableHashKey::to_stable_hash_key` takes a `&Hcx`. But there are
some places where the latter calls the former, and due to the mismatch a
`clone` call is required to get a mutable `StableHashingContext`.

This commit changes `to_stable_hash_key` to instead take a `&mut Hcx`.
This eliminates the mismatch, the need for the clones, and the need for
the `Clone` impls.
2026-04-03 15:34:33 +11:00
Daria Sukhonina
1b68d921a7 Add typeck_root_def_id_local 2026-03-27 15:36:28 +03:00
John Kåre Alsaker
bee28ef7b2 Remove MTLock 2026-03-12 14:37:51 +01:00
Jonathan Brouwer
707bf0961a Rollup merge of #152569 - oli-obk:rustc_layout_scalar_valid_range_end_end, r=davidtwco
Stop using rustc_layout_scalar_valid_range_* in rustc

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152569)*

Another step towards rust-lang/rust#135996

Required some manual impls, but we already do many manual impls for the newtype_index types, so it's not really a new maintenance burden.
2026-03-11 22:05:41 +01:00
bors
b2fabe39bd Auto merge of #153673 - JonathanBrouwer:rollup-cGOKonI, r=JonathanBrouwer
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#153560 (Introduce granular tidy_ctx's check in extra_checks)
 - rust-lang/rust#153666 (Add a regression test for rust-lang/rust#153599)
 - rust-lang/rust#153493 (Remove `FromCycleError` trait)
 - rust-lang/rust#153549 (tests/ui/binop: add annotations for reference rules)
 - rust-lang/rust#153641 (Move `Spanned`.)
 - rust-lang/rust#153663 (Remove `TyCtxt::node_lint` method and `rustc_middle::lint_level` function)
 - rust-lang/rust#153664 (Add test for rust-lang/rust#109804)
2026-03-11 05:12:10 +00:00