mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Canonicalize generated functions for Core witnesses (#7729)
Use a single `SemIR::Function` per `Core` interface method, whether it's generated locally or imported. This prevents generating duplicate functions, which lead to different types when the witness appears in a `FacetValue` as part of a specific for a class. We use a `CanonicalValueStore` of `GeneratedFunction` objects that allow finding an existing FunctionId for a `Generated` special function before (re-)generating it. Mangling for `Generated` functions is also moved to use the values from the `GeneratedFunction`'s canonicalization key, so that we have a consistent source of truth for the unique ID of a `Generated` function across all files. New tests are in `toolchain/check/testdata/impl/custom_witness/destroy.carbon`.
This commit is contained in:
@@ -82,27 +82,27 @@ fn M() {
|
||||
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %c.var, ptr align 1 @C.val.loc15_43, i64 0, i1 false), !dbg !48
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc40_9.3.temp), !dbg !51
|
||||
// CHECK:STDOUT: call void @_CF.Main.42513763e01cba2c(ptr %.loc40_9.3.temp, ptr %c.var, i32 0), !dbg !51
|
||||
// CHECK:STDOUT: call void @"_COp.cbd14a388b4a1c25:core.Destroy.Core"(ptr %.loc40_9.3.temp), !dbg !51
|
||||
// CHECK:STDOUT: call void @"_COp.cbd14a388b4a1c25:core.Destroy.Core"(ptr %c.var), !dbg !48
|
||||
// CHECK:STDOUT: call void @"_COp.a1ae3d31ab69a7f8:core.Destroy.Core"(ptr %m.var), !dbg !26
|
||||
// CHECK:STDOUT: call void @"_COp.70db2d92ffddbef7:core.Destroy.Core"(ptr %n.var), !dbg !24
|
||||
// CHECK:STDOUT: call void @"_COp.08d9e38b928ba575:core.Destroy.Core"(ptr %.loc40_9.3.temp), !dbg !51
|
||||
// CHECK:STDOUT: call void @"_COp.08d9e38b928ba575:core.Destroy.Core"(ptr %c.var), !dbg !48
|
||||
// CHECK:STDOUT: call void @"_COp.dc14d4dd21801791:core.Destroy.Core"(ptr %m.var), !dbg !26
|
||||
// CHECK:STDOUT: call void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %n.var), !dbg !24
|
||||
// CHECK:STDOUT: ret void, !dbg !52
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.cbd14a388b4a1c25:core.Destroy.Core"(ptr %self) #0 !dbg !53 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.08d9e38b928ba575:core.Destroy.Core"(ptr %self) #0 !dbg !53 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !55
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.a1ae3d31ab69a7f8:core.Destroy.Core"(ptr %self) #0 !dbg !57 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.dc14d4dd21801791:core.Destroy.Core"(ptr %self) #0 !dbg !57 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !59
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.70db2d92ffddbef7:core.Destroy.Core"(ptr %self) #0 !dbg !61 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %self) #0 !dbg !61 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !63
|
||||
// CHECK:STDOUT: }
|
||||
@@ -175,7 +175,7 @@ fn M() {
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; uselistorder directives
|
||||
// CHECK:STDOUT: uselistorder ptr @"_COp.cbd14a388b4a1c25:core.Destroy.Core", { 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @"_COp.08d9e38b928ba575:core.Destroy.Core", { 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @llvm.memcpy.p0.p0.i64, { 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 5, 4, 3, 2, 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_CF.Main.a76b78461416b4a8, { 1, 2, 0 }
|
||||
@@ -224,15 +224,15 @@ fn M() {
|
||||
// CHECK:STDOUT: !48 = !DILocation(line: 39, column: 3, scope: !23)
|
||||
// CHECK:STDOUT: !51 = !DILocation(line: 40, column: 3, scope: !23)
|
||||
// CHECK:STDOUT: !52 = !DILocation(line: 28, column: 1, scope: !23)
|
||||
// CHECK:STDOUT: !53 = distinct !DISubprogram(name: "Op", linkageName: "_COp.cbd14a388b4a1c25:core.Destroy.Core", scope: null, file: !4, line: 40, type: !13, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !56)
|
||||
// CHECK:STDOUT: !53 = distinct !DISubprogram(name: "Op", linkageName: "_COp.08d9e38b928ba575:core.Destroy.Core", scope: null, file: !4, line: 40, type: !13, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !56)
|
||||
// CHECK:STDOUT: !54 = !DILocalVariable(arg: 1, scope: !53, type: !7)
|
||||
// CHECK:STDOUT: !55 = !DILocation(line: 40, column: 3, scope: !53)
|
||||
// CHECK:STDOUT: !56 = !{!54}
|
||||
// CHECK:STDOUT: !57 = distinct !DISubprogram(name: "Op", linkageName: "_COp.a1ae3d31ab69a7f8:core.Destroy.Core", scope: null, file: !4, line: 30, type: !13, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !60)
|
||||
// CHECK:STDOUT: !57 = distinct !DISubprogram(name: "Op", linkageName: "_COp.dc14d4dd21801791:core.Destroy.Core", scope: null, file: !4, line: 30, type: !13, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !60)
|
||||
// CHECK:STDOUT: !58 = !DILocalVariable(arg: 1, scope: !57, type: !7)
|
||||
// CHECK:STDOUT: !59 = !DILocation(line: 30, column: 3, scope: !57)
|
||||
// CHECK:STDOUT: !60 = !{!58}
|
||||
// CHECK:STDOUT: !61 = distinct !DISubprogram(name: "Op", linkageName: "_COp.70db2d92ffddbef7:core.Destroy.Core", scope: null, file: !4, line: 29, type: !15, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !64)
|
||||
// CHECK:STDOUT: !61 = distinct !DISubprogram(name: "Op", linkageName: "_COp.f58524831c37807e:core.Destroy.Core", scope: null, file: !4, line: 29, type: !15, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !64)
|
||||
// CHECK:STDOUT: !62 = !DILocalVariable(arg: 1, scope: !61, type: !6)
|
||||
// CHECK:STDOUT: !63 = !DILocation(line: 29, column: 3, scope: !61)
|
||||
// CHECK:STDOUT: !64 = !{!62}
|
||||
|
||||
Reference in New Issue
Block a user