address_of_field.carbon 1006 B

12345678910111213141516171819202122232425262728
  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. fn G(p: i32*);
  7. fn F() {
  8. var s: {.a: i32, .b: i32} = {.a = 1, .b = 2};
  9. G(&s.b);
  10. }
  11. // CHECK:STDOUT: ; ModuleID = 'address_of_field.carbon'
  12. // CHECK:STDOUT: source_filename = "address_of_field.carbon"
  13. // CHECK:STDOUT:
  14. // CHECK:STDOUT: declare void @G(ptr)
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: define void @F() {
  17. // CHECK:STDOUT: %s = alloca { i32, i32 }, align 8
  18. // CHECK:STDOUT: %a = getelementptr inbounds { i32, i32 }, ptr %s, i32 0, i32 0
  19. // CHECK:STDOUT: store i32 1, ptr %a, align 4
  20. // CHECK:STDOUT: %b = getelementptr inbounds { i32, i32 }, ptr %s, i32 0, i32 1
  21. // CHECK:STDOUT: store i32 2, ptr %b, align 4
  22. // CHECK:STDOUT: %b1 = getelementptr inbounds { i32, i32 }, ptr %s, i32 0, i32 1
  23. // CHECK:STDOUT: call void @G(ptr %b1)
  24. // CHECK:STDOUT: ret void
  25. // CHECK:STDOUT: }