Don't eagerly materialize an initializing expression used as the object in a compound member access. (#4496)

Instead, wait until we know whether it is used as a value or reference
expression. This allows us to avoid materializing a temporary if it is
used as a value and the initializing representation holds a copy of a
value representation.
This commit is contained in:
Richard Smith
2024-11-11 21:32:33 +00:00
committed by GitHub
parent a69c2630f9
commit 2c1d02d991
18 changed files with 110 additions and 74 deletions
@@ -129,8 +129,6 @@ fn Run() {
// CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var
// CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
// CHECK:STDOUT: %Foo.call: init f64 = call %Foo.ref()
// CHECK:STDOUT: %.loc20_19.1: ref f64 = temporary_storage
// CHECK:STDOUT: %.loc20_19.2: ref f64 = temporary %.loc20_19.1, %Foo.call
// CHECK:STDOUT: %.loc20_21: i32 = converted %Foo.call, <error> [template = <error>]
// CHECK:STDOUT: assign %x.var, <error>
// CHECK:STDOUT: return