call_different_associated_const.carbon 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.105e251602f0e987(), !dbg !7
  39. // CHECK:STDOUT: call void @_CG.Main.105e251602f0e987(), !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.105e251602f0e987() #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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  52. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: ; uselistorder directives
  55. // CHECK:STDOUT: uselistorder ptr @_CG.Main.105e251602f0e987, { 1, 0 }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: attributes #0 = { nounwind }
  58. // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  61. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  64. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  65. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  66. // CHECK:STDOUT: !3 = !DIFile(filename: "call_different_associated_const.carbon", directory: "")
  67. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "H", linkageName: "_CH.Main", scope: null, file: !3, line: 35, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  68. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  69. // CHECK:STDOUT: !6 = !{null}
  70. // CHECK:STDOUT: !7 = !DILocation(line: 36, column: 3, scope: !4)
  71. // CHECK:STDOUT: !8 = !DILocation(line: 37, column: 3, scope: !4)
  72. // CHECK:STDOUT: !9 = !DILocation(line: 35, column: 1, scope: !4)
  73. // CHECK:STDOUT: !10 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.105e251602f0e987", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  74. // CHECK:STDOUT: !11 = !DILocation(line: 23, column: 3, scope: !10)
  75. // CHECK:STDOUT: !12 = !DILocation(line: 22, column: 1, scope: !10)