/
githubmirror
/
carbon-lang
Обзор
Документация
Войти
/
githubmirror
/
carbon-lang
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
toolchain/lower/testdata/interop/cpp/function/import/parameters.carbon
594 строки
33 KB
Richard Smith
Give thunks weak_odr linkage. (#7525)
17 июл 2026, 16:25
Не верифицирован
17 июл 2026, 16:25
5c544f7
Код
Авторство
О чём код?
// 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/primitives.carbon // // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/interop/cpp/function/import/parameters.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interop/cpp/function/import/parameters.carbon // ============================================================================ // Parameter requires a thunk to be generated // ============================================================================ // --- ints.h // TODO: Also test `long long` once it's supported. void pass_signed(signed char, short, int, long); void pass_unsigned(unsigned char, unsigned short, unsigned int, unsigned long); void pass_short(short); // --- import_ints.carbon library "[[@TEST_NAME]]"; import Cpp library "ints.h"; fn MyF() { Cpp.pass_signed(1, 2, 3, 4); Cpp.pass_unsigned(1, 2, 3, 4); } fn MakeShort() -> i16; var c: i16; fn PassShort(a: i16, b: i16*) { Cpp.pass_short(a); Cpp.pass_short(*b); Cpp.pass_short(c); Cpp.pass_short(MakeShort()); } // --- struct.h struct X { int a; int b; int c; }; void pass_struct(X); // --- import_struct.carbon library "[[@TEST_NAME]]"; import Cpp library "struct.h"; fn Test() { var x: Cpp.X; x.a = 1; x.b = 2; x.c = 3; Cpp.pass_struct(x); } // --- class_with_nontrivial_copy.h class Y { public: Y(const Y&); int a; int b; int c; }; void pass_struct(Y); // --- import_class_with_nontrivial_copy.carbon library "[[@TEST_NAME]]"; import Cpp library "class_with_nontrivial_copy.h"; fn PassRefExpr() { var y: Cpp.Y; y.a = 1; y.b = 2; y.c = 3; Cpp.pass_struct(y); } fn Make() -> Cpp.Y; fn PassInitExpr() { Cpp.pass_struct(Make()); } fn PassValueExpr(y: Cpp.Y) { Cpp.pass_struct(y); } // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'import_ints.carbon' // CHECK:STDOUT: source_filename = "import_ints.carbon" // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: // CHECK:STDOUT: @int_1.f1e = internal constant i8 1 // CHECK:STDOUT: @int_2.5c2 = internal constant i16 2 // CHECK:STDOUT: @int_1.067 = internal constant i8 1 // CHECK:STDOUT: @int_2.ec3 = internal constant i16 2 // CHECK:STDOUT: @_Cc.Main = global i16 0 // CHECK:STDOUT: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr @_C__global_init.Main, ptr null }] // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CMyF.Main() #0 !dbg !12 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.loc7_19.3.temp = alloca i8, align 1, !dbg !15 // CHECK:STDOUT: %.loc7_22.3.temp = alloca i16, align 2, !dbg !16 // CHECK:STDOUT: %.loc9_21.3.temp = alloca i8, align 1, !dbg !17 // CHECK:STDOUT: %.loc9_24.3.temp = alloca i16, align 2, !dbg !18 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc7_19.3.temp), !dbg !15 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc7_22.3.temp), !dbg !16 // CHECK:STDOUT: call void @_Z11pass_signedasil.carbon_thunk.____(ptr @int_1.f1e, ptr @int_2.5c2, i32 3, i64 4), !dbg !19 // CHECK:STDOUT: call void @"_COp.eb6702152d47e49f:core.Destroy.Core"(ptr @int_2.5c2), !dbg !16 // CHECK:STDOUT: call void @"_COp.578b3934f85dbca6:core.Destroy.Core"(ptr @int_1.f1e), !dbg !15 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc9_21.3.temp), !dbg !17 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc9_24.3.temp), !dbg !18 // CHECK:STDOUT: call void @_Z13pass_unsignedhtjm.carbon_thunk.____(ptr @int_1.067, ptr @int_2.ec3, i32 3, i64 4), !dbg !20 // CHECK:STDOUT: call void @"_COp.6fd0ed7da7a22bb4:core.Destroy.Core"(ptr @int_2.ec3), !dbg !18 // CHECK:STDOUT: call void @"_COp.c3b9dc9c7e0d5d3d:core.Destroy.Core"(ptr @int_1.067), !dbg !17 // CHECK:STDOUT: ret void, !dbg !21 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable // CHECK:STDOUT: define internal void @_Z11pass_signedasil.carbon_thunk.____(ptr noundef %0, ptr noundef %1, i32 noundef %2, i64 noundef %3) #1 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.addr = alloca ptr, align 8 // CHECK:STDOUT: %.addr1 = alloca ptr, align 8 // CHECK:STDOUT: %.addr2 = alloca i32, align 4 // CHECK:STDOUT: %.addr3 = alloca i64, align 8 // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !22 // CHECK:STDOUT: store ptr %1, ptr %.addr1, align 8, !tbaa !25 // CHECK:STDOUT: store i32 %2, ptr %.addr2, align 4, !tbaa !27 // CHECK:STDOUT: store i64 %3, ptr %.addr3, align 8, !tbaa !28 // CHECK:STDOUT: %4 = load ptr, ptr %.addr, align 8, !tbaa !22 // CHECK:STDOUT: %5 = load i8, ptr %4, align 1, !tbaa !30 // CHECK:STDOUT: %6 = load ptr, ptr %.addr1, align 8, !tbaa !25 // CHECK:STDOUT: %7 = load i16, ptr %6, align 2, !tbaa !31 // CHECK:STDOUT: %8 = load i32, ptr %.addr2, align 4, !tbaa !27 // CHECK:STDOUT: %9 = load i64, ptr %.addr3, align 8, !tbaa !28 // CHECK:STDOUT: call void @_Z11pass_signedasil(i8 noundef signext %5, i16 noundef signext %7, i32 noundef %8, i64 noundef %9) // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.eb6702152d47e49f:core.Destroy.Core"(ptr %self) #0 !dbg !33 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !39 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.578b3934f85dbca6:core.Destroy.Core"(ptr %self) #0 !dbg !40 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !46 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable // CHECK:STDOUT: define internal void @_Z13pass_unsignedhtjm.carbon_thunk.____(ptr noundef %0, ptr noundef %1, i32 noundef %2, i64 noundef %3) #1 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.addr = alloca ptr, align 8 // CHECK:STDOUT: %.addr1 = alloca ptr, align 8 // CHECK:STDOUT: %.addr2 = alloca i32, align 4 // CHECK:STDOUT: %.addr3 = alloca i64, align 8 // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !22 // CHECK:STDOUT: store ptr %1, ptr %.addr1, align 8, !tbaa !25 // CHECK:STDOUT: store i32 %2, ptr %.addr2, align 4, !tbaa !27 // CHECK:STDOUT: store i64 %3, ptr %.addr3, align 8, !tbaa !28 // CHECK:STDOUT: %4 = load ptr, ptr %.addr, align 8, !tbaa !22 // CHECK:STDOUT: %5 = load i8, ptr %4, align 1, !tbaa !30 // CHECK:STDOUT: %6 = load ptr, ptr %.addr1, align 8, !tbaa !25 // CHECK:STDOUT: %7 = load i16, ptr %6, align 2, !tbaa !31 // CHECK:STDOUT: %8 = load i32, ptr %.addr2, align 4, !tbaa !27 // CHECK:STDOUT: %9 = load i64, ptr %.addr3, align 8, !tbaa !28 // CHECK:STDOUT: call void @_Z13pass_unsignedhtjm(i8 noundef zeroext %5, i16 noundef zeroext %7, i32 noundef %8, i64 noundef %9) // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.6fd0ed7da7a22bb4:core.Destroy.Core"(ptr %self) #0 !dbg !47 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !53 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_COp.c3b9dc9c7e0d5d3d:core.Destroy.Core"(ptr %self) #0 !dbg !54 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !60 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare i16 @_CMakeShort.Main() // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CPassShort.Main(i16 %a, ptr %b) #0 !dbg !61 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.loc17_18.1.temp = alloca i16, align 2, !dbg !68 // CHECK:STDOUT: %.loc18_18.3.temp = alloca i16, align 2, !dbg !69 // CHECK:STDOUT: %.loc19_18.2.temp = alloca i16, align 2, !dbg !70 // CHECK:STDOUT: %.loc20_28.3.temp = alloca i16, align 2, !dbg !71 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc17_18.1.temp), !dbg !68 // CHECK:STDOUT: store i16 %a, ptr %.loc17_18.1.temp, align 2, !dbg !68 // CHECK:STDOUT: call void @_Z10pass_shorts.carbon_thunk._(ptr %.loc17_18.1.temp), !dbg !72 // CHECK:STDOUT: call void @"_COp.eb6702152d47e49f:core.Destroy.Core"(ptr %.loc17_18.1.temp), !dbg !68 // CHECK:STDOUT: %.loc18_18.2 = load i16, ptr %b, align 2, !dbg !69 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc18_18.3.temp), !dbg !69 // CHECK:STDOUT: store i16 %.loc18_18.2, ptr %.loc18_18.3.temp, align 2, !dbg !69 // CHECK:STDOUT: call void @_Z10pass_shorts.carbon_thunk._(ptr %.loc18_18.3.temp), !dbg !73 // CHECK:STDOUT: call void @"_COp.eb6702152d47e49f:core.Destroy.Core"(ptr %.loc18_18.3.temp), !dbg !69 // CHECK:STDOUT: %.loc19_18.1 = load i16, ptr @_Cc.Main, align 2, !dbg !70 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc19_18.2.temp), !dbg !70 // CHECK:STDOUT: store i16 %.loc19_18.1, ptr %.loc19_18.2.temp, align 2, !dbg !70 // CHECK:STDOUT: call void @_Z10pass_shorts.carbon_thunk._(ptr %.loc19_18.2.temp), !dbg !74 // CHECK:STDOUT: call void @"_COp.eb6702152d47e49f:core.Destroy.Core"(ptr %.loc19_18.2.temp), !dbg !70 // CHECK:STDOUT: %MakeShort.call = call i16 @_CMakeShort.Main(), !dbg !71 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc20_28.3.temp), !dbg !71 // CHECK:STDOUT: store i16 %MakeShort.call, ptr %.loc20_28.3.temp, align 2, !dbg !71 // CHECK:STDOUT: call void @_Z10pass_shorts.carbon_thunk._(ptr %.loc20_28.3.temp), !dbg !75 // CHECK:STDOUT: call void @"_COp.eb6702152d47e49f:core.Destroy.Core"(ptr %.loc20_28.3.temp), !dbg !71 // CHECK:STDOUT: ret void, !dbg !76 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable // CHECK:STDOUT: define internal void @_Z10pass_shorts.carbon_thunk._(ptr noundef %0) #1 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !25 // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !25 // CHECK:STDOUT: %2 = load i16, ptr %1, align 2, !tbaa !31 // CHECK:STDOUT: call void @_Z10pass_shorts(i16 noundef signext %2) // CHECK:STDOUT: ret void // 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)) #2 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define internal void @_C__global_init.Main() #0 !dbg !77 { // CHECK:STDOUT: entry: // CHECK:STDOUT: store i16 poison, ptr @_Cc.Main, align 2, !dbg !78 // CHECK:STDOUT: ret void, !dbg !79 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare void @_Z11pass_signedasil(i8 noundef signext, i16 noundef signext, i32 noundef, i64 noundef) #3 // CHECK:STDOUT: // CHECK:STDOUT: declare void @_Z13pass_unsignedhtjm(i8 noundef zeroext, i16 noundef zeroext, i32 noundef, i64 noundef) #3 // CHECK:STDOUT: // CHECK:STDOUT: declare void @_Z10pass_shorts(i16 noundef signext) #3 // CHECK:STDOUT: // CHECK:STDOUT: ; uselistorder directives // CHECK:STDOUT: uselistorder ptr @_Z10pass_shorts.carbon_thunk._, { 3, 2, 1, 0 } // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 7, 6, 5, 4, 3, 2, 1, 0 } // CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } // CHECK:STDOUT: attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } // CHECK:STDOUT: attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.dbg.cu = !{!0} // CHECK:STDOUT: !llvm.module.flags = !{!2, !3, !4, !5, !6} // CHECK:STDOUT: !llvm.errno.tbaa = !{!7} // CHECK:STDOUT: // CHECK:STDOUT: !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !1 = !DIFile(filename: "import_ints.carbon", directory: "") // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2} // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2} // CHECK:STDOUT: !5 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !6 = !{i32 2, !"Debug Info Version", i32 3} // CHECK:STDOUT: !7 = !{!8, !9, i64 0} // CHECK:STDOUT: !8 = !{!"__libc_errno", !9, i64 0} // CHECK:STDOUT: !9 = !{!"int", !10, i64 0} // CHECK:STDOUT: !10 = !{!"omnipotent char", !11, i64 0} // CHECK:STDOUT: !11 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !12 = distinct !DISubprogram(name: "MyF", linkageName: "_CMyF.Main", scope: null, file: !1, line: 6, type: !13, spFlags: DISPFlagDefinition, unit: !0) // CHECK:STDOUT: !13 = !DISubroutineType(types: !14) // CHECK:STDOUT: !14 = !{null} // CHECK:STDOUT: !15 = !DILocation(line: 7, column: 19, scope: !12) // CHECK:STDOUT: !16 = !DILocation(line: 7, column: 22, scope: !12) // CHECK:STDOUT: !17 = !DILocation(line: 9, column: 21, scope: !12) // CHECK:STDOUT: !18 = !DILocation(line: 9, column: 24, scope: !12) // CHECK:STDOUT: !19 = !DILocation(line: 7, column: 3, scope: !12) // CHECK:STDOUT: !20 = !DILocation(line: 9, column: 3, scope: !12) // CHECK:STDOUT: !21 = !DILocation(line: 6, column: 1, scope: !12) // CHECK:STDOUT: !22 = !{!23, !23, i64 0} // CHECK:STDOUT: !23 = !{!"p1 omnipotent char", !24, i64 0} // CHECK:STDOUT: !24 = !{!"any pointer", !10, i64 0} // CHECK:STDOUT: !25 = !{!26, !26, i64 0} // CHECK:STDOUT: !26 = !{!"p1 short", !24, i64 0} // CHECK:STDOUT: !27 = !{!9, !9, i64 0} // CHECK:STDOUT: !28 = !{!29, !29, i64 0} // CHECK:STDOUT: !29 = !{!"long", !10, i64 0} // CHECK:STDOUT: !30 = !{!10, !10, i64 0} // CHECK:STDOUT: !31 = !{!32, !32, i64 0} // CHECK:STDOUT: !32 = !{!"short", !10, i64 0} // CHECK:STDOUT: !33 = distinct !DISubprogram(name: "Op", linkageName: "_COp.eb6702152d47e49f:core.Destroy.Core", scope: null, file: !1, line: 7, type: !34, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !37) // CHECK:STDOUT: !34 = !DISubroutineType(types: !35) // CHECK:STDOUT: !35 = !{null, !36} // CHECK:STDOUT: !36 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed) // CHECK:STDOUT: !37 = !{!38} // CHECK:STDOUT: !38 = !DILocalVariable(arg: 1, scope: !33, type: !36) // CHECK:STDOUT: !39 = !DILocation(line: 7, column: 22, scope: !33) // CHECK:STDOUT: !40 = distinct !DISubprogram(name: "Op", linkageName: "_COp.578b3934f85dbca6:core.Destroy.Core", scope: null, file: !1, line: 7, type: !41, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !44) // CHECK:STDOUT: !41 = !DISubroutineType(types: !42) // CHECK:STDOUT: !42 = !{null, !43} // CHECK:STDOUT: !43 = !DIBasicType(name: "int", size: 8, encoding: DW_ATE_signed) // CHECK:STDOUT: !44 = !{!45} // CHECK:STDOUT: !45 = !DILocalVariable(arg: 1, scope: !40, type: !43) // CHECK:STDOUT: !46 = !DILocation(line: 7, column: 19, scope: !40) // CHECK:STDOUT: !47 = distinct !DISubprogram(name: "Op", linkageName: "_COp.6fd0ed7da7a22bb4:core.Destroy.Core", scope: null, file: !1, line: 9, type: !48, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !51) // CHECK:STDOUT: !48 = !DISubroutineType(types: !49) // CHECK:STDOUT: !49 = !{null, !50} // CHECK:STDOUT: !50 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_unsigned) // CHECK:STDOUT: !51 = !{!52} // CHECK:STDOUT: !52 = !DILocalVariable(arg: 1, scope: !47, type: !50) // CHECK:STDOUT: !53 = !DILocation(line: 9, column: 24, scope: !47) // CHECK:STDOUT: !54 = distinct !DISubprogram(name: "Op", linkageName: "_COp.c3b9dc9c7e0d5d3d:core.Destroy.Core", scope: null, file: !1, line: 9, type: !55, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !58) // CHECK:STDOUT: !55 = !DISubroutineType(types: !56) // CHECK:STDOUT: !56 = !{null, !57} // CHECK:STDOUT: !57 = !DIBasicType(name: "int", size: 8, encoding: DW_ATE_unsigned) // CHECK:STDOUT: !58 = !{!59} // CHECK:STDOUT: !59 = !DILocalVariable(arg: 1, scope: !54, type: !57) // CHECK:STDOUT: !60 = !DILocation(line: 9, column: 21, scope: !54) // CHECK:STDOUT: !61 = distinct !DISubprogram(name: "PassShort", linkageName: "_CPassShort.Main", scope: null, file: !1, line: 16, type: !62, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !65) // CHECK:STDOUT: !62 = !DISubroutineType(types: !63) // CHECK:STDOUT: !63 = !{null, !36, !64} // CHECK:STDOUT: !64 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) // CHECK:STDOUT: !65 = !{!66, !67} // CHECK:STDOUT: !66 = !DILocalVariable(arg: 1, scope: !61, type: !36) // CHECK:STDOUT: !67 = !DILocalVariable(arg: 2, scope: !61, type: !64) // CHECK:STDOUT: !68 = !DILocation(line: 17, column: 18, scope: !61) // CHECK:STDOUT: !69 = !DILocation(line: 18, column: 18, scope: !61) // CHECK:STDOUT: !70 = !DILocation(line: 19, column: 18, scope: !61) // CHECK:STDOUT: !71 = !DILocation(line: 20, column: 18, scope: !61) // CHECK:STDOUT: !72 = !DILocation(line: 17, column: 3, scope: !61) // CHECK:STDOUT: !73 = !DILocation(line: 18, column: 3, scope: !61) // CHECK:STDOUT: !74 = !DILocation(line: 19, column: 3, scope: !61) // CHECK:STDOUT: !75 = !DILocation(line: 20, column: 3, scope: !61) // CHECK:STDOUT: !76 = !DILocation(line: 16, column: 1, scope: !61) // CHECK:STDOUT: !77 = distinct !DISubprogram(name: "__global_init", linkageName: "_C__global_init.Main", scope: null, file: !1, type: !13, spFlags: DISPFlagDefinition, unit: !0) // CHECK:STDOUT: !78 = !DILocation(line: 14, column: 1, scope: !77) // CHECK:STDOUT: !79 = !DILocation(line: 0, scope: !77) // CHECK:STDOUT: // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'import_struct.carbon' // CHECK:STDOUT: source_filename = "import_struct.carbon" // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: // CHECK:STDOUT: %struct.X = type { i32, i32, i32 } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CTest.Main() #0 !dbg !12 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %x.var = alloca [12 x i8], align 4, !dbg !15 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %x.var), !dbg !15 // CHECK:STDOUT: call void @"_COp.51f3fb62cb986374:DefaultOrUnformed.Core.102476b7ae87d0a1"(ptr %x.var), !dbg !15 // CHECK:STDOUT: %.loc8_4.a = getelementptr inbounds nuw [12 x i8], ptr %x.var, i32 0, i32 0, !dbg !16 // CHECK:STDOUT: store i32 1, ptr %.loc8_4.a, align 4, !dbg !16 // CHECK:STDOUT: %.loc9_4.b = getelementptr inbounds nuw [12 x i8], ptr %x.var, i32 0, i32 4, !dbg !17 // CHECK:STDOUT: store i32 2, ptr %.loc9_4.b, align 4, !dbg !17 // CHECK:STDOUT: %.loc10_4.c = getelementptr inbounds nuw [12 x i8], ptr %x.var, i32 0, i32 8, !dbg !18 // CHECK:STDOUT: store i32 3, ptr %.loc10_4.c, align 4, !dbg !18 // CHECK:STDOUT: call void @_Z11pass_struct1X.carbon_thunk._(ptr %x.var), !dbg !19 // CHECK:STDOUT: ret void, !dbg !20 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable // CHECK:STDOUT: define internal void @_ZN1XC1Ev.carbon_thunk.(ptr noundef %return) #1 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %return.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %return, ptr %return.addr, align 8, !tbaa !21 // CHECK:STDOUT: %0 = load ptr, ptr %return.addr, align 8, !tbaa !21 // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind // CHECK:STDOUT: define weak_odr void @"_COp:thunk:Default.eed9ddf3aaac414a.Core:X.Cpp"(ptr sret([12 x i8]) %return) #2 !dbg !24 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @_ZN1XC1Ev.carbon_thunk.(ptr %return), !dbg !29 // CHECK:STDOUT: ret void, !dbg !29 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable // CHECK:STDOUT: define internal void @_Z11pass_struct1X.carbon_thunk._(ptr noundef %0) #3 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.addr = alloca ptr, align 8 // CHECK:STDOUT: %agg.tmp = alloca %struct.X, align 4 // CHECK:STDOUT: %agg.tmp.coerce = alloca { i64, i32 }, align 4 // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !21 // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !21 // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %agg.tmp, ptr align 4 %1, i64 12, i1 false), !tbaa.struct !30 // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %agg.tmp.coerce, ptr align 4 %agg.tmp, i64 12, i1 false) // CHECK:STDOUT: %2 = getelementptr inbounds nuw { i64, i32 }, ptr %agg.tmp.coerce, i32 0, i32 0 // CHECK:STDOUT: %3 = load i64, ptr %2, align 4 // CHECK:STDOUT: %4 = getelementptr inbounds nuw { i64, i32 }, ptr %agg.tmp.coerce, i32 0, i32 1 // CHECK:STDOUT: %5 = load i32, ptr %4, align 4 // CHECK:STDOUT: call void @_Z11pass_struct1X(i64 %3, i32 %5) // CHECK:STDOUT: ret void // 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)) #4 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr void @"_COp.51f3fb62cb986374:DefaultOrUnformed.Core.102476b7ae87d0a1"(ptr sret([12 x i8]) %return) #0 !dbg !32 { // CHECK:STDOUT: call void @"_COp:thunk:Default.eed9ddf3aaac414a.Core:X.Cpp"(ptr %return), !dbg !34 // CHECK:STDOUT: ret void, !dbg !35 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare void @_Z11pass_struct1X(i64, i32) #5 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) // CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) #4 // CHECK:STDOUT: // CHECK:STDOUT: ; uselistorder directives // CHECK:STDOUT: uselistorder ptr @llvm.memcpy.p0.p0.i64, { 1, 0 } // CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { alwaysinline mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } // CHECK:STDOUT: attributes #2 = { alwaysinline nounwind } // CHECK:STDOUT: attributes #3 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } // CHECK:STDOUT: attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } // CHECK:STDOUT: attributes #5 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.dbg.cu = !{!0} // CHECK:STDOUT: !llvm.module.flags = !{!2, !3, !4, !5, !6} // CHECK:STDOUT: !llvm.errno.tbaa = !{!7} // CHECK:STDOUT: // CHECK:STDOUT: !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !1 = !DIFile(filename: "import_struct.carbon", directory: "") // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2} // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2} // CHECK:STDOUT: !5 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !6 = !{i32 2, !"Debug Info Version", i32 3} // CHECK:STDOUT: !7 = !{!8, !9, i64 0} // CHECK:STDOUT: !8 = !{!"__libc_errno", !9, i64 0} // CHECK:STDOUT: !9 = !{!"int", !10, i64 0} // CHECK:STDOUT: !10 = !{!"omnipotent char", !11, i64 0} // CHECK:STDOUT: !11 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !12 = distinct !DISubprogram(name: "Test", linkageName: "_CTest.Main", scope: null, file: !1, line: 6, type: !13, spFlags: DISPFlagDefinition, unit: !0) // CHECK:STDOUT: !13 = !DISubroutineType(types: !14) // CHECK:STDOUT: !14 = !{null} // CHECK:STDOUT: !15 = !DILocation(line: 7, column: 3, scope: !12) // CHECK:STDOUT: !16 = !DILocation(line: 8, column: 3, scope: !12) // CHECK:STDOUT: !17 = !DILocation(line: 9, column: 3, scope: !12) // CHECK:STDOUT: !18 = !DILocation(line: 10, column: 3, scope: !12) // CHECK:STDOUT: !19 = !DILocation(line: 11, column: 3, scope: !12) // CHECK:STDOUT: !20 = !DILocation(line: 6, column: 1, scope: !12) // CHECK:STDOUT: !21 = !{!22, !22, i64 0} // CHECK:STDOUT: !22 = !{!"p1 _ZTS1X", !23, i64 0} // CHECK:STDOUT: !23 = !{!"any pointer", !10, i64 0} // CHECK:STDOUT: !24 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk:Default.eed9ddf3aaac414a.Core:X.Cpp", scope: null, file: !25, line: 2, type: !26, spFlags: DISPFlagDefinition, unit: !0) // CHECK:STDOUT: !25 = !DIFile(filename: "./struct.h", directory: "") // CHECK:STDOUT: !26 = !DISubroutineType(types: !27) // CHECK:STDOUT: !27 = !{!28} // CHECK:STDOUT: !28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) // CHECK:STDOUT: !29 = !DILocation(line: 2, column: 8, scope: !24) // CHECK:STDOUT: !30 = !{i64 0, i64 4, !31, i64 4, i64 4, !31, i64 8, i64 4, !31} // CHECK:STDOUT: !31 = !{!9, !9, i64 0} // CHECK:STDOUT: !32 = distinct !DISubprogram(name: "Op", linkageName: "_COp.51f3fb62cb986374:DefaultOrUnformed.Core.102476b7ae87d0a1", scope: null, file: !33, line: 9, type: !26, spFlags: DISPFlagDefinition, unit: !0) // CHECK:STDOUT: !33 = !DIFile(filename: "min_prelude/parts/default.carbon", directory: "") // CHECK:STDOUT: !34 = !DILocation(line: 9, column: 28, scope: !32) // CHECK:STDOUT: !35 = !DILocation(line: 9, column: 21, scope: !32) // CHECK:STDOUT: // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'import_class_with_nontrivial_copy.carbon' // CHECK:STDOUT: source_filename = "import_class_with_nontrivial_copy.carbon" // CHECK:STDOUT: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu" // CHECK:STDOUT: // CHECK:STDOUT: %class.Y = type { i32, i32, i32 } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CPassRefExpr.Main() #0 !dbg !12 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %y.var = alloca [12 x i8], align 4, !dbg !15 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %y.var), !dbg !15 // CHECK:STDOUT: %.loc8_4.a = getelementptr inbounds nuw [12 x i8], ptr %y.var, i32 0, i32 0, !dbg !16 // CHECK:STDOUT: store i32 1, ptr %.loc8_4.a, align 4, !dbg !16 // CHECK:STDOUT: %.loc9_4.b = getelementptr inbounds nuw [12 x i8], ptr %y.var, i32 0, i32 4, !dbg !17 // CHECK:STDOUT: store i32 2, ptr %.loc9_4.b, align 4, !dbg !17 // CHECK:STDOUT: %.loc10_4.c = getelementptr inbounds nuw [12 x i8], ptr %y.var, i32 0, i32 8, !dbg !18 // CHECK:STDOUT: store i32 3, ptr %.loc10_4.c, align 4, !dbg !18 // CHECK:STDOUT: call void @_Z11pass_struct1Y.carbon_thunk._(ptr %y.var), !dbg !19 // CHECK:STDOUT: ret void, !dbg !20 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable // CHECK:STDOUT: define internal void @_Z11pass_struct1Y.carbon_thunk._(ptr noundef %0) #1 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.addr = alloca ptr, align 8 // CHECK:STDOUT: %agg.tmp = alloca %class.Y, align 4 // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !21 // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !21 // CHECK:STDOUT: call void @_ZN1YC1ERKS_(ptr noundef nonnull align 4 dereferenceable(12) %agg.tmp, ptr noundef nonnull align 4 dereferenceable(12) %1) // CHECK:STDOUT: call void @_Z11pass_struct1Y(ptr noundef align 4 dead_on_return %agg.tmp) // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare void @_CMake.Main(ptr sret([12 x i8])) // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CPassInitExpr.Main() #0 !dbg !24 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.loc17_24.1.temp = alloca [12 x i8], align 4, !dbg !25 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc17_24.1.temp), !dbg !25 // CHECK:STDOUT: call void @_CMake.Main(ptr %.loc17_24.1.temp), !dbg !25 // CHECK:STDOUT: call void @_Z11pass_struct1Y.carbon_thunk._(ptr %.loc17_24.1.temp), !dbg !26 // CHECK:STDOUT: ret void, !dbg !27 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CPassValueExpr.Main(ptr %y) #0 !dbg !28 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @_Z11pass_struct1Y.carbon_thunk._(ptr %y), !dbg !34 // CHECK:STDOUT: ret void, !dbg !35 // 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)) #2 // CHECK:STDOUT: // CHECK:STDOUT: declare void @_Z11pass_struct1Y(ptr noundef align 4 dead_on_return) #3 // CHECK:STDOUT: // CHECK:STDOUT: declare void @_ZN1YC1ERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3 // CHECK:STDOUT: // CHECK:STDOUT: ; uselistorder directives // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 1, 0 } // CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } // CHECK:STDOUT: attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } // CHECK:STDOUT: attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.dbg.cu = !{!0} // CHECK:STDOUT: !llvm.module.flags = !{!2, !3, !4, !5, !6} // CHECK:STDOUT: !llvm.errno.tbaa = !{!7} // CHECK:STDOUT: // CHECK:STDOUT: !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !1 = !DIFile(filename: "import_class_with_nontrivial_copy.carbon", directory: "") // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2} // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2} // CHECK:STDOUT: !5 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !6 = !{i32 2, !"Debug Info Version", i32 3} // CHECK:STDOUT: !7 = !{!8, !9, i64 0} // CHECK:STDOUT: !8 = !{!"__libc_errno", !9, i64 0} // CHECK:STDOUT: !9 = !{!"int", !10, i64 0} // CHECK:STDOUT: !10 = !{!"omnipotent char", !11, i64 0} // CHECK:STDOUT: !11 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !12 = distinct !DISubprogram(name: "PassRefExpr", linkageName: "_CPassRefExpr.Main", scope: null, file: !1, line: 6, type: !13, spFlags: DISPFlagDefinition, unit: !0) // CHECK:STDOUT: !13 = !DISubroutineType(types: !14) // CHECK:STDOUT: !14 = !{null} // CHECK:STDOUT: !15 = !DILocation(line: 7, column: 3, scope: !12) // CHECK:STDOUT: !16 = !DILocation(line: 8, column: 3, scope: !12) // CHECK:STDOUT: !17 = !DILocation(line: 9, column: 3, scope: !12) // CHECK:STDOUT: !18 = !DILocation(line: 10, column: 3, scope: !12) // CHECK:STDOUT: !19 = !DILocation(line: 11, column: 3, scope: !12) // CHECK:STDOUT: !20 = !DILocation(line: 6, column: 1, scope: !12) // CHECK:STDOUT: !21 = !{!22, !22, i64 0} // CHECK:STDOUT: !22 = !{!"p1 _ZTS1Y", !23, i64 0} // CHECK:STDOUT: !23 = !{!"any pointer", !10, i64 0} // CHECK:STDOUT: !24 = distinct !DISubprogram(name: "PassInitExpr", linkageName: "_CPassInitExpr.Main", scope: null, file: !1, line: 16, type: !13, spFlags: DISPFlagDefinition, unit: !0) // CHECK:STDOUT: !25 = !DILocation(line: 17, column: 19, scope: !24) // CHECK:STDOUT: !26 = !DILocation(line: 17, column: 3, scope: !24) // CHECK:STDOUT: !27 = !DILocation(line: 16, column: 1, scope: !24) // CHECK:STDOUT: !28 = distinct !DISubprogram(name: "PassValueExpr", linkageName: "_CPassValueExpr.Main", scope: null, file: !1, line: 20, type: !29, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !32) // CHECK:STDOUT: !29 = !DISubroutineType(types: !30) // CHECK:STDOUT: !30 = !{null, !31} // CHECK:STDOUT: !31 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) // CHECK:STDOUT: !32 = !{!33} // CHECK:STDOUT: !33 = !DILocalVariable(arg: 1, scope: !28, type: !31) // CHECK:STDOUT: !34 = !DILocation(line: 21, column: 3, scope: !28) // CHECK:STDOUT: !35 = !DILocation(line: 20, column: 1, scope: !28) // CHECK:STDOUT: