rust/compiler/rustc_middle/src/query
Matthias Krüger accf61dd42
Rollup merge of #143293 - folkertdev:naked-function-kcfi, r=compiler-errors
fix `-Zsanitizer=kcfi` on `#[naked]` functions

fixes https://github.com/rust-lang/rust/issues/143266

With `-Zsanitizer=kcfi`, indirect calls happen via generated intermediate shim that forwards the call. The generated shim preserves the attributes of the original, including `#[unsafe(naked)]`. The shim is not a naked function though, and violates its invariants (like having a body that consists of a single `naked_asm!` call).

My fix here is to match on the `InstanceKind`, and only use `codegen_naked_asm` when the instance is not a `ReifyShim`. That does beg the question whether there are other `InstanceKind`s that could come up. As far as I can tell the answer is no: calling via `dyn` seems to work find, and `#[track_caller]` is disallowed in combination with `#[naked]`.

r? codegen
````@rustbot```` label +A-naked
cc ````@maurer```` ````@rcvalle````
2025-07-18 04:27:51 +02:00
..
arena_cached.rs Allow arena_cache queries to return Option<&'tcx T> 2025-01-23 13:25:37 +11:00
erase.rs inherit #[align] from trait method prototypes 2025-06-29 17:22:45 +02:00
keys.rs trait_sel: {Meta,Pointee}Sized on ?Sized types 2025-06-16 15:00:22 +00:00
mod.rs Rollup merge of #143293 - folkertdev:naked-function-kcfi, r=compiler-errors 2025-07-18 04:27:51 +02:00
on_disk_cache.rs Introduce ByteSymbol. 2025-06-30 20:42:27 +10:00
plumbing.rs Reformat parameters to macros used by with-all-queries 2025-04-29 20:48:51 +10:00