else.carbon 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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() {}
  7. fn G() {}
  8. fn H() {}
  9. fn If(b: bool) {
  10. if (b) {
  11. F();
  12. } else {
  13. G();
  14. }
  15. H();
  16. }
  17. // CHECK:STDOUT: --- else.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %F: type = fn_type @F [template]
  21. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  22. // CHECK:STDOUT: %struct.1: F = struct_value () [template]
  23. // CHECK:STDOUT: %G: type = fn_type @G [template]
  24. // CHECK:STDOUT: %struct.2: G = struct_value () [template]
  25. // CHECK:STDOUT: %H: type = fn_type @H [template]
  26. // CHECK:STDOUT: %struct.3: H = struct_value () [template]
  27. // CHECK:STDOUT: %If: type = fn_type @If [template]
  28. // CHECK:STDOUT: %struct.4: If = struct_value () [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: file {
  32. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  33. // CHECK:STDOUT: .Core = %Core
  34. // CHECK:STDOUT: .F = %F.decl
  35. // CHECK:STDOUT: .G = %G.decl
  36. // CHECK:STDOUT: .H = %H.decl
  37. // CHECK:STDOUT: .If = %If.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  40. // CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct.1] {}
  41. // CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.2] {}
  42. // CHECK:STDOUT: %H.decl: H = fn_decl @H [template = constants.%struct.3] {}
  43. // CHECK:STDOUT: %If.decl: If = fn_decl @If [template = constants.%struct.4] {
  44. // CHECK:STDOUT: %b.loc11_7.1: bool = param b
  45. // CHECK:STDOUT: @If.%b: bool = bind_name b, %b.loc11_7.1
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: fn @F() {
  50. // CHECK:STDOUT: !entry:
  51. // CHECK:STDOUT: return
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: fn @G() {
  55. // CHECK:STDOUT: !entry:
  56. // CHECK:STDOUT: return
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: fn @H() {
  60. // CHECK:STDOUT: !entry:
  61. // CHECK:STDOUT: return
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @If(%b: bool) {
  65. // CHECK:STDOUT: !entry:
  66. // CHECK:STDOUT: %b.ref: bool = name_ref b, %b
  67. // CHECK:STDOUT: if %b.ref br !if.then else br !if.else
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: !if.then:
  70. // CHECK:STDOUT: %F.ref: F = name_ref F, file.%F.decl [template = constants.%struct.1]
  71. // CHECK:STDOUT: %F.call: init () = call %F.ref()
  72. // CHECK:STDOUT: br !if.done
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: !if.else:
  75. // CHECK:STDOUT: %G.ref: G = name_ref G, file.%G.decl [template = constants.%struct.2]
  76. // CHECK:STDOUT: %G.call: init () = call %G.ref()
  77. // CHECK:STDOUT: br !if.done
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: !if.done:
  80. // CHECK:STDOUT: %H.ref: H = name_ref H, file.%H.decl [template = constants.%struct.3]
  81. // CHECK:STDOUT: %H.call: init () = call %H.ref()
  82. // CHECK:STDOUT: return
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: