mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-22 12:42:39 +00:00
Move SubobjectDestroy and SelfDestruct out of interface Destroy (#7942)
Determining that a type has trivial destruction requires checking whether all of its subobjects have trivial destruction and whether its type has a custom witness for `Destroy.Op`. This isn't possible when `Destroy` is the custodian for `Destroy.Op` and `SubobjectDestroy.Op`, so we need to make `SubobjectDestroy` its own interface. `Destroy.SelfDestruct` becomes a standalone function because it depends on `SubobjectDestroy` and `Destroy` being implemented, and is also responsible for generating any custom witnesses for both interfaces. Making `SelfDestruct` an interface was experimented with, but this required a blanket impl that caused issues for facet types. `Destroy` depends on `SubobjectDestroy` to be implemented. We'd ideally use `require impls SubobjectDestroy`, but it isn't complete yet, and it also causes problems when `Destroy` is implemented inside the class definition. We work around this by temporarily renaming the `Destroy` interface to `DestroyImpl`, and introducing a constraint called `Destroy` so that user code doesn't need to write `Core.SubobjectDestroy & Core.Destroy`.
This commit is contained in:
1 parent
57bf903ef1
commit
05a7ecbd34
357 files changed
+41452
-59092
No files matched your search
+49
-50
@@ -22,45 +22,43 @@ fn F(p: i32**) -> i32 {
|
||||
// CHECK:STDOUT: source_filename = "pointer_to_pointer.carbon"
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define i32 @_CF.Main(ptr %p) #0 !dbg !26 {
|
||||
// CHECK:STDOUT: define i32 @_CF.Main(ptr %p) #0 !dbg !24 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %_.var = alloca ptr, align 8, !dbg !31
|
||||
// CHECK:STDOUT: %b.var = alloca ptr, align 8, !dbg !34
|
||||
// CHECK:STDOUT: %c.var = alloca ptr, align 8, !dbg !38
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %_.var), !dbg !31
|
||||
// CHECK:STDOUT: store ptr %p, ptr %_.var, align 8, !dbg !31
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %b.var), !dbg !34
|
||||
// CHECK:STDOUT: %.loc15_17.2 = load ptr, ptr %p, align 8, !dbg !36
|
||||
// CHECK:STDOUT: store ptr %.loc15_17.2, ptr %b.var, align 8, !dbg !34
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c.var), !dbg !38
|
||||
// CHECK:STDOUT: store ptr %b.var, ptr %c.var, align 8, !dbg !38
|
||||
// CHECK:STDOUT: %.loc17_12 = load ptr, ptr %c.var, align 8, !dbg !42
|
||||
// CHECK:STDOUT: %.loc17_11.2 = load ptr, ptr %.loc17_12, align 8, !dbg !43
|
||||
// CHECK:STDOUT: %.loc17_10.2 = load i32, ptr %.loc17_11.2, align 4, !dbg !44
|
||||
// CHECK:STDOUT: call void @"_CSelfDestruct.8609a36981aa979c:core.Destroy.Core"(ptr %c.var), !dbg !38
|
||||
// CHECK:STDOUT: call void @"_CSelfDestruct.a17e1ddde5b22223:core.Destroy.Core"(ptr %b.var), !dbg !34
|
||||
// CHECK:STDOUT: call void @"_CSelfDestruct.8609a36981aa979c:core.Destroy.Core"(ptr %_.var), !dbg !31
|
||||
// CHECK:STDOUT: %_.var = alloca ptr, align 8, !dbg !29
|
||||
// CHECK:STDOUT: %b.var = alloca ptr, align 8, !dbg !32
|
||||
// CHECK:STDOUT: %c.var = alloca ptr, align 8, !dbg !36
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %_.var), !dbg !29
|
||||
// CHECK:STDOUT: store ptr %p, ptr %_.var, align 8, !dbg !29
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %b.var), !dbg !32
|
||||
// CHECK:STDOUT: %.loc15_17.2 = load ptr, ptr %p, align 8, !dbg !34
|
||||
// CHECK:STDOUT: store ptr %.loc15_17.2, ptr %b.var, align 8, !dbg !32
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c.var), !dbg !36
|
||||
// CHECK:STDOUT: store ptr %b.var, ptr %c.var, align 8, !dbg !36
|
||||
// CHECK:STDOUT: %.loc17_12 = load ptr, ptr %c.var, align 8, !dbg !40
|
||||
// CHECK:STDOUT: %.loc17_11.2 = load ptr, ptr %.loc17_12, align 8, !dbg !41
|
||||
// CHECK:STDOUT: %.loc17_10.2 = load i32, ptr %.loc17_11.2, align 4, !dbg !42
|
||||
// CHECK:STDOUT: call void @_CSelfDestruct.Core.fe9506775ab787b4(ptr %c.var), !dbg !36
|
||||
// CHECK:STDOUT: call void @_CSelfDestruct.Core.4f29d15a20894e9b(ptr %b.var), !dbg !32
|
||||
// CHECK:STDOUT: call void @_CSelfDestruct.Core.fe9506775ab787b4(ptr %_.var), !dbg !29
|
||||
// CHECK:STDOUT: ret i32 %.loc17_10.2, !dbg !45
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.8609a36981aa979c: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 @"_CSelfDestruct.a17e1ddde5b22223:core.Destroy.Core"(ptr %self) #0 !dbg !51 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !53
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
|
||||
// CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CSelfDestruct.Core.fe9506775ab787b4(ptr %t) #0 !dbg !47 {
|
||||
// CHECK:STDOUT: ret void, !dbg !52
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define linkonce_odr void @_CSelfDestruct.Core.4f29d15a20894e9b(ptr %t) #0 !dbg !54 {
|
||||
// CHECK:STDOUT: ret void, !dbg !59
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; uselistorder directives
|
||||
// CHECK:STDOUT: uselistorder ptr @"_CSelfDestruct.8609a36981aa979c:core.Destroy.Core", { 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 2, 1, 0 }
|
||||
// CHECK:STDOUT: uselistorder ptr @_CSelfDestruct.Core.fe9506775ab787b4, { 1, 0 }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: attributes #0 = { nounwind }
|
||||
// CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
|
||||
@@ -70,31 +68,32 @@ fn F(p: i32**) -> i32 {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5}
|
||||
// CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
// CHECK:STDOUT: !10 = !DIFile(filename: "min_prelude/parts/destroy.carbon", directory: "")
|
||||
// CHECK:STDOUT: !18 = !DIFile(filename: "pointer_to_pointer.carbon", directory: "")
|
||||
// CHECK:STDOUT: !19 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !18, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
|
||||
// CHECK:STDOUT: !20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
// CHECK:STDOUT: !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
||||
// CHECK:STDOUT: !22 = !{!20, !21}
|
||||
// CHECK:STDOUT: !23 = !DISubroutineType(types: !22)
|
||||
// CHECK:STDOUT: !24 = !{null, !21}
|
||||
// CHECK:STDOUT: !25 = !DISubroutineType(types: !24)
|
||||
// CHECK:STDOUT: !26 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !18, line: 13, type: !23, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !46)
|
||||
// CHECK:STDOUT: !27 = !DILocalVariable(arg: 1, scope: !26, type: !21)
|
||||
// CHECK:STDOUT: !31 = !DILocation(line: 14, column: 3, scope: !26)
|
||||
// CHECK:STDOUT: !34 = !DILocation(line: 15, column: 3, scope: !26)
|
||||
// CHECK:STDOUT: !36 = !DILocation(line: 15, column: 17, scope: !26)
|
||||
// CHECK:STDOUT: !38 = !DILocation(line: 16, column: 3, scope: !26)
|
||||
// CHECK:STDOUT: !42 = !DILocation(line: 17, column: 12, scope: !26)
|
||||
// CHECK:STDOUT: !43 = !DILocation(line: 17, column: 11, scope: !26)
|
||||
// CHECK:STDOUT: !44 = !DILocation(line: 17, column: 10, scope: !26)
|
||||
// CHECK:STDOUT: !45 = !DILocation(line: 17, column: 3, scope: !26)
|
||||
// CHECK:STDOUT: !46 = !{!27}
|
||||
// CHECK:STDOUT: !47 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.8609a36981aa979c:core.Destroy.Core", scope: null, file: !18, line: 16, type: !25, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !50)
|
||||
// CHECK:STDOUT: !24 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !18, line: 13, type: !23, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !46)
|
||||
// CHECK:STDOUT: !25 = !DILocalVariable(arg: 1, scope: !24, type: !21)
|
||||
// CHECK:STDOUT: !29 = !DILocation(line: 14, column: 3, scope: !24)
|
||||
// CHECK:STDOUT: !32 = !DILocation(line: 15, column: 3, scope: !24)
|
||||
// CHECK:STDOUT: !34 = !DILocation(line: 15, column: 17, scope: !24)
|
||||
// CHECK:STDOUT: !36 = !DILocation(line: 16, column: 3, scope: !24)
|
||||
// CHECK:STDOUT: !40 = !DILocation(line: 17, column: 12, scope: !24)
|
||||
// CHECK:STDOUT: !41 = !DILocation(line: 17, column: 11, scope: !24)
|
||||
// CHECK:STDOUT: !42 = !DILocation(line: 17, column: 10, scope: !24)
|
||||
// CHECK:STDOUT: !43 = !{null, !21}
|
||||
// CHECK:STDOUT: !44 = !DISubroutineType(types: !43)
|
||||
// CHECK:STDOUT: !45 = !DILocation(line: 17, column: 3, scope: !24)
|
||||
// CHECK:STDOUT: !46 = !{!25}
|
||||
// CHECK:STDOUT: !47 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.Core.fe9506775ab787b4", scope: null, file: !10, line: 32, type: !44, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !53)
|
||||
// CHECK:STDOUT: !48 = !DILocalVariable(arg: 1, scope: !47, type: !21)
|
||||
// CHECK:STDOUT: !49 = !DILocation(line: 16, column: 3, scope: !47)
|
||||
// CHECK:STDOUT: !50 = !{!48}
|
||||
// CHECK:STDOUT: !51 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.a17e1ddde5b22223:core.Destroy.Core", scope: null, file: !18, line: 15, type: !25, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !54)
|
||||
// CHECK:STDOUT: !52 = !DILocalVariable(arg: 1, scope: !51, type: !21)
|
||||
// CHECK:STDOUT: !53 = !DILocation(line: 15, column: 3, scope: !51)
|
||||
// CHECK:STDOUT: !54 = !{!52}
|
||||
// CHECK:STDOUT: !52 = !DILocation(line: 32, column: 1, scope: !47)
|
||||
// CHECK:STDOUT: !53 = !{!48}
|
||||
// CHECK:STDOUT: !54 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.Core.4f29d15a20894e9b", scope: null, file: !10, line: 32, type: !44, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !60)
|
||||
// CHECK:STDOUT: !55 = !DILocalVariable(arg: 1, scope: !54, type: !21)
|
||||
// CHECK:STDOUT: !59 = !DILocation(line: 32, column: 1, scope: !54)
|
||||
// CHECK:STDOUT: !60 = !{!55}
|
||||
// CHECK:STDOUT:
|
||||
Reference in new issue
Block a user