mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 08:44:41 +01:00
Change the Destroy blanket impls to be more specific (#6098)
The main direction of this change is the edits to `destroy.carbon` (matching in both prelude and min_prelude). Previously there was a no-op blanket impl for `Destroy`, which hid all missing implementations of `Destroy`. This does a few things: - Sets up builtin aggregate destruction for struct and tuple types as before, but also adds C++ class types and array types to the same handling. (all as a TODO for actual implementation) - Also maybe-unformed destruction, for now at least. (there's a chance I may try a different approach on this, but the impl lookup wasn't working as I'd hope in order to write it in code) - Adds handlers for simple things that are easy to do in code: `type`, `bool`, pointers. (because these are no-op destruction) - Redirect `const T` destruction to `T` destruction. This leaves as future issues: - `partial T` destruction. (this can't be done similar to `const` because it only works for non-`final` class types; I think `class` definitions should just generate what's needed) - Destruction of other prelude-provided types. (will probably come up as we implement class destruction, that the adapted builtin type doesn't implement `Destroy` -- but may end up special-casing that in a way that moots it) This moves the `&` operator from `facet_types.carbon` to `convert.carbon` because more things need to handle type and now that we're getting separate copy and destroy interfaces. It should be low-cost (an interface and builtin) so hopefully this is the right balance for complexity and re-use. A few tests are also edited in order to focus them more on what they intend to test, and avoid a `Destroy` dependency.
This commit is contained in:
@@ -25,7 +25,7 @@ fn H[T:! Core.Copy](x: T) -> T {
|
||||
|
||||
// Simple stress test for single depth of calls with change in types.
|
||||
// Check definitions are emitted for each specific.
|
||||
fn G[T:! Core.Copy](x: T) -> T {
|
||||
fn G[T:! Core.Copy & Core.Destroy](x: T) -> T {
|
||||
H(x);
|
||||
H(i32);
|
||||
H(G(x));
|
||||
@@ -85,12 +85,12 @@ fn M() {
|
||||
// CHECK:STDOUT: %.loc54 = load i32, ptr %n.var, align 4, !dbg !13
|
||||
// CHECK:STDOUT: call void @_CF.Main.b88d1103f417c6d4(i32 %.loc54), !dbg !14
|
||||
// CHECK:STDOUT: %.loc55_9 = load i32, ptr %n.var, align 4, !dbg !15
|
||||
// CHECK:STDOUT: %G.call.loc55 = call i32 @_CG.Main.de631560529e9861(i32 %.loc55_9), !dbg !16
|
||||
// CHECK:STDOUT: %G.call.loc55 = call i32 @_CG.Main.dedae426f8f6526d(i32 %.loc55_9), !dbg !16
|
||||
// CHECK:STDOUT: store i32 %G.call.loc55, ptr %m.var, align 4, !dbg !17
|
||||
// CHECK:STDOUT: %.loc56 = load double, ptr %p.var, align 8, !dbg !18
|
||||
// CHECK:STDOUT: call void @_CF.Main.d4b5665541d5d7a8(double %.loc56), !dbg !19
|
||||
// CHECK:STDOUT: %.loc57_9 = load double, ptr %p.var, align 8, !dbg !20
|
||||
// CHECK:STDOUT: %G.call.loc57 = call double @_CG.Main.3836ccc537683c19(double %.loc57_9), !dbg !21
|
||||
// CHECK:STDOUT: %G.call.loc57 = call double @_CG.Main.42589ad6dce0869e(double %.loc57_9), !dbg !21
|
||||
// CHECK:STDOUT: store double %G.call.loc57, ptr %q.var, align 8, !dbg !22
|
||||
// CHECK:STDOUT: ret void, !dbg !23
|
||||
// CHECK:STDOUT: }
|
||||
@@ -106,7 +106,7 @@ fn M() {
|
||||
// CHECK:STDOUT: ret void, !dbg !25
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: define linkonce_odr i32 @_CG.Main.de631560529e9861(i32 %x) !dbg !26 {
|
||||
// CHECK:STDOUT: define linkonce_odr i32 @_CG.Main.dedae426f8f6526d(i32 %x) !dbg !26 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc29_6.3.temp = alloca i32, align 4, !dbg !27
|
||||
// CHECK:STDOUT: %.loc31_8.3.temp = alloca i32, align 4, !dbg !28
|
||||
@@ -122,7 +122,7 @@ fn M() {
|
||||
// CHECK:STDOUT: store i32 %H.call.loc29, ptr %.loc29_6.3.temp, align 4, !dbg !27
|
||||
// CHECK:STDOUT: %H.call.loc30 = call %type @_CH.Main.402deed6b8733082(%type zeroinitializer), !dbg !36
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc31_8.3.temp), !dbg !28
|
||||
// CHECK:STDOUT: %G.call = call i32 @_CG.Main.de631560529e9861(i32 %x), !dbg !28
|
||||
// CHECK:STDOUT: %G.call = call i32 @_CG.Main.dedae426f8f6526d(i32 %x), !dbg !28
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc31_9.3.temp), !dbg !29
|
||||
// CHECK:STDOUT: store i32 %G.call, ptr %.loc31_8.3.temp, align 4, !dbg !28
|
||||
// CHECK:STDOUT: %.loc31_8.5 = load i32, ptr %.loc31_8.3.temp, align 4, !dbg !28
|
||||
@@ -151,7 +151,7 @@ fn M() {
|
||||
// CHECK:STDOUT: ret void, !dbg !47
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: define linkonce_odr double @_CG.Main.3836ccc537683c19(double %x) !dbg !48 {
|
||||
// CHECK:STDOUT: define linkonce_odr double @_CG.Main.42589ad6dce0869e(double %x) !dbg !48 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %.loc29_6.3.temp = alloca double, align 8, !dbg !49
|
||||
// CHECK:STDOUT: %.loc31_8.3.temp = alloca double, align 8, !dbg !50
|
||||
@@ -167,7 +167,7 @@ fn M() {
|
||||
// CHECK:STDOUT: store double %H.call.loc29, ptr %.loc29_6.3.temp, align 8, !dbg !49
|
||||
// CHECK:STDOUT: %H.call.loc30 = call %type @_CH.Main.402deed6b8733082(%type zeroinitializer), !dbg !58
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc31_8.3.temp), !dbg !50
|
||||
// CHECK:STDOUT: %G.call = call double @_CG.Main.3836ccc537683c19(double %x), !dbg !50
|
||||
// CHECK:STDOUT: %G.call = call double @_CG.Main.42589ad6dce0869e(double %x), !dbg !50
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc31_9.3.temp), !dbg !51
|
||||
// CHECK:STDOUT: store double %G.call, ptr %.loc31_8.3.temp, align 8, !dbg !50
|
||||
// CHECK:STDOUT: %.loc31_8.5 = load double, ptr %.loc31_8.3.temp, align 8, !dbg !50
|
||||
@@ -257,7 +257,7 @@ fn M() {
|
||||
// CHECK:STDOUT: !23 = !DILocation(line: 48, column: 1, scope: !8)
|
||||
// CHECK:STDOUT: !24 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main.b88d1103f417c6d4", scope: null, file: !3, line: 19, type: !5, spFlags: DISPFlagDefinition, unit: !2)
|
||||
// CHECK:STDOUT: !25 = !DILocation(line: 19, column: 1, scope: !24)
|
||||
// CHECK:STDOUT: !26 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.de631560529e9861", scope: null, file: !3, line: 28, type: !5, spFlags: DISPFlagDefinition, unit: !2)
|
||||
// CHECK:STDOUT: !26 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.dedae426f8f6526d", scope: null, file: !3, line: 28, type: !5, spFlags: DISPFlagDefinition, unit: !2)
|
||||
// CHECK:STDOUT: !27 = !DILocation(line: 29, column: 3, scope: !26)
|
||||
// CHECK:STDOUT: !28 = !DILocation(line: 31, column: 5, scope: !26)
|
||||
// CHECK:STDOUT: !29 = !DILocation(line: 31, column: 3, scope: !26)
|
||||
@@ -279,7 +279,7 @@ fn M() {
|
||||
// CHECK:STDOUT: !45 = !DILocation(line: 45, column: 3, scope: !26)
|
||||
// CHECK:STDOUT: !46 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main.d4b5665541d5d7a8", scope: null, file: !3, line: 19, type: !5, spFlags: DISPFlagDefinition, unit: !2)
|
||||
// CHECK:STDOUT: !47 = !DILocation(line: 19, column: 1, scope: !46)
|
||||
// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.3836ccc537683c19", scope: null, file: !3, line: 28, type: !5, spFlags: DISPFlagDefinition, unit: !2)
|
||||
// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "G", linkageName: "_CG.Main.42589ad6dce0869e", scope: null, file: !3, line: 28, type: !5, spFlags: DISPFlagDefinition, unit: !2)
|
||||
// CHECK:STDOUT: !49 = !DILocation(line: 29, column: 3, scope: !48)
|
||||
// CHECK:STDOUT: !50 = !DILocation(line: 31, column: 5, scope: !48)
|
||||
// CHECK:STDOUT: !51 = !DILocation(line: 31, column: 3, scope: !48)
|
||||
|
||||
Reference in New Issue
Block a user