address_of_deref.carbon 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 F() -> i32 {
  7. var n: i32 = 0;
  8. return *&*&n;
  9. }
  10. // CHECK:STDOUT: --- address_of_deref.carbon
  11. // CHECK:STDOUT:
  12. // CHECK:STDOUT: constants {
  13. // CHECK:STDOUT: %F: type = fn_type @F [template]
  14. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  15. // CHECK:STDOUT: %struct: F = struct_value () [template]
  16. // CHECK:STDOUT: %.2: i32 = int_literal 0 [template]
  17. // CHECK:STDOUT: %.3: type = ptr_type i32 [template]
  18. // CHECK:STDOUT: }
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: file {
  21. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  22. // CHECK:STDOUT: .Core = %Core
  23. // CHECK:STDOUT: .F = %F.decl
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  26. // CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct] {
  27. // CHECK:STDOUT: @F.%return: ref i32 = var <return slot>
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: fn @F() -> i32 {
  32. // CHECK:STDOUT: !entry:
  33. // CHECK:STDOUT: %n.var: ref i32 = var n
  34. // CHECK:STDOUT: %n: ref i32 = bind_name n, %n.var
  35. // CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.2]
  36. // CHECK:STDOUT: assign %n.var, %.loc8
  37. // CHECK:STDOUT: %n.ref: ref i32 = name_ref n, %n
  38. // CHECK:STDOUT: %.loc9_13: i32* = addr_of %n.ref
  39. // CHECK:STDOUT: %.loc9_12: ref i32 = deref %.loc9_13
  40. // CHECK:STDOUT: %.loc9_11: i32* = addr_of %.loc9_12
  41. // CHECK:STDOUT: %.loc9_10.1: ref i32 = deref %.loc9_11
  42. // CHECK:STDOUT: %.loc9_10.2: i32 = bind_value %.loc9_10.1
  43. // CHECK:STDOUT: return %.loc9_10.2
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: