mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Improve CanDestroyType to handle remaining cases (#6943)
This is only fixing the decision about *whether* to produce a witness. Implementation of the witness is still a TODO, though where a body is generated, it should also precisely reflect where one _needs_ to be generated. Note the tests: - toolchain/lower/testdata/function/generic/import_core_witness.carbon - toolchain/lower/testdata/function/generic/import_unused_def.carbon These tests can probably be produced _without_ Core.Destroy, but I found the essence of them while trying to build //examples with Core.Destroy and a simpler minimization wasn't striking me. Assisted-by: Google Antigravity with Gemini --------- Co-authored-by: jonmeow <jperkins@google.com>
This commit is contained in:
co-authored by
jonmeow
parent
1fa7a64cd4
commit
9266ced4e3
@@ -34,9 +34,22 @@ fn F() {
|
||||
// CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %s.var, ptr align 4 @struct.ed5.loc16_3, i64 8, i1 false), !dbg !7
|
||||
// CHECK:STDOUT: %.loc17.b = getelementptr inbounds nuw { i32, i32 }, ptr %s.var, i32 0, i32 1, !dbg !9
|
||||
// CHECK:STDOUT: call void @_CG.Main(ptr %.loc17.b), !dbg !10
|
||||
// CHECK:STDOUT: call void @"_COp.fb32c4dfca65e378:core.Destroy.Core"(ptr %s.var), !dbg !7
|
||||
// CHECK:STDOUT: ret void, !dbg !11
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %self) #0 !dbg !12 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !18
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.fb32c4dfca65e378:core.Destroy.Core"(ptr %self) #0 !dbg !19 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !25
|
||||
// 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:
|
||||
@@ -62,3 +75,17 @@ fn F() {
|
||||
// CHECK:STDOUT: !9 = !DILocation(line: 17, column: 6, scope: !4)
|
||||
// CHECK:STDOUT: !10 = !DILocation(line: 17, column: 3, scope: !4)
|
||||
// CHECK:STDOUT: !11 = !DILocation(line: 15, column: 1, scope: !4)
|
||||
// CHECK:STDOUT: !12 = distinct !DISubprogram(name: "Op", linkageName: "_COp.7e389eab4a7e5487:core.Destroy.Core", scope: null, file: !3, line: 16, type: !13, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !16)
|
||||
// CHECK:STDOUT: !13 = !DISubroutineType(types: !14)
|
||||
// CHECK:STDOUT: !14 = !{null, !15}
|
||||
// CHECK:STDOUT: !15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
// CHECK:STDOUT: !16 = !{!17}
|
||||
// CHECK:STDOUT: !17 = !DILocalVariable(arg: 1, scope: !12, type: !15)
|
||||
// CHECK:STDOUT: !18 = !DILocation(line: 16, column: 3, scope: !12)
|
||||
// CHECK:STDOUT: !19 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fb32c4dfca65e378:core.Destroy.Core", scope: null, file: !3, line: 16, type: !20, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !23)
|
||||
// CHECK:STDOUT: !20 = !DISubroutineType(types: !21)
|
||||
// CHECK:STDOUT: !21 = !{null, !22}
|
||||
// CHECK:STDOUT: !22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
|
||||
// CHECK:STDOUT: !23 = !{!24}
|
||||
// CHECK:STDOUT: !24 = !DILocalVariable(arg: 1, scope: !19, type: !22)
|
||||
// CHECK:STDOUT: !25 = !DILocation(line: 16, column: 3, scope: !19)
|
||||
|
||||
@@ -24,9 +24,16 @@ fn F() {
|
||||
// CHECK:STDOUT: %n.var = alloca i32, align 4, !dbg !7
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n.var), !dbg !7
|
||||
// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !7
|
||||
// CHECK:STDOUT: call void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %n.var), !dbg !7
|
||||
// CHECK:STDOUT: ret void, !dbg !8
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %self) #0 !dbg !9 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !15
|
||||
// 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:
|
||||
@@ -45,3 +52,10 @@ fn F() {
|
||||
// CHECK:STDOUT: !6 = !{null}
|
||||
// CHECK:STDOUT: !7 = !DILocation(line: 14, column: 3, scope: !4)
|
||||
// CHECK:STDOUT: !8 = !DILocation(line: 13, column: 1, scope: !4)
|
||||
// CHECK:STDOUT: !9 = distinct !DISubprogram(name: "Op", linkageName: "_COp.7e389eab4a7e5487:core.Destroy.Core", scope: null, file: !3, line: 14, type: !10, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !13)
|
||||
// CHECK:STDOUT: !10 = !DISubroutineType(types: !11)
|
||||
// CHECK:STDOUT: !11 = !{null, !12}
|
||||
// CHECK:STDOUT: !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
||||
// CHECK:STDOUT: !13 = !{!14}
|
||||
// CHECK:STDOUT: !14 = !DILocalVariable(arg: 1, scope: !9, type: !12)
|
||||
// CHECK:STDOUT: !15 = !DILocation(line: 14, column: 3, scope: !9)
|
||||
|
||||
+13
@@ -36,9 +36,16 @@ fn F() -> i32 {
|
||||
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n.var), !dbg !16
|
||||
// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !16
|
||||
// CHECK:STDOUT: %G.call = call i32 @_CG.Main(ptr %n.var), !dbg !17
|
||||
// CHECK:STDOUT: call void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %n.var), !dbg !16
|
||||
// CHECK:STDOUT: ret i32 %G.call, !dbg !18
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define weak_odr void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %self) #0 !dbg !19 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: ret void, !dbg !24
|
||||
// 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:
|
||||
@@ -67,3 +74,9 @@ fn F() -> i32 {
|
||||
// CHECK:STDOUT: !16 = !DILocation(line: 18, column: 3, scope: !13)
|
||||
// CHECK:STDOUT: !17 = !DILocation(line: 19, column: 10, scope: !13)
|
||||
// CHECK:STDOUT: !18 = !DILocation(line: 19, column: 3, scope: !13)
|
||||
// CHECK:STDOUT: !19 = distinct !DISubprogram(name: "Op", linkageName: "_COp.7e389eab4a7e5487:core.Destroy.Core", scope: null, file: !3, line: 18, type: !20, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !22)
|
||||
// CHECK:STDOUT: !20 = !DISubroutineType(types: !21)
|
||||
// CHECK:STDOUT: !21 = !{null, !7}
|
||||
// CHECK:STDOUT: !22 = !{!23}
|
||||
// CHECK:STDOUT: !23 = !DILocalVariable(arg: 1, scope: !19, type: !7)
|
||||
// CHECK:STDOUT: !24 = !DILocation(line: 18, column: 3, scope: !19)
|
||||
|
||||
Reference in New Issue
Block a user