address_of_field.carbon 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  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: @struct.3.loc10_47 = internal constant { i32, i32 } { i32 1, i32 2 }
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: declare void @G(ptr)
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: define void @F() {
  19. // CHECK:STDOUT: entry:
  20. // CHECK:STDOUT: %s.var = alloca { i32, i32 }, align 8
  21. // CHECK:STDOUT: %.loc10_46.2.a = getelementptr inbounds { i32, i32 }, ptr %s.var, i32 0, i32 0
  22. // CHECK:STDOUT: %.loc10_46.4.b = getelementptr inbounds { i32, i32 }, ptr %s.var, i32 0, i32 1
  23. // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %s.var, ptr align 4 @struct.3.loc10_47, i64 8, i1 false)
  24. // CHECK:STDOUT: %.loc11_7.b = getelementptr inbounds { i32, i32 }, ptr %s.var, i32 0, i32 1
  25. // CHECK:STDOUT: call void @G(ptr %.loc11_7.b)
  26. // CHECK:STDOUT: ret void
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
  30. // CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }