mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Fix name mangling of generic impls (#6533)
### Description Mangling collisions occur when implementing interfaces with generic parameters. The mangler does not use the specific id, causing the same symbol `_C[FunctionName].[PackageName]:[InterfaceName].[PackageName]` to be generated for all of the implementations below: ```carbon // Generic interface parameters ignored impl C as I(A) impl C as I(B) // Generic class parameters ignored impl D(A) as I impl D(B) as I // Both ignored impl D(A) as I(A) impl D(B) as I(B) ``` ### Changes Updated the mangling logic for `SemIR::ClassDecl` and `SemIR::InterfaceDecl` to include the specific id. Now the mangling ensures unique symbols for generic implementations using the format: `_C[FunctionName].[FunctionSpecificId].[PackageName]:[InterfaceName].[InterfaceSpecificId].[PackageName]`. Closes #6498
This commit is contained in:
+6
-6
@@ -33,7 +33,7 @@ fn PassVoidPtr(a: Cpp.void*) {
|
||||
// CHECK:STDOUT: define void @_CPassVoidPtr.Main(ptr %a) #0 !dbg !7 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc7_21.2.temp = alloca ptr, align 8, !dbg !13
|
||||
// CHECK:STDOUT: %U.binding.as_type.as.ImplicitAs.impl.Convert.call = call ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.Core.5c62f2dbad753cd9"(ptr %a), !dbg !13
|
||||
// CHECK:STDOUT: %U.binding.as_type.as.ImplicitAs.impl.Convert.call = call ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.5c62f2dbad753cd9"(ptr %a), !dbg !13
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc7_21.2.temp), !dbg !13
|
||||
// CHECK:STDOUT: store ptr %U.binding.as_type.as.ImplicitAs.impl.Convert.call, ptr %.loc7_21.2.temp, align 8, !dbg !13
|
||||
// CHECK:STDOUT: %.loc7_21.4 = load ptr, ptr %.loc7_21.2.temp, align 8, !dbg !13
|
||||
@@ -44,8 +44,8 @@ fn PassVoidPtr(a: Cpp.void*) {
|
||||
// CHECK:STDOUT: declare void @_Z13take_void_ptrPv(ptr)
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.Core.5c62f2dbad753cd9"(ptr %self) #0 !dbg !16 {
|
||||
// CHECK:STDOUT: %1 = call ptr @"_CConvert.90961d7b1ce4f089:OptionalAs.Core.d2075df181ac34c1"(ptr %self), !dbg !22
|
||||
// CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.5c62f2dbad753cd9"(ptr %self) #0 !dbg !16 {
|
||||
// CHECK:STDOUT: %1 = call ptr @"_CConvert.90961d7b1ce4f089:OptionalAs.0e326e799dad0c64.Core.d2075df181ac34c1"(ptr %self), !dbg !22
|
||||
// CHECK:STDOUT: ret ptr %1, !dbg !23
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
@@ -53,7 +53,7 @@ fn PassVoidPtr(a: Cpp.void*) {
|
||||
// CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.90961d7b1ce4f089:OptionalAs.Core.d2075df181ac34c1"(ptr %self) #0 !dbg !24 {
|
||||
// CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.90961d7b1ce4f089:OptionalAs.0e326e799dad0c64.Core.d2075df181ac34c1"(ptr %self) #0 !dbg !24 {
|
||||
// CHECK:STDOUT: %1 = call ptr @_CSome.Optional.Core.d2075df181ac34c1(ptr %self), !dbg !27
|
||||
// CHECK:STDOUT: ret ptr %1, !dbg !28
|
||||
// CHECK:STDOUT: }
|
||||
@@ -95,7 +95,7 @@ fn PassVoidPtr(a: Cpp.void*) {
|
||||
// CHECK:STDOUT: !13 = !DILocation(line: 7, column: 21, scope: !7)
|
||||
// CHECK:STDOUT: !14 = !DILocation(line: 7, column: 3, scope: !7)
|
||||
// CHECK:STDOUT: !15 = !DILocation(line: 6, column: 1, scope: !7)
|
||||
// CHECK:STDOUT: !16 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.e5cf8fcbb4feaae2:ImplicitAs.Core.5c62f2dbad753cd9", scope: null, file: !17, line: 82, type: !18, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !20)
|
||||
// CHECK:STDOUT: !16 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.5c62f2dbad753cd9", scope: null, file: !17, line: 82, type: !18, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !20)
|
||||
// CHECK:STDOUT: !17 = !DIFile(filename: "{{.*}}/prelude/types/optional.carbon", directory: "")
|
||||
// CHECK:STDOUT: !18 = !DISubroutineType(types: !19)
|
||||
// CHECK:STDOUT: !19 = !{!10, !10}
|
||||
@@ -103,7 +103,7 @@ fn PassVoidPtr(a: Cpp.void*) {
|
||||
// CHECK:STDOUT: !21 = !DILocalVariable(arg: 1, scope: !16, type: !10)
|
||||
// CHECK:STDOUT: !22 = !DILocation(line: 83, column: 12, scope: !16)
|
||||
// CHECK:STDOUT: !23 = !DILocation(line: 83, column: 5, scope: !16)
|
||||
// CHECK:STDOUT: !24 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.90961d7b1ce4f089:OptionalAs.Core.d2075df181ac34c1", scope: null, file: !17, line: 68, type: !18, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !25)
|
||||
// CHECK:STDOUT: !24 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.90961d7b1ce4f089:OptionalAs.0e326e799dad0c64.Core.d2075df181ac34c1", scope: null, file: !17, line: 68, type: !18, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !25)
|
||||
// CHECK:STDOUT: !25 = !{!26}
|
||||
// CHECK:STDOUT: !26 = !DILocalVariable(arg: 1, scope: !24, type: !10)
|
||||
// CHECK:STDOUT: !27 = !DILocation(line: 69, column: 12, scope: !24)
|
||||
|
||||
Reference in New Issue
Block a user