bool.carbon 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/bool.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/primitives/bool.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/primitives/bool.carbon
  12. fn F() -> bool {
  13. return false;
  14. }
  15. fn T() -> bool {
  16. return true;
  17. }
  18. fn LoadStore(p: bool*, b: bool) -> bool {
  19. let v: bool = *p;
  20. *p = b;
  21. return v;
  22. }
  23. // CHECK:STDOUT: ; ModuleID = 'bool.carbon'
  24. // CHECK:STDOUT: source_filename = "bool.carbon"
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: ; Function Attrs: nounwind
  27. // CHECK:STDOUT: define i1 @_CF.Main() #0 !dbg !4 {
  28. // CHECK:STDOUT: entry:
  29. // CHECK:STDOUT: ret i1 false, !dbg !8
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: ; Function Attrs: nounwind
  33. // CHECK:STDOUT: define i1 @_CT.Main() #0 !dbg !9 {
  34. // CHECK:STDOUT: entry:
  35. // CHECK:STDOUT: ret i1 true, !dbg !10
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: ; Function Attrs: nounwind
  39. // CHECK:STDOUT: define i1 @_CLoadStore.Main(ptr %p, i1 %b) #0 !dbg !11 {
  40. // CHECK:STDOUT: entry:
  41. // CHECK:STDOUT: %.loc22_17.2 = load i8, ptr %p, align 1, !dbg !17
  42. // CHECK:STDOUT: %.loc22_17.21 = trunc i8 %.loc22_17.2 to i1, !dbg !17
  43. // CHECK:STDOUT: %0 = zext i1 %b to i8, !dbg !18
  44. // CHECK:STDOUT: store i8 %0, ptr %p, align 1, !dbg !18
  45. // CHECK:STDOUT: ret i1 %.loc22_17.21, !dbg !19
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: attributes #0 = { nounwind }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  51. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  54. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  55. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  56. // CHECK:STDOUT: !3 = !DIFile(filename: "bool.carbon", directory: "")
  57. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  58. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  59. // CHECK:STDOUT: !6 = !{!7}
  60. // CHECK:STDOUT: !7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 8)
  61. // CHECK:STDOUT: !8 = !DILocation(line: 14, column: 3, scope: !4)
  62. // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "T", linkageName: "_CT.Main", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  63. // CHECK:STDOUT: !10 = !DILocation(line: 18, column: 3, scope: !9)
  64. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "LoadStore", linkageName: "_CLoadStore.Main", scope: null, file: !3, line: 21, type: !12, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !14)
  65. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  66. // CHECK:STDOUT: !13 = !{!7, !7, !7}
  67. // CHECK:STDOUT: !14 = !{!15, !16}
  68. // CHECK:STDOUT: !15 = !DILocalVariable(arg: 1, scope: !11, type: !7)
  69. // CHECK:STDOUT: !16 = !DILocalVariable(arg: 2, scope: !11, type: !7)
  70. // CHECK:STDOUT: !17 = !DILocation(line: 22, column: 17, scope: !11)
  71. // CHECK:STDOUT: !18 = !DILocation(line: 23, column: 3, scope: !11)
  72. // CHECK:STDOUT: !19 = !DILocation(line: 24, column: 3, scope: !11)