Files
carbon-lang/toolchain/lower/testdata/struct/two_entries.carbon
T
Richard Smith 9a11e977b3 Improve formatting of the type of a function or generic class name. (#4033)
Don't format the *type of* the function `F` as `"F"`. Instead use
`"<type of F>"`.

Also improve instruction naming for function and generic class name
values: name the value after the function or generic class, and add a
`.type` suffix to the type.
2024-06-06 00:40:43 +00:00

44 lines
2.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
// TIP: To test this file alone, run:
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/struct/two_entries.carbon
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/struct/two_entries.carbon
fn Run() -> i32 {
var x: {.a: i32, .b: i32} = {.a = 1, .b = 2};
var y: {.a: i32, .b: i32} = x;
return 0;
}
// CHECK:STDOUT: ; ModuleID = 'two_entries.carbon'
// CHECK:STDOUT: source_filename = "two_entries.carbon"
// CHECK:STDOUT:
// CHECK:STDOUT: @struct.loc12_47 = internal constant { i32, i32 } { i32 1, i32 2 }
// CHECK:STDOUT:
// CHECK:STDOUT: define i32 @main() {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %x.var = alloca { i32, i32 }, align 8
// CHECK:STDOUT: %.loc12_46.2.a = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 0
// CHECK:STDOUT: %.loc12_46.4.b = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 1
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x.var, ptr align 4 @struct.loc12_47, i64 8, i1 false)
// CHECK:STDOUT: %y.var = alloca { i32, i32 }, align 8
// CHECK:STDOUT: %.loc13_31.1.a = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 0
// CHECK:STDOUT: %.loc13_31.2 = load i32, ptr %.loc13_31.1.a, align 4
// CHECK:STDOUT: %.loc13_31.3.a = getelementptr inbounds { i32, i32 }, ptr %y.var, i32 0, i32 0
// CHECK:STDOUT: store i32 %.loc13_31.2, ptr %.loc13_31.3.a, align 4
// CHECK:STDOUT: %.loc13_31.5.b = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 1
// CHECK:STDOUT: %.loc13_31.6 = load i32, ptr %.loc13_31.5.b, align 4
// CHECK:STDOUT: %.loc13_31.7.b = getelementptr inbounds { i32, i32 }, ptr %y.var, i32 0, i32 1
// CHECK:STDOUT: store i32 %.loc13_31.6, ptr %.loc13_31.7.b, align 4
// CHECK:STDOUT: ret i32 0
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
// CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0
// CHECK:STDOUT:
// CHECK:STDOUT: attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }