call_different_associated_const.carbon 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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: ret void, !dbg !12
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: ; Function Attrs: nounwind
  52. // CHECK:STDOUT: define linkonce_odr void @_CG.Main.81fba156b0d338bf() #0 !dbg !13 {
  53. // CHECK:STDOUT: entry:
  54. // CHECK:STDOUT: %_.var = alloca ptr, align 8, !dbg !14
  55. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %_.var), !dbg !14
  56. // CHECK:STDOUT: ret void, !dbg !15
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  60. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: ; uselistorder directives
  63. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 1, 0 }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: attributes #0 = { nounwind }
  66. // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  69. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  72. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  73. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  74. // CHECK:STDOUT: !3 = !DIFile(filename: "call_different_associated_const.carbon", directory: "")
  75. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "H", linkageName: "_CH.Main", scope: null, file: !3, line: 35, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  76. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  77. // CHECK:STDOUT: !6 = !{null}
  78. // CHECK:STDOUT: !7 = !DILocation(line: 36, column: 3, scope: !4)
  79. // CHECK:STDOUT: !8 = !DILocation(line: 37, column: 3, scope: !4)
  80. // CHECK:STDOUT: !9 = !DILocation(line: 35, column: 1, scope: !4)
  81. // CHECK:STDOUT: !10 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.5b70bb1fa120a73d", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  82. // CHECK:STDOUT: !11 = !DILocation(line: 23, column: 3, scope: !10)
  83. // CHECK:STDOUT: !12 = !DILocation(line: 22, column: 1, scope: !10)
  84. // CHECK:STDOUT: !13 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.81fba156b0d338bf", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  85. // CHECK:STDOUT: !14 = !DILocation(line: 23, column: 3, scope: !13)
  86. // CHECK:STDOUT: !15 = !DILocation(line: 22, column: 1, scope: !13)