mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Tag destruction as desugaring (#5790)
In `BuildUnaryOperator`, `GetOperatorOpFunction` is treated as desugaring, but `PerformCompoundMemberAccess` and `PerformCall` are not. This treats all of destruction as desugaring. This leads to some instructions being elided, because of `GetOrAddInst` behaviors: > // If the instruction has a desugared location and a constant value, returns > // the constant value's instruction ID. Otherwise, same as AddInst. This changes instructions that previously had a non-desugared location to instead have a desugared location, so if they also have a constant value then the constant value can be used directly.
This commit is contained in:
+8
-19
@@ -212,16 +212,9 @@ fn CallFAndGIncomplete() {
|
||||
// CHECK:STDOUT: %ReturnDUsed.type: type = fn_type @ReturnDUsed [concrete]
|
||||
// CHECK:STDOUT: %ReturnDUsed: %ReturnDUsed.type = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
|
||||
// CHECK:STDOUT: %Op.type.bae: type = fn_type @Op.1 [concrete]
|
||||
// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
|
||||
// CHECK:STDOUT: %Op.type.bc9: type = fn_type @Op.2, @impl(%T) [symbolic]
|
||||
// CHECK:STDOUT: %Op.46f: %Op.type.bc9 = struct_value () [symbolic]
|
||||
// CHECK:STDOUT: %Destroy.impl_witness.45e: <witness> = impl_witness imports.%Destroy.impl_witness_table, @impl(%D) [concrete]
|
||||
// CHECK:STDOUT: %Op.type.548: type = fn_type @Op.2, @impl(%D) [concrete]
|
||||
// CHECK:STDOUT: %Op.2d4: %Op.type.548 = struct_value () [concrete]
|
||||
// CHECK:STDOUT: %ptr.19c: type = ptr_type %D [concrete]
|
||||
// CHECK:STDOUT: %Destroy.facet: %Destroy.type = facet_value %D, (%Destroy.impl_witness.45e) [concrete]
|
||||
// CHECK:STDOUT: %.64e: type = fn_type_with_self_type %Op.type.bae, %Destroy.facet [concrete]
|
||||
// CHECK:STDOUT: %Op.specific_fn: <specific function> = specific_function %Op.2d4, @Op.2(%D) [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -241,8 +234,6 @@ fn CallFAndGIncomplete() {
|
||||
// CHECK:STDOUT: %Main.import_ref.8f2: <witness> = import_ref Main//incomplete_return, loc37_10, loaded [concrete = constants.%complete_type.357]
|
||||
// CHECK:STDOUT: %Main.import_ref.cab = import_ref Main//incomplete_return, inst20 [no loc], unloaded
|
||||
// CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
|
||||
// CHECK:STDOUT: %Core.import_ref.0b9: @impl.%Op.type (%Op.type.bc9) = import_ref Core//prelude/parts/destroy, loc8_29, loaded [symbolic = @impl.%Op (constants.%Op.46f)]
|
||||
// CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (%Core.import_ref.0b9), @impl [concrete]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
@@ -285,18 +276,16 @@ fn CallFAndGIncomplete() {
|
||||
// CHECK:STDOUT: %.loc34_15.1: ref %D = temporary_storage
|
||||
// CHECK:STDOUT: %ReturnDUsed.call: init %D = call %ReturnDUsed.ref() to %.loc34_15.1
|
||||
// CHECK:STDOUT: %.loc34_15.2: ref %D = temporary %.loc34_15.1, %ReturnDUsed.call
|
||||
// CHECK:STDOUT: %impl.elem0.loc34: %.64e = impl_witness_access constants.%Destroy.impl_witness.45e, element0 [concrete = constants.%Op.2d4]
|
||||
// CHECK:STDOUT: %bound_method.loc34_15.1: <bound method> = bound_method %.loc34_15.1, %impl.elem0.loc34
|
||||
// CHECK:STDOUT: %specific_fn.loc34: <specific function> = specific_function %impl.elem0.loc34, @Op.2(constants.%D) [concrete = constants.%Op.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc34_15.2: <bound method> = bound_method %.loc34_15.1, %specific_fn.loc34
|
||||
// CHECK:STDOUT: %Op.bound.loc34: <bound method> = bound_method %.loc34_15.1, constants.%Op.2d4
|
||||
// CHECK:STDOUT: %Op.specific_fn.1: <specific function> = specific_function constants.%Op.2d4, @Op.2(constants.%D) [concrete = constants.%Op.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc34: <bound method> = bound_method %.loc34_15.1, %Op.specific_fn.1
|
||||
// CHECK:STDOUT: %addr.loc34: %ptr.19c = addr_of %.loc34_15.1
|
||||
// CHECK:STDOUT: %no_op.loc34: init %empty_tuple.type = call %bound_method.loc34_15.2(%addr.loc34)
|
||||
// CHECK:STDOUT: %impl.elem0.loc33: %.64e = impl_witness_access constants.%Destroy.impl_witness.45e, element0 [concrete = constants.%Op.2d4]
|
||||
// CHECK:STDOUT: %bound_method.loc33_17.1: <bound method> = bound_method %.loc33_17.1, %impl.elem0.loc33
|
||||
// CHECK:STDOUT: %specific_fn.loc33: <specific function> = specific_function %impl.elem0.loc33, @Op.2(constants.%D) [concrete = constants.%Op.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc33_17.2: <bound method> = bound_method %.loc33_17.1, %specific_fn.loc33
|
||||
// CHECK:STDOUT: %no_op.loc34: init %empty_tuple.type = call %bound_method.loc34(%addr.loc34)
|
||||
// CHECK:STDOUT: %Op.bound.loc33: <bound method> = bound_method %.loc33_17.1, constants.%Op.2d4
|
||||
// CHECK:STDOUT: %Op.specific_fn.2: <specific function> = specific_function constants.%Op.2d4, @Op.2(constants.%D) [concrete = constants.%Op.specific_fn]
|
||||
// CHECK:STDOUT: %bound_method.loc33: <bound method> = bound_method %.loc33_17.1, %Op.specific_fn.2
|
||||
// CHECK:STDOUT: %addr.loc33: %ptr.19c = addr_of %.loc33_17.1
|
||||
// CHECK:STDOUT: %no_op.loc33: init %empty_tuple.type = call %bound_method.loc33_17.2(%addr.loc33)
|
||||
// CHECK:STDOUT: %no_op.loc33: init %empty_tuple.type = call %bound_method.loc33(%addr.loc33)
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
Reference in New Issue
Block a user