mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 10:01:06 +01:00
Move completeness check to the point where the function is defined or first called. This means we also defer deciding whether the function has a return slot until that point. Instead of storing a return slot per function, store the location of the return storage, which may or may not be used, and compute and store a separate flag saying whether to use it at the point of first use or definition. This is the final piece in supporting simple `Make` functions in classes as a replacement for constructors.
43 lines
1.4 KiB
Plaintext
43 lines
1.4 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// AUTOUPDATE
|
|
|
|
fn F() -> i32 {
|
|
var a: i32 = 0;
|
|
alias b = a;
|
|
return b;
|
|
}
|
|
|
|
// CHECK:STDOUT: --- local.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %.1: i32 = int_literal 0 [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Core = %Core
|
|
// CHECK:STDOUT: .F = %F
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
|
// CHECK:STDOUT: %F: <function> = fn_decl @F [template] {
|
|
// CHECK:STDOUT: @F.%return: ref i32 = var <return slot>
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @F() -> i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %a.var: ref i32 = var a
|
|
// CHECK:STDOUT: %a: ref i32 = bind_name a, %a.var
|
|
// CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.1]
|
|
// CHECK:STDOUT: assign %a.var, %.loc8
|
|
// CHECK:STDOUT: %a.ref: ref i32 = name_ref a, %a
|
|
// CHECK:STDOUT: %b: ref i32 = bind_alias b, %a
|
|
// CHECK:STDOUT: %b.ref: ref i32 = name_ref b, %b
|
|
// CHECK:STDOUT: %.loc10: i32 = bind_value %b.ref
|
|
// CHECK:STDOUT: return %.loc10
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|