Directly convert from an initializer to a value where possible. (#3306)

If the initializing representation is the same as the value
representation, don't materialize a temporary and perform a value
binding. Instead, directly extract the value, using a new
`value_of_initializer` node.

This removes a lot of redundant `alloca`s from our generated LLVM IR.
This commit is contained in:
Richard Smith
2023-10-31 20:59:28 +00:00
committed by GitHub
parent bc8db9406d
commit 428d11323a
32 changed files with 214 additions and 290 deletions
+1 -4
View File
@@ -25,8 +25,5 @@ fn F() -> i32 {
// CHECK:STDOUT: %n = alloca i32, align 4
// CHECK:STDOUT: store i32 0, ptr %n, align 4
// CHECK:STDOUT: %G = call i32 @G(ptr %n)
// CHECK:STDOUT: %temp = alloca i32, align 4
// CHECK:STDOUT: store i32 %G, ptr %temp, align 4
// CHECK:STDOUT: %1 = load i32, ptr %temp, align 4
// CHECK:STDOUT: ret i32 %1
// CHECK:STDOUT: ret i32 %G
// CHECK:STDOUT: }