two_entries.carbon 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/struct/two_entries.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/struct/two_entries.carbon
  10. fn Run() -> i32 {
  11. var x: {.a: i32, .b: i32} = {.a = 1, .b = 2};
  12. var y: {.a: i32, .b: i32} = x;
  13. return 0;
  14. }
  15. // CHECK:STDOUT: ; ModuleID = 'two_entries.carbon'
  16. // CHECK:STDOUT: source_filename = "two_entries.carbon"
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: @struct.loc12_47 = internal constant { i32, i32 } { i32 1, i32 2 }
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: define i32 @main() {
  21. // CHECK:STDOUT: entry:
  22. // CHECK:STDOUT: %x.var = alloca { i32, i32 }, align 8
  23. // CHECK:STDOUT: %.loc12_46.2.a = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 0
  24. // CHECK:STDOUT: %.loc12_46.4.b = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 1
  25. // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %x.var, ptr align 4 @struct.loc12_47, i64 8, i1 false)
  26. // CHECK:STDOUT: %y.var = alloca { i32, i32 }, align 8
  27. // CHECK:STDOUT: %.loc13_31.1.a = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 0
  28. // CHECK:STDOUT: %.loc13_31.2 = load i32, ptr %.loc13_31.1.a, align 4
  29. // CHECK:STDOUT: %.loc13_31.3.a = getelementptr inbounds { i32, i32 }, ptr %y.var, i32 0, i32 0
  30. // CHECK:STDOUT: store i32 %.loc13_31.2, ptr %.loc13_31.3.a, align 4
  31. // CHECK:STDOUT: %.loc13_31.5.b = getelementptr inbounds { i32, i32 }, ptr %x.var, i32 0, i32 1
  32. // CHECK:STDOUT: %.loc13_31.6 = load i32, ptr %.loc13_31.5.b, align 4
  33. // CHECK:STDOUT: %.loc13_31.7.b = getelementptr inbounds { i32, i32 }, ptr %y.var, i32 0, i32 1
  34. // CHECK:STDOUT: store i32 %.loc13_31.6, ptr %.loc13_31.7.b, align 4
  35. // CHECK:STDOUT: ret i32 0
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
  39. // CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }