Avoid recursion in InstNamer::CollectNamesInBlock (#4706)

Use a deque to maintain the set of instructions to be walked over. so
that the loop can append more instructions (with their related scope)
during iteration without requiring recursion.

---------

Co-authored-by: jonmeow <jperkins@google.com>
This commit is contained in:
Dana Jansens
2024-12-20 16:12:06 +00:00
committed by GitHub
co-authored by jonmeow
parent aca862ceff
commit 6cb660f5ad
92 changed files with 974 additions and 955 deletions
+3 -3
View File
@@ -820,12 +820,12 @@ fn CallImplicitNotDeducible() {
// CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
// CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_15.2 (constants.%T)]
// CHECK:STDOUT: %x.param: @TupleParam.%tuple.type (%tuple.type.2) = value_param runtime_param0
// CHECK:STDOUT: %.loc4_35.3: type = splice_block %.loc4_35.2 [symbolic = %tuple.type (constants.%tuple.type.2)] {
// CHECK:STDOUT: %.loc4_35.1: type = splice_block %.loc4_35.3 [symbolic = %tuple.type (constants.%tuple.type.2)] {
// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_15.1 [symbolic = %T.loc4_15.2 (constants.%T)]
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
// CHECK:STDOUT: %.loc4_35.1: %tuple.type.1 = tuple_literal (%T.ref, %i32)
// CHECK:STDOUT: %.loc4_35.2: type = converted %.loc4_35.1, constants.%tuple.type.2 [symbolic = %tuple.type (constants.%tuple.type.2)]
// CHECK:STDOUT: %.loc4_35.2: %tuple.type.1 = tuple_literal (%T.ref, %i32)
// CHECK:STDOUT: %.loc4_35.3: type = converted %.loc4_35.2, constants.%tuple.type.2 [symbolic = %tuple.type (constants.%tuple.type.2)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %x: @TupleParam.%tuple.type (%tuple.type.2) = bind_name x, %x.param
// CHECK:STDOUT: }
@@ -75,12 +75,12 @@ fn CallNegative() {
// CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt.loc4_19.1, runtime_param<invalid> [symbolic = %N.patt.loc4_19.2 (constants.%N.patt)]
// CHECK:STDOUT: } {
// CHECK:STDOUT: %N.param: Core.IntLiteral = value_param runtime_param<invalid>
// CHECK:STDOUT: %.loc4_39.3: type = splice_block %.loc4_39.2 [template = Core.IntLiteral] {
// CHECK:STDOUT: %.loc4_39.1: type = splice_block %.loc4_39.3 [template = Core.IntLiteral] {
// CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
// CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, imports.%import_ref.1 [template = constants.%IntLiteral]
// CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
// CHECK:STDOUT: %.loc4_39.1: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
// CHECK:STDOUT: %.loc4_39.2: type = converted %int_literal.make_type, %.loc4_39.1 [template = Core.IntLiteral]
// CHECK:STDOUT: %.loc4_39.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
// CHECK:STDOUT: %.loc4_39.3: type = converted %int_literal.make_type, %.loc4_39.2 [template = Core.IntLiteral]
// CHECK:STDOUT: }
// CHECK:STDOUT: %N.loc4_19.1: Core.IntLiteral = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc4_19.2 (constants.%N)]
// CHECK:STDOUT: }