ExprCategory for guaranteed-in-place initializing expressions (#6623)

The primary change in this PR is to split the `Initializing` expression
category into separate `ReprInitializing` and `InPlaceInitializing`
categories, depending on whether initialization uses the types
initializing representation, or is guaranteed to be in place. It also
rationalizes and documents the SemIR-level semantics of those categories
(including where #5545's "ephemeral entire reference" category will
fit), and introduces two new inst kinds to close gaps exposed in the
process.

Some additional secondary changes:
- Consistently format the storage arguments of initializers with `to`,
regardless of whether initialization is in-place, and document the `to`
notation.
- Rename some inst kinds and functions, and restructure some of the
code, for clarity and consistency with the new documentation.
- Resolve a TODO to handle more category conversions in
`CategoryConverter`, in order to make it easier to reason about category
conversions.

See #6588 and the review history of this PR for background.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Geoff Romer
2026-02-04 02:27:12 +00:00
committed by GitHub
co-authored by Richard Smith
parent 2980e6bcbb
commit e5b05a1fac
127 changed files with 1352 additions and 926 deletions
@@ -154,7 +154,7 @@ fn StarstWith(a: str, b: str) -> bool {
// CHECK:STDOUT: %.loc13_11.1: ref %str.ee0 = splice_block %return.param {}
// CHECK:STDOUT: %addr: %ptr.85f = addr_of %.loc13_11.1
// CHECK:STDOUT: %Produce__carbon_thunk.call: init %empty_tuple.type = call imports.%Produce__carbon_thunk.decl(%addr)
// CHECK:STDOUT: %.loc14: init %str.ee0 to %.loc13_11.1 = in_place_init %Produce__carbon_thunk.call
// CHECK:STDOUT: %.loc14: init %str.ee0 to %.loc13_11.1 = mark_in_place_init %Produce__carbon_thunk.call
// CHECK:STDOUT: return %.loc14 to %return.param
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -228,7 +228,7 @@ fn StarstWith(a: str, b: str) -> bool {
// CHECK:STDOUT: %.loc8_53.1: ref bool = temporary_storage
// CHECK:STDOUT: %addr.loc8_53.2: %ptr.bb2 = addr_of %.loc8_53.1
// CHECK:STDOUT: %starts_with__carbon_thunk.call: init %empty_tuple.type = call imports.%starts_with__carbon_thunk.decl(%a.ref, %addr.loc8_53.1, %addr.loc8_53.2)
// CHECK:STDOUT: %.loc8_53.2: init bool = in_place_init %starts_with__carbon_thunk.call, %.loc8_53.1
// CHECK:STDOUT: %.loc8_53.2: init bool to %.loc8_53.1 = mark_in_place_init %starts_with__carbon_thunk.call
// CHECK:STDOUT: return %.loc8_53.2
// CHECK:STDOUT: }
// CHECK:STDOUT: