mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 09:34:42 +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:
+3
-3
@@ -37,12 +37,12 @@ fn F() -> i32 {
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n.var), !dbg !40
|
||||
// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !40
|
||||
// CHECK:STDOUT: %G.call = call i32 @_CG.Main(ptr %n.var), !dbg !44
|
||||
// CHECK:STDOUT: call void @"_COp.70db2d92ffddbef7:core.Destroy.Core"(ptr %n.var), !dbg !40
|
||||
// CHECK:STDOUT: call void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %n.var), !dbg !40
|
||||
// CHECK:STDOUT: ret i32 %G.call, !dbg !45
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.70db2d92ffddbef7:core.Destroy.Core"(ptr %self) #0 !dbg !46 {
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %self) #0 !dbg !46 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !48
|
||||
// CHECK:STDOUT: }
|
||||
@@ -77,7 +77,7 @@ fn F() -> i32 {
|
||||
// CHECK:STDOUT: !40 = !DILocation(line: 18, column: 3, scope: !37)
|
||||
// CHECK:STDOUT: !44 = !DILocation(line: 19, column: 10, scope: !37)
|
||||
// CHECK:STDOUT: !45 = !DILocation(line: 19, column: 3, scope: !37)
|
||||
// CHECK:STDOUT: !46 = distinct !DISubprogram(name: "Op", linkageName: "_COp.70db2d92ffddbef7:core.Destroy.Core", scope: null, file: !18, line: 18, type: !27, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !49)
|
||||
// CHECK:STDOUT: !46 = distinct !DISubprogram(name: "Op", linkageName: "_COp.f58524831c37807e:core.Destroy.Core", scope: null, file: !18, line: 18, type: !27, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !49)
|
||||
// CHECK:STDOUT: !47 = !DILocalVariable(arg: 1, scope: !46, type: !20)
|
||||
// CHECK:STDOUT: !48 = !DILocation(line: 18, column: 3, scope: !46)
|
||||
// CHECK:STDOUT: !49 = !{!47}
|
||||
|
||||
Reference in New Issue
Block a user