call_different_associated_const.carbon 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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/primitives.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/function/generic/call_different_associated_const.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/function/generic/call_different_associated_const.carbon
  12. // Cannot coalesce the lowering for G specifics, as they have associated contants of different types.
  13. // Check different functions are still emitted when trying to deduplicate emitted definitons.
  14. interface I {
  15. let T:! type;
  16. // TODO: An interface with multiple associated entities is not yet
  17. // implemented in mangling.
  18. }
  19. fn G(U:! I) {
  20. var _: U.T*;
  21. }
  22. class C {}
  23. impl C as I where .T = bool {
  24. }
  25. class D {}
  26. impl D as I where .T = i32 {
  27. }
  28. fn H() {
  29. G(C);
  30. G(D);
  31. }
  32. // CHECK:STDOUT: ; ModuleID = 'call_different_associated_const.carbon'
  33. // CHECK:STDOUT: source_filename = "call_different_associated_const.carbon"
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: ; Function Attrs: nounwind
  36. // CHECK:STDOUT: define void @_CH.Main() #0 !dbg !4 {
  37. // CHECK:STDOUT: entry:
  38. // CHECK:STDOUT: call void @_CG.Main.5b70bb1fa120a73d(), !dbg !7
  39. // CHECK:STDOUT: call void @_CG.Main.81fba156b0d338bf(), !dbg !8
  40. // CHECK:STDOUT: ret void, !dbg !9
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: ; Function Attrs: nounwind
  44. // CHECK:STDOUT: define linkonce_odr void @_CG.Main.5b70bb1fa120a73d() #0 !dbg !10 {
  45. // CHECK:STDOUT: entry:
  46. // CHECK:STDOUT: %_.var = alloca ptr, align 8, !dbg !11
  47. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %_.var), !dbg !11
  48. // CHECK:STDOUT: store ptr poison, ptr %_.var, align 8, !dbg !11
  49. // CHECK:STDOUT: ret void, !dbg !12
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: ; Function Attrs: nounwind
  53. // CHECK:STDOUT: define linkonce_odr void @_CG.Main.81fba156b0d338bf() #0 !dbg !13 {
  54. // CHECK:STDOUT: entry:
  55. // CHECK:STDOUT: %_.var = alloca ptr, align 8, !dbg !14
  56. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %_.var), !dbg !14
  57. // CHECK:STDOUT: store ptr poison, ptr %_.var, align 8, !dbg !14
  58. // CHECK:STDOUT: ret void, !dbg !15
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  62. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: ; uselistorder directives
  65. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 1, 0 }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: attributes #0 = { nounwind }
  68. // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  71. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  74. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  75. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  76. // CHECK:STDOUT: !3 = !DIFile(filename: "call_different_associated_const.carbon", directory: "")
  77. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "H", linkageName: "_CH.Main", scope: null, file: !3, line: 35, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  78. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  79. // CHECK:STDOUT: !6 = !{null}
  80. // CHECK:STDOUT: !7 = !DILocation(line: 36, column: 3, scope: !4)
  81. // CHECK:STDOUT: !8 = !DILocation(line: 37, column: 3, scope: !4)
  82. // CHECK:STDOUT: !9 = !DILocation(line: 35, column: 1, scope: !4)
  83. // CHECK:STDOUT: !10 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.5b70bb1fa120a73d", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  84. // CHECK:STDOUT: !11 = !DILocation(line: 23, column: 3, scope: !10)
  85. // CHECK:STDOUT: !12 = !DILocation(line: 22, column: 1, scope: !10)
  86. // CHECK:STDOUT: !13 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.81fba156b0d338bf", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  87. // CHECK:STDOUT: !14 = !DILocation(line: 23, column: 3, scope: !13)
  88. // CHECK:STDOUT: !15 = !DILocation(line: 22, column: 1, scope: !13)