unreachable_end.carbon 3.3 KB

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