// Part of the Carbon Language project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon // // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/struct/layout.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/struct/layout.carbon // --- no_padding.carbon library "[[@TEST_NAME]]"; fn G(p: i32*); fn F() { // LLVM {i32, i32, i32} matches the Carbon layout, so we use it. var no_padding: {.x: i32, .y: i32, .z: i32}; G(&no_padding.x); G(&no_padding.y); G(&no_padding.z); } // --- avoid_tail_padding.carbon library "[[@TEST_NAME]]"; fn G(p: i32*); fn F() { // LLVM {ptr, i32} would have a size of 16, so we use a packed struct. var avoid_tail_padding: {.x: ()*, .y: i32}; G(&avoid_tail_padding.y); } // --- use_tail_padding.carbon library "[[@TEST_NAME]]"; fn G(p: i32*); fn F() { // LLVM {ptr, i32} would have a size of 16, so we use a packed struct as the // type of `.a`. `.b` goes in the tail padding. var use_tail_padding: {.a: {.x: ()*, .y: i32}, .b: i32}; G(&use_tail_padding.a.y); G(&use_tail_padding.b); } // --- implicit_padding.carbon library "[[@TEST_NAME]]"; fn G(p: ()**); fn F() { // LLVM {<{ptr, i32}>, ptr} inserts the right padding before `.b`, so we use // it directly. var implicit_padding: {.a: {.x: ()*, .y: i32}, .b: ()*}; G(&implicit_padding.a.x); G(&implicit_padding.b); } // --- insert_padding.carbon library "[[@TEST_NAME]]"; fn G(p: ()**); fn F() { // LLVM {<{i32, i32, i32}>, ptr, i32} would have extra tail padding, so we use // a packed struct. That requires that we explicitly add padding between `.a` // and `.b`. var insert_padding: {.a: {.x: i32, .y: i32, .z: i32}, .b: ()*, .c: i32}; G(&insert_padding.b); } // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'no_padding.carbon' // CHECK:STDOUT: source_filename = "no_padding.carbon" // CHECK:STDOUT: // CHECK:STDOUT: declare void @_CG.Main(ptr) // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CF.Main() #0 !dbg !28 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %no_padding.var = alloca { i32, i32, i32 }, align 4, !dbg !29 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %no_padding.var), !dbg !29 // CHECK:STDOUT: %.loc8.x = getelementptr inbounds nuw { i32, i32, i32 }, ptr %no_padding.var, i32 0, i32 0, !dbg !31 // CHECK:STDOUT: call void @_CG.Main(ptr %.loc8.x), !dbg !33 // CHECK:STDOUT: %.loc9.y = getelementptr inbounds nuw { i32, i32, i32 }, ptr %no_padding.var, i32 0, i32 1, !dbg !34 // CHECK:STDOUT: call void @_CG.Main(ptr %.loc9.y), !dbg !36 // CHECK:STDOUT: %.loc10.z = getelementptr inbounds nuw { i32, i32, i32 }, ptr %no_padding.var, i32 0, i32 2, !dbg !37 // CHECK:STDOUT: call void @_CG.Main(ptr %.loc10.z), !dbg !39 // CHECK:STDOUT: call void @"_COp.cc12b768126bed5c:core.Destroy.Core"(ptr %no_padding.var), !dbg !29 // CHECK:STDOUT: ret void, !dbg !40 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %self) #0 !dbg !41 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !43 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.cc12b768126bed5c:core.Destroy.Core"(ptr %self) #0 !dbg !45 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !47 // 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: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.dbg.cu = !{!19} // CHECK:STDOUT: !llvm.module.flags = !{!2, !3} // CHECK:STDOUT: // CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3} // CHECK:STDOUT: !18 = !DIFile(filename: "no_padding.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 = !{null, !21} // CHECK:STDOUT: !23 = !DISubroutineType(types: !22) // CHECK:STDOUT: !24 = !{null} // CHECK:STDOUT: !25 = !DISubroutineType(types: !24) // CHECK:STDOUT: !26 = !{null, !20} // CHECK:STDOUT: !27 = !DISubroutineType(types: !26) // CHECK:STDOUT: !28 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !18, line: 5, type: !25, spFlags: DISPFlagDefinition, unit: !19) // CHECK:STDOUT: !29 = !DILocation(line: 7, column: 3, scope: !28) // CHECK:STDOUT: !31 = !DILocation(line: 8, column: 6, scope: !28) // CHECK:STDOUT: !33 = !DILocation(line: 8, column: 3, scope: !28) // CHECK:STDOUT: !34 = !DILocation(line: 9, column: 6, scope: !28) // CHECK:STDOUT: !36 = !DILocation(line: 9, column: 3, scope: !28) // CHECK:STDOUT: !37 = !DILocation(line: 10, column: 6, scope: !28) // CHECK:STDOUT: !39 = !DILocation(line: 10, column: 3, scope: !28) // CHECK:STDOUT: !40 = !DILocation(line: 5, column: 1, scope: !28) // CHECK:STDOUT: !41 = distinct !DISubprogram(name: "Op", linkageName: "_COp.f58524831c37807e:core.Destroy.Core", scope: null, file: !18, line: 7, type: !27, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !44) // CHECK:STDOUT: !42 = !DILocalVariable(arg: 1, scope: !41, type: !20) // CHECK:STDOUT: !43 = !DILocation(line: 7, column: 3, scope: !41) // CHECK:STDOUT: !44 = !{!42} // CHECK:STDOUT: !45 = distinct !DISubprogram(name: "Op", linkageName: "_COp.cc12b768126bed5c:core.Destroy.Core", scope: null, file: !18, line: 7, type: !23, spFlags: DISPFlagDefinition, unit: !19, retainedNodes: !48) // CHECK:STDOUT: !46 = !DILocalVariable(arg: 1, scope: !45, type: !21) // CHECK:STDOUT: !47 = !DILocation(line: 7, column: 3, scope: !45) // CHECK:STDOUT: !48 = !{!46} // CHECK:STDOUT: // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'avoid_tail_padding.carbon' // CHECK:STDOUT: source_filename = "avoid_tail_padding.carbon" // CHECK:STDOUT: // CHECK:STDOUT: declare void @_CG.Main(ptr) // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CF.Main() #0 !dbg !51 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %avoid_tail_padding.var = alloca <{ ptr, i32 }>, align 8, !dbg !52 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %avoid_tail_padding.var), !dbg !52 // CHECK:STDOUT: %.loc8.y = getelementptr inbounds nuw <{ ptr, i32 }>, ptr %avoid_tail_padding.var, i32 0, i32 1, !dbg !54 // CHECK:STDOUT: call void @_CG.Main(ptr %.loc8.y), !dbg !56 // CHECK:STDOUT: call void @"_COp.90798694d9a177e6:core.Destroy.Core"(ptr %avoid_tail_padding.var), !dbg !52 // CHECK:STDOUT: ret void, !dbg !57 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %self) #0 !dbg !58 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !60 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.90798694d9a177e6:core.Destroy.Core"(ptr %self) #0 !dbg !62 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !64 // 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: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.dbg.cu = !{!50} // CHECK:STDOUT: !llvm.module.flags = !{!2, !3} // CHECK:STDOUT: // CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3} // 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 = !{null, !21} // CHECK:STDOUT: !23 = !DISubroutineType(types: !22) // CHECK:STDOUT: !24 = !{null} // CHECK:STDOUT: !25 = !DISubroutineType(types: !24) // CHECK:STDOUT: !26 = !{null, !20} // CHECK:STDOUT: !27 = !DISubroutineType(types: !26) // CHECK:STDOUT: !49 = !DIFile(filename: "avoid_tail_padding.carbon", directory: "") // CHECK:STDOUT: !50 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !49, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !51 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !49, line: 5, type: !25, spFlags: DISPFlagDefinition, unit: !50) // CHECK:STDOUT: !52 = !DILocation(line: 7, column: 3, scope: !51) // CHECK:STDOUT: !54 = !DILocation(line: 8, column: 6, scope: !51) // CHECK:STDOUT: !56 = !DILocation(line: 8, column: 3, scope: !51) // CHECK:STDOUT: !57 = !DILocation(line: 5, column: 1, scope: !51) // CHECK:STDOUT: !58 = distinct !DISubprogram(name: "Op", linkageName: "_COp.f58524831c37807e:core.Destroy.Core", scope: null, file: !49, line: 7, type: !27, spFlags: DISPFlagDefinition, unit: !50, retainedNodes: !61) // CHECK:STDOUT: !59 = !DILocalVariable(arg: 1, scope: !58, type: !20) // CHECK:STDOUT: !60 = !DILocation(line: 7, column: 3, scope: !58) // CHECK:STDOUT: !61 = !{!59} // CHECK:STDOUT: !62 = distinct !DISubprogram(name: "Op", linkageName: "_COp.90798694d9a177e6:core.Destroy.Core", scope: null, file: !49, line: 7, type: !23, spFlags: DISPFlagDefinition, unit: !50, retainedNodes: !65) // CHECK:STDOUT: !63 = !DILocalVariable(arg: 1, scope: !62, type: !21) // CHECK:STDOUT: !64 = !DILocation(line: 7, column: 3, scope: !62) // CHECK:STDOUT: !65 = !{!63} // CHECK:STDOUT: // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'use_tail_padding.carbon' // CHECK:STDOUT: source_filename = "use_tail_padding.carbon" // CHECK:STDOUT: // CHECK:STDOUT: declare void @_CG.Main(ptr) // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CF.Main() #0 !dbg !68 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %use_tail_padding.var = alloca { <{ ptr, i32 }>, i32 }, align 8, !dbg !69 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %use_tail_padding.var), !dbg !69 // CHECK:STDOUT: %.loc9_22.a = getelementptr inbounds nuw { <{ ptr, i32 }>, i32 }, ptr %use_tail_padding.var, i32 0, i32 0, !dbg !71 // CHECK:STDOUT: %.loc9_24.y = getelementptr inbounds nuw <{ ptr, i32 }>, ptr %.loc9_22.a, i32 0, i32 1, !dbg !71 // CHECK:STDOUT: call void @_CG.Main(ptr %.loc9_24.y), !dbg !73 // CHECK:STDOUT: %.loc10.b = getelementptr inbounds nuw { <{ ptr, i32 }>, i32 }, ptr %use_tail_padding.var, i32 0, i32 1, !dbg !74 // CHECK:STDOUT: call void @_CG.Main(ptr %.loc10.b), !dbg !76 // CHECK:STDOUT: call void @"_COp.3862e4ac11efcf1c:core.Destroy.Core"(ptr %use_tail_padding.var), !dbg !69 // CHECK:STDOUT: ret void, !dbg !77 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %self) #0 !dbg !78 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !80 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.90798694d9a177e6:core.Destroy.Core"(ptr %self) #0 !dbg !82 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !84 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.3862e4ac11efcf1c:core.Destroy.Core"(ptr %self) #0 !dbg !86 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !88 // 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: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.dbg.cu = !{!67} // CHECK:STDOUT: !llvm.module.flags = !{!2, !3} // CHECK:STDOUT: // CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3} // 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 = !{null, !21} // CHECK:STDOUT: !23 = !DISubroutineType(types: !22) // CHECK:STDOUT: !24 = !{null} // CHECK:STDOUT: !25 = !DISubroutineType(types: !24) // CHECK:STDOUT: !26 = !{null, !20} // CHECK:STDOUT: !27 = !DISubroutineType(types: !26) // CHECK:STDOUT: !66 = !DIFile(filename: "use_tail_padding.carbon", directory: "") // CHECK:STDOUT: !67 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !66, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !68 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !66, line: 5, type: !25, spFlags: DISPFlagDefinition, unit: !67) // CHECK:STDOUT: !69 = !DILocation(line: 8, column: 3, scope: !68) // CHECK:STDOUT: !71 = !DILocation(line: 9, column: 6, scope: !68) // CHECK:STDOUT: !73 = !DILocation(line: 9, column: 3, scope: !68) // CHECK:STDOUT: !74 = !DILocation(line: 10, column: 6, scope: !68) // CHECK:STDOUT: !76 = !DILocation(line: 10, column: 3, scope: !68) // CHECK:STDOUT: !77 = !DILocation(line: 5, column: 1, scope: !68) // CHECK:STDOUT: !78 = distinct !DISubprogram(name: "Op", linkageName: "_COp.f58524831c37807e:core.Destroy.Core", scope: null, file: !66, line: 8, type: !27, spFlags: DISPFlagDefinition, unit: !67, retainedNodes: !81) // CHECK:STDOUT: !79 = !DILocalVariable(arg: 1, scope: !78, type: !20) // CHECK:STDOUT: !80 = !DILocation(line: 8, column: 3, scope: !78) // CHECK:STDOUT: !81 = !{!79} // CHECK:STDOUT: !82 = distinct !DISubprogram(name: "Op", linkageName: "_COp.90798694d9a177e6:core.Destroy.Core", scope: null, file: !66, line: 8, type: !23, spFlags: DISPFlagDefinition, unit: !67, retainedNodes: !85) // CHECK:STDOUT: !83 = !DILocalVariable(arg: 1, scope: !82, type: !21) // CHECK:STDOUT: !84 = !DILocation(line: 8, column: 3, scope: !82) // CHECK:STDOUT: !85 = !{!83} // CHECK:STDOUT: !86 = distinct !DISubprogram(name: "Op", linkageName: "_COp.3862e4ac11efcf1c:core.Destroy.Core", scope: null, file: !66, line: 8, type: !23, spFlags: DISPFlagDefinition, unit: !67, retainedNodes: !89) // CHECK:STDOUT: !87 = !DILocalVariable(arg: 1, scope: !86, type: !21) // CHECK:STDOUT: !88 = !DILocation(line: 8, column: 3, scope: !86) // CHECK:STDOUT: !89 = !{!87} // CHECK:STDOUT: // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'implicit_padding.carbon' // CHECK:STDOUT: source_filename = "implicit_padding.carbon" // CHECK:STDOUT: // CHECK:STDOUT: declare void @_CG.Main(ptr) // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CF.Main() #0 !dbg !92 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %implicit_padding.var = alloca { <{ ptr, i32 }>, ptr }, align 8, !dbg !93 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %implicit_padding.var), !dbg !93 // CHECK:STDOUT: %.loc9_22.a = getelementptr inbounds nuw { <{ ptr, i32 }>, ptr }, ptr %implicit_padding.var, i32 0, i32 0, !dbg !95 // CHECK:STDOUT: %.loc9_24.x = getelementptr inbounds nuw <{ ptr, i32 }>, ptr %.loc9_22.a, i32 0, i32 0, !dbg !95 // CHECK:STDOUT: call void @_CG.Main(ptr %.loc9_24.x), !dbg !97 // CHECK:STDOUT: %.loc10.b = getelementptr inbounds nuw { <{ ptr, i32 }>, ptr }, ptr %implicit_padding.var, i32 0, i32 1, !dbg !98 // CHECK:STDOUT: call void @_CG.Main(ptr %.loc10.b), !dbg !100 // CHECK:STDOUT: call void @"_COp.fb4d9eb13d71ce13:core.Destroy.Core"(ptr %implicit_padding.var), !dbg !93 // CHECK:STDOUT: ret void, !dbg !101 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %self) #0 !dbg !102 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !104 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.90798694d9a177e6:core.Destroy.Core"(ptr %self) #0 !dbg !106 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !108 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.fb4d9eb13d71ce13:core.Destroy.Core"(ptr %self) #0 !dbg !110 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !112 // 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: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.dbg.cu = !{!91} // CHECK:STDOUT: !llvm.module.flags = !{!2, !3} // CHECK:STDOUT: // CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3} // 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 = !{null, !21} // CHECK:STDOUT: !23 = !DISubroutineType(types: !22) // CHECK:STDOUT: !24 = !{null} // CHECK:STDOUT: !25 = !DISubroutineType(types: !24) // CHECK:STDOUT: !26 = !{null, !20} // CHECK:STDOUT: !27 = !DISubroutineType(types: !26) // CHECK:STDOUT: !90 = !DIFile(filename: "implicit_padding.carbon", directory: "") // CHECK:STDOUT: !91 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !90, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !92 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !90, line: 5, type: !25, spFlags: DISPFlagDefinition, unit: !91) // CHECK:STDOUT: !93 = !DILocation(line: 8, column: 3, scope: !92) // CHECK:STDOUT: !95 = !DILocation(line: 9, column: 6, scope: !92) // CHECK:STDOUT: !97 = !DILocation(line: 9, column: 3, scope: !92) // CHECK:STDOUT: !98 = !DILocation(line: 10, column: 6, scope: !92) // CHECK:STDOUT: !100 = !DILocation(line: 10, column: 3, scope: !92) // CHECK:STDOUT: !101 = !DILocation(line: 5, column: 1, scope: !92) // CHECK:STDOUT: !102 = distinct !DISubprogram(name: "Op", linkageName: "_COp.f58524831c37807e:core.Destroy.Core", scope: null, file: !90, line: 8, type: !27, spFlags: DISPFlagDefinition, unit: !91, retainedNodes: !105) // CHECK:STDOUT: !103 = !DILocalVariable(arg: 1, scope: !102, type: !20) // CHECK:STDOUT: !104 = !DILocation(line: 8, column: 3, scope: !102) // CHECK:STDOUT: !105 = !{!103} // CHECK:STDOUT: !106 = distinct !DISubprogram(name: "Op", linkageName: "_COp.90798694d9a177e6:core.Destroy.Core", scope: null, file: !90, line: 8, type: !23, spFlags: DISPFlagDefinition, unit: !91, retainedNodes: !109) // CHECK:STDOUT: !107 = !DILocalVariable(arg: 1, scope: !106, type: !21) // CHECK:STDOUT: !108 = !DILocation(line: 8, column: 3, scope: !106) // CHECK:STDOUT: !109 = !{!107} // CHECK:STDOUT: !110 = distinct !DISubprogram(name: "Op", linkageName: "_COp.fb4d9eb13d71ce13:core.Destroy.Core", scope: null, file: !90, line: 8, type: !23, spFlags: DISPFlagDefinition, unit: !91, retainedNodes: !113) // CHECK:STDOUT: !111 = !DILocalVariable(arg: 1, scope: !110, type: !21) // CHECK:STDOUT: !112 = !DILocation(line: 8, column: 3, scope: !110) // CHECK:STDOUT: !113 = !{!111} // CHECK:STDOUT: // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'insert_padding.carbon' // CHECK:STDOUT: source_filename = "insert_padding.carbon" // CHECK:STDOUT: // CHECK:STDOUT: declare void @_CG.Main(ptr) // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CF.Main() #0 !dbg !116 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %insert_padding.var = alloca <{ <{ { i32, i32, i32 }, [4 x i8] }>, ptr, i32 }>, align 8, !dbg !117 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %insert_padding.var), !dbg !117 // CHECK:STDOUT: %.loc10.b = getelementptr inbounds nuw <{ <{ { i32, i32, i32 }, [4 x i8] }>, ptr, i32 }>, ptr %insert_padding.var, i32 0, i32 1, !dbg !119 // CHECK:STDOUT: call void @_CG.Main(ptr %.loc10.b), !dbg !121 // CHECK:STDOUT: call void @"_COp.b496992173693e26:core.Destroy.Core"(ptr %insert_padding.var), !dbg !117 // CHECK:STDOUT: ret void, !dbg !122 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.f58524831c37807e:core.Destroy.Core"(ptr %self) #0 !dbg !123 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !125 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.cc12b768126bed5c:core.Destroy.Core"(ptr %self) #0 !dbg !127 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !129 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.b496992173693e26:core.Destroy.Core"(ptr %self) #0 !dbg !131 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !133 // 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: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.dbg.cu = !{!115} // CHECK:STDOUT: !llvm.module.flags = !{!2, !3} // CHECK:STDOUT: // CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3} // 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 = !{null, !21} // CHECK:STDOUT: !23 = !DISubroutineType(types: !22) // CHECK:STDOUT: !24 = !{null} // CHECK:STDOUT: !25 = !DISubroutineType(types: !24) // CHECK:STDOUT: !26 = !{null, !20} // CHECK:STDOUT: !27 = !DISubroutineType(types: !26) // CHECK:STDOUT: !114 = !DIFile(filename: "insert_padding.carbon", directory: "") // CHECK:STDOUT: !115 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !114, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !116 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !114, line: 5, type: !25, spFlags: DISPFlagDefinition, unit: !115) // CHECK:STDOUT: !117 = !DILocation(line: 9, column: 3, scope: !116) // CHECK:STDOUT: !119 = !DILocation(line: 10, column: 6, scope: !116) // CHECK:STDOUT: !121 = !DILocation(line: 10, column: 3, scope: !116) // CHECK:STDOUT: !122 = !DILocation(line: 5, column: 1, scope: !116) // CHECK:STDOUT: !123 = distinct !DISubprogram(name: "Op", linkageName: "_COp.f58524831c37807e:core.Destroy.Core", scope: null, file: !114, line: 9, type: !27, spFlags: DISPFlagDefinition, unit: !115, retainedNodes: !126) // CHECK:STDOUT: !124 = !DILocalVariable(arg: 1, scope: !123, type: !20) // CHECK:STDOUT: !125 = !DILocation(line: 9, column: 3, scope: !123) // CHECK:STDOUT: !126 = !{!124} // CHECK:STDOUT: !127 = distinct !DISubprogram(name: "Op", linkageName: "_COp.cc12b768126bed5c:core.Destroy.Core", scope: null, file: !114, line: 9, type: !23, spFlags: DISPFlagDefinition, unit: !115, retainedNodes: !130) // CHECK:STDOUT: !128 = !DILocalVariable(arg: 1, scope: !127, type: !21) // CHECK:STDOUT: !129 = !DILocation(line: 9, column: 3, scope: !127) // CHECK:STDOUT: !130 = !{!128} // CHECK:STDOUT: !131 = distinct !DISubprogram(name: "Op", linkageName: "_COp.b496992173693e26:core.Destroy.Core", scope: null, file: !114, line: 9, type: !23, spFlags: DISPFlagDefinition, unit: !115, retainedNodes: !134) // CHECK:STDOUT: !132 = !DILocalVariable(arg: 1, scope: !131, type: !21) // CHECK:STDOUT: !133 = !DILocation(line: 9, column: 3, scope: !131) // CHECK:STDOUT: !134 = !{!132} // CHECK:STDOUT: