Switch inst namer to queue entities when reached (#5806)

This switches from the `CollectNamesInBlock` approach for entities, to
instead traversing entities as they're encountered. For example, when
traversing constants, when a type is found, the entity will have its
block queued for processing.

This leads to a change in the traversal order, which affects
disambiguation done by numeric sequencing (since that's just showing the
traversal order).

This will allow for simpler "name based on name" logic. This is
something I plan to use for:

- impls: `<type>.as.<interface>.impl`
- functions: `<entity>.<member function>`
  - Note an impl may be used as the entity for a bound function.

By naming the entities as they're encountered, I'll be able to rely on
the generated names rather than recalculating them.

To assist this, I'm also differentiating between the ambiguous and
disambiguated name. Otherwise, we could end up with things like
`<function>.<disambiguator>.<call>.<other disambiguator>`, where the
repeated disambiguator may not be necessary in order to get full
disambiguation. It's also a smaller delta from the current output.

Note, changing `Name` to a class felt appropriate given its shape. I was
also noticing that parts of its API were unused, and the class helps
detect unused private members.

---------

Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
Jon Ross-Perkins
2025-07-21 17:58:55 +00:00
committed by GitHub
co-authored by Geoff Romer
parent 9e9df7d14e
commit eae3491129
268 changed files with 8304 additions and 8270 deletions
@@ -198,7 +198,7 @@ fn F() {
// CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
// CHECK:STDOUT: %Op.type.642: type = fn_type @Op.2, @Destroy.impl(%S) [concrete]
// CHECK:STDOUT: %Op.type.642: type = fn_type @Op.1, @Destroy.impl(%S) [concrete]
// CHECK:STDOUT: %Op.ab5: %Op.type.642 = struct_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -259,9 +259,9 @@ fn F() {
// CHECK:STDOUT: %ptr.dfe: type = ptr_type %ptr.5c7 [concrete]
// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
// CHECK:STDOUT: %Op.type.c07: type = fn_type @Op.2, @Destroy.impl(%ptr.5c7) [concrete]
// CHECK:STDOUT: %Op.type.c07: type = fn_type @Op.1, @Destroy.impl(%ptr.5c7) [concrete]
// CHECK:STDOUT: %Op.64b: %Op.type.c07 = struct_value () [concrete]
// CHECK:STDOUT: %Op.type.642: type = fn_type @Op.2, @Destroy.impl(%S) [concrete]
// CHECK:STDOUT: %Op.type.642: type = fn_type @Op.1, @Destroy.impl(%S) [concrete]
// CHECK:STDOUT: %Op.ab5: %Op.type.642 = struct_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -340,7 +340,7 @@ fn F() {
// CHECK:STDOUT: %ptr.ff5: type = ptr_type %const [concrete]
// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
// CHECK:STDOUT: %Op.type.372: type = fn_type @Op.2, @Destroy.impl(%const) [concrete]
// CHECK:STDOUT: %Op.type.372: type = fn_type @Op.1, @Destroy.impl(%const) [concrete]
// CHECK:STDOUT: %Op.af7: %Op.type.372 = struct_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -529,7 +529,7 @@ fn F() {
// CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
// CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
// CHECK:STDOUT: %ptr.5c7: type = ptr_type %S [concrete]
// CHECK:STDOUT: %Op.type.642: type = fn_type @Op.2, @Destroy.impl(%S) [concrete]
// CHECK:STDOUT: %Op.type.642: type = fn_type @Op.1, @Destroy.impl(%S) [concrete]
// CHECK:STDOUT: %Op.ab5: %Op.type.642 = struct_value () [concrete]
// CHECK:STDOUT: }
// CHECK:STDOUT: