mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:42:01 +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:
+5
-5
@@ -42,18 +42,18 @@ fn G() -> i32 {
|
||||
// CHECK:STDOUT: %.loc18_20.7.array.index = getelementptr inbounds [3 x i32], ptr %.loc18_20.3.temp, i32 0, i64 1, !dbg !44
|
||||
// CHECK:STDOUT: %.loc18_20.10.array.index = getelementptr inbounds [3 x i32], ptr %.loc18_20.3.temp, i32 0, i64 2, !dbg !44
|
||||
// CHECK:STDOUT: %F.call = call i32 @_CF.Main(ptr @array.loc18_20.15, i32 1), !dbg !45
|
||||
// CHECK:STDOUT: call void @"_COp.3bc428c96004ce87:core.Destroy.Core"(ptr @array), !dbg !44
|
||||
// CHECK:STDOUT: call void @"_COp.dc7dedd104b837b2:core.Destroy.Core"(ptr @array), !dbg !44
|
||||
// CHECK:STDOUT: ret i32 %F.call, !dbg !46
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.70db2d92ffddbef7:core.Destroy.Core"(ptr %self) #0 !dbg !47 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %self) #0 !dbg !47 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !49
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.3bc428c96004ce87:core.Destroy.Core"(ptr %self) #0 !dbg !51 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.dc7dedd104b837b2:core.Destroy.Core"(ptr %self) #0 !dbg !51 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !53
|
||||
// CHECK:STDOUT: }
|
||||
@@ -91,11 +91,11 @@ fn G() -> i32 {
|
||||
// CHECK:STDOUT: !44 = !DILocation(line: 18, column: 12, scope: !41)
|
||||
// CHECK:STDOUT: !45 = !DILocation(line: 18, column: 10, scope: !41)
|
||||
// CHECK:STDOUT: !46 = !DILocation(line: 18, column: 3, scope: !41)
|
||||
// CHECK:STDOUT: !47 = distinct !DISubprogram(name: "Op", linkageName: "_COp.70db2d92ffddbef7:core.Destroy.Core", scope: null, file: !18, line: 18, type: !27, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !50)
|
||||
// CHECK:STDOUT: !47 = distinct !DISubprogram(name: "Op", linkageName: "_COp.f58524831c37807e:core.Destroy.Core", scope: null, file: !18, line: 18, type: !27, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !50)
|
||||
// CHECK:STDOUT: !48 = !DILocalVariable(arg: 1, scope: !47, type: !20)
|
||||
// CHECK:STDOUT: !49 = !DILocation(line: 18, column: 12, scope: !47)
|
||||
// CHECK:STDOUT: !50 = !{!48}
|
||||
// CHECK:STDOUT: !51 = distinct !DISubprogram(name: "Op", linkageName: "_COp.3bc428c96004ce87:core.Destroy.Core", scope: null, file: !18, line: 18, type: !29, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !54)
|
||||
// CHECK:STDOUT: !51 = distinct !DISubprogram(name: "Op", linkageName: "_COp.dc7dedd104b837b2:core.Destroy.Core", scope: null, file: !18, line: 18, type: !29, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !54)
|
||||
// CHECK:STDOUT: !52 = !DILocalVariable(arg: 1, scope: !51, type: !21)
|
||||
// CHECK:STDOUT: !53 = !DILocation(line: 18, column: 12, scope: !51)
|
||||
// CHECK:STDOUT: !54 = !{!52}
|
||||
|
||||
Reference in New Issue
Block a user