Classify classes with no struct fields as trivially destructible (#7846)

This commit is contained in:
Christopher Di Bella
2026-09-28 22:39:03 +00:00
committed by GitHub
parent e530421ba1
commit b227419d8d
227 changed files with 9144 additions and 12453 deletions
@@ -142,7 +142,7 @@ fn Run() {
// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon1AD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %this.addr = alloca ptr, align 8
// CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !83
// CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !75
// CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8
// CHECK:STDOUT: call void @"_C__destroy_thunk:thunk.A.Main"(ptr noundef nonnull align 1 %this1)
// CHECK:STDOUT: ret void
@@ -160,7 +160,7 @@ fn Run() {
// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN6Carbon1BD2Ev(ptr noundef nonnull align 1 %this) unnamed_addr #3 comdat align 2 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: %this.addr = alloca ptr, align 8
// CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !85
// CHECK:STDOUT: store ptr %this, ptr %this.addr, align 8, !tbaa !77
// CHECK:STDOUT: %this1 = load ptr, ptr %this.addr, align 8
// CHECK:STDOUT: call void @"_C__destroy_thunk:thunk.B.Main"(ptr noundef nonnull align 1 %this1)
// CHECK:STDOUT: ret void
@@ -195,71 +195,57 @@ fn Run() {
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define weak_odr void @"_CSubobjectDestroy.5a23cc09585c55d2:core.Destroy.Core"(ptr %self) #4 !dbg !36 {
// CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.5a23cc09585c55d2:core.Destroy.Core"(ptr %self) #4 !dbg !36 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: ret void, !dbg !38
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.5a23cc09585c55d2:core.Destroy.Core"(ptr %self) #4 !dbg !40 {
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
// CHECK:STDOUT: define weak_odr void @"_C__destroy_thunk:thunk.B.Main"(ptr %self) #5 !dbg !40 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @"_CSubobjectDestroy.5a23cc09585c55d2:core.Destroy.Core"(ptr %self), !dbg !42
// CHECK:STDOUT: call void @"_CSelfDestruct.8c4b83ecd900f1ea:core.Destroy.Core"(ptr %self), !dbg !42
// CHECK:STDOUT: ret void, !dbg !42
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
// CHECK:STDOUT: define weak_odr void @"_C__destroy_thunk:thunk.B.Main"(ptr %self) #5 !dbg !44 {
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.8c4b83ecd900f1ea:core.Destroy.Core"(ptr %self) #4 !dbg !44 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @"_CSelfDestruct.8c4b83ecd900f1ea:core.Destroy.Core"(ptr %self), !dbg !46
// CHECK:STDOUT: ret void, !dbg !46
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define weak_odr void @"_CSubobjectDestroy.8c4b83ecd900f1ea:core.Destroy.Core"(ptr %self) #4 !dbg !48 {
// CHECK:STDOUT: define void @_CF__carbon_thunk.26f2099a79512a5d.Main(ptr %_) #4 !dbg !48 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @_CF.Main.6662a1ffb773360a(ptr %_), !dbg !50
// CHECK:STDOUT: ret void, !dbg !50
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.8c4b83ecd900f1ea:core.Destroy.Core"(ptr %self) #4 !dbg !52 {
// CHECK:STDOUT: define void @_CF__carbon_thunk.7a3b9f04ddf4269e.Main(ptr %_) #4 !dbg !52 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @"_CSubobjectDestroy.8c4b83ecd900f1ea:core.Destroy.Core"(ptr %self), !dbg !54
// CHECK:STDOUT: call void @_CF.Main.d53b17eed3ce903c(ptr %_), !dbg !54
// CHECK:STDOUT: ret void, !dbg !54
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define void @_CF__carbon_thunk.26f2099a79512a5d.Main(ptr %_) #4 !dbg !56 {
// CHECK:STDOUT: define i32 @main() #4 !dbg !56 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @_CF.Main.6662a1ffb773360a(ptr %_), !dbg !58
// CHECK:STDOUT: ret void, !dbg !58
// CHECK:STDOUT: call void @_Z1Gv(), !dbg !57
// CHECK:STDOUT: ret i32 0, !dbg !58
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define void @_CF__carbon_thunk.7a3b9f04ddf4269e.Main(ptr %_) #4 !dbg !60 {
// CHECK:STDOUT: define linkonce_odr void @_CF.Main.6662a1ffb773360a(ptr %t) #4 !dbg !59 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @_CF.Main.d53b17eed3ce903c(ptr %_), !dbg !62
// CHECK:STDOUT: ret void, !dbg !62
// CHECK:STDOUT: call void @"_CDoit.A.Main:I.Main"(ptr %t), !dbg !62
// CHECK:STDOUT: ret void, !dbg !63
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define i32 @main() #4 !dbg !64 {
// CHECK:STDOUT: define linkonce_odr void @_CF.Main.d53b17eed3ce903c(ptr %t) #4 !dbg !65 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @_Z1Gv(), !dbg !65
// CHECK:STDOUT: ret i32 0, !dbg !66
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define linkonce_odr void @_CF.Main.6662a1ffb773360a(ptr %t) #4 !dbg !67 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @"_CDoit.A.Main:I.Main"(ptr %t), !dbg !70
// CHECK:STDOUT: ret void, !dbg !71
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; Function Attrs: nounwind
// CHECK:STDOUT: define linkonce_odr void @_CF.Main.d53b17eed3ce903c(ptr %t) #4 !dbg !73 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT: call void @"_CDoit.B.Main:I.Main"(ptr %t), !dbg !76
// CHECK:STDOUT: ret void, !dbg !77
// CHECK:STDOUT: call void @"_CDoit.B.Main:I.Main"(ptr %t), !dbg !68
// CHECK:STDOUT: ret void, !dbg !69
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: ; uselistorder directives
@@ -276,8 +262,8 @@ fn Run() {
// CHECK:STDOUT: attributes #5 = { alwaysinline nounwind }
// CHECK:STDOUT:
// CHECK:STDOUT: !llvm.dbg.cu = !{!9}
// CHECK:STDOUT: !llvm.module.flags = !{!86, !87, !88, !4, !5}
// CHECK:STDOUT: !llvm.errno.tbaa = !{!91}
// CHECK:STDOUT: !llvm.module.flags = !{!78, !79, !80, !4, !5}
// CHECK:STDOUT: !llvm.errno.tbaa = !{!83}
// CHECK:STDOUT:
// CHECK:STDOUT: !4 = !{i32 7, !"Dwarf Version", i32 5}
// CHECK:STDOUT: !5 = !{i32 2, !"Debug Info Version", i32 3}
@@ -305,58 +291,50 @@ fn Run() {
// CHECK:STDOUT: !33 = !DILocalVariable(arg: 1, scope: !32, type: !10)
// CHECK:STDOUT: !34 = !DILocation(line: 8, column: 1, scope: !32)
// CHECK:STDOUT: !35 = !{!33}
// CHECK:STDOUT: !36 = distinct !DISubprogram(name: "SubobjectDestroy", linkageName: "_CSubobjectDestroy.5a23cc09585c55d2:core.Destroy.Core", scope: null, file: !8, line: 8, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !39)
// CHECK:STDOUT: !36 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.5a23cc09585c55d2:core.Destroy.Core", scope: null, file: !8, line: 8, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !39)
// CHECK:STDOUT: !37 = !DILocalVariable(arg: 1, scope: !36, type: !10)
// CHECK:STDOUT: !38 = !DILocation(line: 8, column: 1, scope: !36)
// CHECK:STDOUT: !39 = !{!37}
// CHECK:STDOUT: !40 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.5a23cc09585c55d2:core.Destroy.Core", scope: null, file: !8, line: 8, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !43)
// CHECK:STDOUT: !40 = distinct !DISubprogram(name: "__destroy_thunk", linkageName: "_C__destroy_thunk:thunk.B.Main", scope: null, file: !8, line: 13, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !43)
// CHECK:STDOUT: !41 = !DILocalVariable(arg: 1, scope: !40, type: !10)
// CHECK:STDOUT: !42 = !DILocation(line: 8, column: 1, scope: !40)
// CHECK:STDOUT: !42 = !DILocation(line: 13, column: 1, scope: !40)
// CHECK:STDOUT: !43 = !{!41}
// CHECK:STDOUT: !44 = distinct !DISubprogram(name: "__destroy_thunk", linkageName: "_C__destroy_thunk:thunk.B.Main", scope: null, file: !8, line: 13, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !47)
// CHECK:STDOUT: !44 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.8c4b83ecd900f1ea:core.Destroy.Core", scope: null, file: !8, line: 13, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !47)
// CHECK:STDOUT: !45 = !DILocalVariable(arg: 1, scope: !44, type: !10)
// CHECK:STDOUT: !46 = !DILocation(line: 13, column: 1, scope: !44)
// CHECK:STDOUT: !47 = !{!45}
// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "SubobjectDestroy", linkageName: "_CSubobjectDestroy.8c4b83ecd900f1ea:core.Destroy.Core", scope: null, file: !8, line: 13, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !51)
// CHECK:STDOUT: !48 = distinct !DISubprogram(name: "F__carbon_thunk.26f2099a79512a5d", linkageName: "_CF__carbon_thunk.26f2099a79512a5d.Main", scope: null, file: !8, line: 19, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !51)
// CHECK:STDOUT: !49 = !DILocalVariable(arg: 1, scope: !48, type: !10)
// CHECK:STDOUT: !50 = !DILocation(line: 13, column: 1, scope: !48)
// CHECK:STDOUT: !50 = !DILocation(line: 19, column: 1, scope: !48)
// CHECK:STDOUT: !51 = !{!49}
// CHECK:STDOUT: !52 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.8c4b83ecd900f1ea:core.Destroy.Core", scope: null, file: !8, line: 13, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !55)
// CHECK:STDOUT: !52 = distinct !DISubprogram(name: "F__carbon_thunk.7a3b9f04ddf4269e", linkageName: "_CF__carbon_thunk.7a3b9f04ddf4269e.Main", scope: null, file: !8, line: 19, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !55)
// CHECK:STDOUT: !53 = !DILocalVariable(arg: 1, scope: !52, type: !10)
// CHECK:STDOUT: !54 = !DILocation(line: 13, column: 1, scope: !52)
// CHECK:STDOUT: !54 = !DILocation(line: 19, column: 1, scope: !52)
// CHECK:STDOUT: !55 = !{!53}
// CHECK:STDOUT: !56 = distinct !DISubprogram(name: "F__carbon_thunk.26f2099a79512a5d", linkageName: "_CF__carbon_thunk.26f2099a79512a5d.Main", scope: null, file: !8, line: 19, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !59)
// CHECK:STDOUT: !57 = !DILocalVariable(arg: 1, scope: !56, type: !10)
// CHECK:STDOUT: !58 = !DILocation(line: 19, column: 1, scope: !56)
// CHECK:STDOUT: !59 = !{!57}
// CHECK:STDOUT: !60 = distinct !DISubprogram(name: "F__carbon_thunk.7a3b9f04ddf4269e", linkageName: "_CF__carbon_thunk.7a3b9f04ddf4269e.Main", scope: null, file: !8, line: 19, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !63)
// CHECK:STDOUT: !61 = !DILocalVariable(arg: 1, scope: !60, type: !10)
// CHECK:STDOUT: !62 = !DILocation(line: 19, column: 1, scope: !60)
// CHECK:STDOUT: !63 = !{!61}
// CHECK:STDOUT: !64 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !8, line: 32, type: !15, spFlags: DISPFlagDefinition, unit: !9)
// CHECK:STDOUT: !65 = !DILocation(line: 33, column: 3, scope: !64)
// CHECK:STDOUT: !66 = !DILocation(line: 32, column: 1, scope: !64)
// CHECK:STDOUT: !67 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main.6662a1ffb773360a", scope: null, file: !8, line: 19, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !72)
// CHECK:STDOUT: !68 = !DILocalVariable(arg: 1, scope: !67, type: !10)
// CHECK:STDOUT: !70 = !DILocation(line: 20, column: 3, scope: !67)
// CHECK:STDOUT: !71 = !DILocation(line: 19, column: 1, scope: !67)
// CHECK:STDOUT: !72 = !{!68}
// CHECK:STDOUT: !73 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main.d53b17eed3ce903c", scope: null, file: !8, line: 19, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !78)
// CHECK:STDOUT: !74 = !DILocalVariable(arg: 1, scope: !73, type: !10)
// CHECK:STDOUT: !76 = !DILocation(line: 20, column: 3, scope: !73)
// CHECK:STDOUT: !77 = !DILocation(line: 19, column: 1, scope: !73)
// CHECK:STDOUT: !78 = !{!74}
// CHECK:STDOUT: !79 = !{!"Simple C++ TBAA"}
// CHECK:STDOUT: !80 = !{!"omnipotent char", !79, i64 0}
// CHECK:STDOUT: !81 = !{!"any pointer", !80, i64 0}
// CHECK:STDOUT: !82 = !{!"p1 _ZTSN6Carbon1AE", !81, i64 0}
// CHECK:STDOUT: !83 = !{!82, !82, i64 0}
// CHECK:STDOUT: !84 = !{!"p1 _ZTSN6Carbon1BE", !81, i64 0}
// CHECK:STDOUT: !85 = !{!84, !84, i64 0}
// CHECK:STDOUT: !86 = !{i32 8, !"PIC Level", i32 2}
// CHECK:STDOUT: !87 = !{i32 7, !"PIE Level", i32 2}
// CHECK:STDOUT: !88 = !{i32 7, !"uwtable", i32 2}
// CHECK:STDOUT: !89 = !{!"int", !80, i64 0}
// CHECK:STDOUT: !90 = !{!"__libc_errno", !89, i64 0}
// CHECK:STDOUT: !91 = !{!90, !89, i64 0}
// CHECK:STDOUT: !56 = distinct !DISubprogram(name: "Run", linkageName: "main", scope: null, file: !8, line: 32, type: !15, spFlags: DISPFlagDefinition, unit: !9)
// CHECK:STDOUT: !57 = !DILocation(line: 33, column: 3, scope: !56)
// CHECK:STDOUT: !58 = !DILocation(line: 32, column: 1, scope: !56)
// CHECK:STDOUT: !59 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main.6662a1ffb773360a", scope: null, file: !8, line: 19, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !64)
// CHECK:STDOUT: !60 = !DILocalVariable(arg: 1, scope: !59, type: !10)
// CHECK:STDOUT: !62 = !DILocation(line: 20, column: 3, scope: !59)
// CHECK:STDOUT: !63 = !DILocation(line: 19, column: 1, scope: !59)
// CHECK:STDOUT: !64 = !{!60}
// CHECK:STDOUT: !65 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main.d53b17eed3ce903c", scope: null, file: !8, line: 19, type: !12, spFlags: DISPFlagDefinition, unit: !9, retainedNodes: !70)
// CHECK:STDOUT: !66 = !DILocalVariable(arg: 1, scope: !65, type: !10)
// CHECK:STDOUT: !68 = !DILocation(line: 20, column: 3, scope: !65)
// CHECK:STDOUT: !69 = !DILocation(line: 19, column: 1, scope: !65)
// CHECK:STDOUT: !70 = !{!66}
// CHECK:STDOUT: !71 = !{!"Simple C++ TBAA"}
// CHECK:STDOUT: !72 = !{!"omnipotent char", !71, i64 0}
// CHECK:STDOUT: !73 = !{!"any pointer", !72, i64 0}
// CHECK:STDOUT: !74 = !{!"p1 _ZTSN6Carbon1AE", !73, i64 0}
// CHECK:STDOUT: !75 = !{!74, !74, i64 0}
// CHECK:STDOUT: !76 = !{!"p1 _ZTSN6Carbon1BE", !73, i64 0}
// CHECK:STDOUT: !77 = !{!76, !76, i64 0}
// CHECK:STDOUT: !78 = !{i32 8, !"PIC Level", i32 2}
// CHECK:STDOUT: !79 = !{i32 7, !"PIE Level", i32 2}
// CHECK:STDOUT: !80 = !{i32 7, !"uwtable", i32 2}
// CHECK:STDOUT: !81 = !{!"int", !72, i64 0}
// CHECK:STDOUT: !82 = !{!"__libc_errno", !81, i64 0}
// CHECK:STDOUT: !83 = !{!82, !81, i64 0}
// CHECK:STDOUT: