// 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/full.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/pointer.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interop/cpp/pointer.carbon // ============================================================================ // Non-null pointers // ============================================================================ // --- nonnull.carbon library "[[@TEST_NAME]]"; import Cpp inline ''' class NonnullC {}; auto TakeNonnullPtr(NonnullC* _Nonnull) -> void; auto ReturnNonnullPtr() -> NonnullC* _Nonnull; auto TakeNonnullPtrWithThunk(NonnullC* _Nonnull, int = 0) -> void; auto ReturnNonnullPtrWithThunk(int = 0) -> NonnullC* _Nonnull; '''; fn PassPtr(p: Cpp.NonnullC*) { Cpp.TakeNonnullPtr(p); } fn ReturnPtr() -> Cpp.NonnullC* { return Cpp.ReturnNonnullPtr(); } fn PassPtrWithThunk(p: Cpp.NonnullC*) { Cpp.TakeNonnullPtrWithThunk(p); } fn ReturnPtrWithThunk() -> Cpp.NonnullC* { return Cpp.ReturnNonnullPtrWithThunk(); } // ============================================================================ // Nullable pointers // ============================================================================ // --- nullable.carbon library "[[@TEST_NAME]]"; import Cpp inline ''' class NullableC {}; auto TakeNullablePtr(NullableC*) -> void; auto ReturnNullablePtr() -> NullableC*; auto TakeNullablePtrWithThunk(NullableC*, int = 0) -> void; auto ReturnNullablePtrWithThunk(int = 0) -> NullableC*; '''; fn PassPtr(_: Core.Optional(Cpp.NullableC*)) { // TODO: Add support for passing an optional here. // Cpp.TakeNullablePtr(p); } fn PassNonnullPtr(p: Cpp.NullableC*) { // TODO: The `value_of_initializer` optimization doesn't get used here, so we // unnecessarily round-trip this value through memory. Cpp.TakeNullablePtr(p); } fn ReturnPtr() -> Core.Optional(Cpp.NullableC*) { return Cpp.ReturnNullablePtr(); } fn PassPtrWithThunk(_: Core.Optional(Cpp.NullableC*)) { // TODO: Add support for passing an optional here. // Cpp.TakeNullablePtrWithThunk(p); } fn PassNonnullPtrWithThunk(p: Cpp.NullableC*) { Cpp.TakeNullablePtrWithThunk(p); } fn ReturnPtrWithThunk() -> Core.Optional(Cpp.NullableC*) { return Cpp.ReturnNullablePtrWithThunk(); } // --- add_const.carbon library "[[@TEST_NAME]]"; import Cpp inline ''' class ConstC {}; ConstC *make(); void take(const ConstC*); '''; fn Convert() { Cpp.take(Cpp.make()); } // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'nonnull.carbon' // CHECK:STDOUT: source_filename = "nonnull.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: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CPassPtr.Main(ptr %p) #0 !dbg !11 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @_Z14TakeNonnullPtrP8NonnullC(ptr %p), !dbg !15 // CHECK:STDOUT: ret void, !dbg !16 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare void @_Z14TakeNonnullPtrP8NonnullC(ptr noundef) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define ptr @_CReturnPtr.Main() #0 !dbg !18 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %ReturnNonnullPtr.call = call ptr @_Z16ReturnNonnullPtrv(), !dbg !21 // CHECK:STDOUT: ret ptr %ReturnNonnullPtr.call, !dbg !22 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare noundef ptr @_Z16ReturnNonnullPtrv() #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CPassPtrWithThunk.Main(ptr %p) #0 !dbg !23 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @_Z23TakeNonnullPtrWithThunkP8NonnullCi.carbon_thunk._(ptr %p), !dbg !27 // CHECK:STDOUT: ret void, !dbg !28 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable // CHECK:STDOUT: define internal void @_Z23TakeNonnullPtrWithThunkP8NonnullCi.carbon_thunk._(ptr noundef %0) #2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !39 // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !39 // CHECK:STDOUT: call void @_Z23TakeNonnullPtrWithThunkP8NonnullCi(ptr noundef %1, i32 noundef 0) // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define ptr @_CReturnPtrWithThunk.Main() #0 !dbg !30 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %ReturnNonnullPtrWithThunk__carbon_thunk.call = call ptr @_Z25ReturnNonnullPtrWithThunki.carbon_thunk.(), !dbg !33 // CHECK:STDOUT: ret ptr %ReturnNonnullPtrWithThunk__carbon_thunk.call, !dbg !34 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable // CHECK:STDOUT: define internal noundef ptr @_Z25ReturnNonnullPtrWithThunki.carbon_thunk.() #2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %call = call noundef ptr @_Z25ReturnNonnullPtrWithThunki(i32 noundef 0) // CHECK:STDOUT: ret ptr %call // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare void @_Z23TakeNonnullPtrWithThunkP8NonnullCi(ptr noundef, i32 noundef) #1 // CHECK:STDOUT: // CHECK:STDOUT: declare noundef ptr @_Z25ReturnNonnullPtrWithThunki(i32 noundef) #1 // CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { "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 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: // CHECK:STDOUT: !llvm.dbg.cu = !{!5} // CHECK:STDOUT: !llvm.module.flags = !{!40, !41, !42, !2, !3} // CHECK:STDOUT: !llvm.errno.tbaa = !{!45} // CHECK:STDOUT: // CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3} // CHECK:STDOUT: !4 = !DIFile(filename: "nonnull.carbon", directory: "") // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) // CHECK:STDOUT: !7 = !{null, !6} // CHECK:STDOUT: !8 = !DISubroutineType(types: !7) // CHECK:STDOUT: !9 = !{!6} // CHECK:STDOUT: !10 = !DISubroutineType(types: !9) // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "PassPtr", linkageName: "_CPassPtr.Main", scope: null, file: !4, line: 14, type: !8, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !17) // CHECK:STDOUT: !12 = !DILocalVariable(arg: 1, scope: !11, type: !6) // CHECK:STDOUT: !15 = !DILocation(line: 15, column: 3, scope: !11) // CHECK:STDOUT: !16 = !DILocation(line: 14, column: 1, scope: !11) // CHECK:STDOUT: !17 = !{!12} // CHECK:STDOUT: !18 = distinct !DISubprogram(name: "ReturnPtr", linkageName: "_CReturnPtr.Main", scope: null, file: !4, line: 18, type: !10, spFlags: DISPFlagDefinition, unit: !5) // CHECK:STDOUT: !21 = !DILocation(line: 19, column: 10, scope: !18) // CHECK:STDOUT: !22 = !DILocation(line: 19, column: 3, scope: !18) // CHECK:STDOUT: !23 = distinct !DISubprogram(name: "PassPtrWithThunk", linkageName: "_CPassPtrWithThunk.Main", scope: null, file: !4, line: 22, type: !8, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !29) // CHECK:STDOUT: !24 = !DILocalVariable(arg: 1, scope: !23, type: !6) // CHECK:STDOUT: !27 = !DILocation(line: 23, column: 3, scope: !23) // CHECK:STDOUT: !28 = !DILocation(line: 22, column: 1, scope: !23) // CHECK:STDOUT: !29 = !{!24} // CHECK:STDOUT: !30 = distinct !DISubprogram(name: "ReturnPtrWithThunk", linkageName: "_CReturnPtrWithThunk.Main", scope: null, file: !4, line: 26, type: !10, spFlags: DISPFlagDefinition, unit: !5) // CHECK:STDOUT: !33 = !DILocation(line: 27, column: 10, scope: !30) // CHECK:STDOUT: !34 = !DILocation(line: 27, column: 3, scope: !30) // CHECK:STDOUT: !35 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !36 = !{!"omnipotent char", !35, i64 0} // CHECK:STDOUT: !37 = !{!"any pointer", !36, i64 0} // CHECK:STDOUT: !38 = !{!"p1 _ZTS8NonnullC", !37, i64 0} // CHECK:STDOUT: !39 = !{!38, !38, i64 0} // CHECK:STDOUT: !40 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !41 = !{i32 7, !"PIE Level", i32 2} // CHECK:STDOUT: !42 = !{i32 7, !"uwtable", i32 2} // CHECK:STDOUT: !43 = !{!"int", !36, i64 0} // CHECK:STDOUT: !44 = !{!"__libc_errno", !43, i64 0} // CHECK:STDOUT: !45 = !{!44, !43, i64 0} // CHECK:STDOUT: // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'nullable.carbon' // CHECK:STDOUT: source_filename = "nullable.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: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.51fa064adaeb8681:core.Destroy.Core"(ptr %self) #0 !dbg !49 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !51 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CPassPtr.Main(ptr %_) #0 !dbg !53 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !56 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CPassNonnullPtr.Main(ptr %p) #0 !dbg !58 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.loc22_23.2.temp = alloca ptr, align 8, !dbg !61 // CHECK:STDOUT: %U.as_type.as.ImplicitAs.impl.Convert.call = call ptr @"_CConvert.538322f9fda4254f:ImplicitAs.a276ba298c70ba87.Core.75a9143bcbb84fa5"(ptr %p), !dbg !61 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc22_23.2.temp), !dbg !61 // CHECK:STDOUT: store ptr %U.as_type.as.ImplicitAs.impl.Convert.call, ptr %.loc22_23.2.temp, align 8, !dbg !61 // CHECK:STDOUT: %.loc22_23.4 = load ptr, ptr %.loc22_23.2.temp, align 8, !dbg !61 // CHECK:STDOUT: call void @_Z15TakeNullablePtrP9NullableC(ptr %.loc22_23.4), !dbg !64 // CHECK:STDOUT: call void @"_CSelfDestruct.574ea10b2e6709a0:core.Destroy.Core"(ptr %.loc22_23.2.temp), !dbg !61 // CHECK:STDOUT: ret void, !dbg !65 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare void @_Z15TakeNullablePtrP9NullableC(ptr noundef) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSubobjectDestroy.6789a803c53632c0:core.Destroy.Core"(ptr %self) #0 !dbg !67 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !69 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.6789a803c53632c0:core.Destroy.Core"(ptr %self) #0 !dbg !71 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @"_CSubobjectDestroy.6789a803c53632c0:core.Destroy.Core"(ptr %self), !dbg !73 // CHECK:STDOUT: ret void, !dbg !73 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSubobjectDestroy.5cf0c9a25f98a429:core.Destroy.Core"(ptr %self) #0 !dbg !75 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !77 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.5cf0c9a25f98a429:core.Destroy.Core"(ptr %self) #0 !dbg !79 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @"_CSubobjectDestroy.5cf0c9a25f98a429:core.Destroy.Core"(ptr %self), !dbg !81 // CHECK:STDOUT: ret void, !dbg !81 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSubobjectDestroy.574ea10b2e6709a0:core.Destroy.Core"(ptr %self) #0 !dbg !83 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !85 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.574ea10b2e6709a0:core.Destroy.Core"(ptr %self) #0 !dbg !87 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @"_CSubobjectDestroy.574ea10b2e6709a0:core.Destroy.Core"(ptr %self), !dbg !89 // CHECK:STDOUT: ret void, !dbg !89 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define ptr @_CReturnPtr.Main() #0 !dbg !91 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %ReturnNullablePtr.call = call ptr @_Z17ReturnNullablePtrv(), !dbg !94 // CHECK:STDOUT: ret ptr %ReturnNullablePtr.call, !dbg !95 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare noundef ptr @_Z17ReturnNullablePtrv() #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CPassPtrWithThunk.Main(ptr %_) #0 !dbg !96 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !99 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CPassNonnullPtrWithThunk.Main(ptr %p) #0 !dbg !101 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.loc35_32.2.temp = alloca ptr, align 8, !dbg !104 // CHECK:STDOUT: %U.as_type.as.ImplicitAs.impl.Convert.call = call ptr @"_CConvert.538322f9fda4254f:ImplicitAs.a276ba298c70ba87.Core.75a9143bcbb84fa5"(ptr %p), !dbg !104 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc35_32.2.temp), !dbg !104 // CHECK:STDOUT: store ptr %U.as_type.as.ImplicitAs.impl.Convert.call, ptr %.loc35_32.2.temp, align 8, !dbg !104 // CHECK:STDOUT: %.loc35_32.4 = load ptr, ptr %.loc35_32.2.temp, align 8, !dbg !104 // CHECK:STDOUT: call void @_Z24TakeNullablePtrWithThunkP9NullableCi.carbon_thunk._(ptr %.loc35_32.4), !dbg !105 // CHECK:STDOUT: call void @"_CSelfDestruct.574ea10b2e6709a0:core.Destroy.Core"(ptr %.loc35_32.2.temp), !dbg !104 // CHECK:STDOUT: ret void, !dbg !106 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable // CHECK:STDOUT: define internal void @_Z24TakeNullablePtrWithThunkP9NullableCi.carbon_thunk._(ptr noundef %0) #2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.addr = alloca ptr, align 8 // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !152 // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !152 // CHECK:STDOUT: call void @_Z24TakeNullablePtrWithThunkP9NullableCi(ptr noundef %1, i32 noundef 0) // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define ptr @_CReturnPtrWithThunk.Main() #0 !dbg !108 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %ReturnNullablePtrWithThunk__carbon_thunk.call = call ptr @_Z26ReturnNullablePtrWithThunki.carbon_thunk.(), !dbg !111 // CHECK:STDOUT: ret ptr %ReturnNullablePtrWithThunk__carbon_thunk.call, !dbg !112 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable // CHECK:STDOUT: define internal noundef ptr @_Z26ReturnNullablePtrWithThunki.carbon_thunk.() #2 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %call = call noundef ptr @_Z26ReturnNullablePtrWithThunki(i32 noundef 0) // CHECK:STDOUT: ret ptr %call // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.538322f9fda4254f:ImplicitAs.a276ba298c70ba87.Core.75a9143bcbb84fa5"(ptr %self) #0 !dbg !113 { // CHECK:STDOUT: %1 = call ptr @"_CConvert.9fdaf39d07a1dc4e:OptionalAs.24b7347a93330e68.Core.e83c25d1d2fd22c2"(ptr %self), !dbg !118 // CHECK:STDOUT: ret ptr %1, !dbg !119 // 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)) #3 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.9fdaf39d07a1dc4e:OptionalAs.24b7347a93330e68.Core.e83c25d1d2fd22c2"(ptr %self) #0 !dbg !121 { // CHECK:STDOUT: %1 = call ptr @_CSome.Optional.Core.e83c25d1d2fd22c2(ptr %self), !dbg !127 // CHECK:STDOUT: ret ptr %1, !dbg !128 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr ptr @_CSome.Optional.Core.e83c25d1d2fd22c2(ptr %value) #0 !dbg !130 { // CHECK:STDOUT: %1 = call ptr @"_CSome.e8f8f92d3d08d149:OptionalStorage.Core.77dd513e5db6ef8d"(ptr %value), !dbg !135 // CHECK:STDOUT: ret ptr %1, !dbg !136 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr ptr @"_CSome.e8f8f92d3d08d149:OptionalStorage.Core.77dd513e5db6ef8d"(ptr %self) #0 !dbg !138 { // CHECK:STDOUT: %1 = alloca ptr, align 8, !dbg !143 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %1), !dbg !143 // CHECK:STDOUT: store ptr poison, ptr %1, align 8, !dbg !143 // CHECK:STDOUT: store ptr %self, ptr %1, align 8, !dbg !147 // CHECK:STDOUT: %2 = load ptr, ptr %1, align 8, !dbg !145 // CHECK:STDOUT: call void @"_CSelfDestruct.5cf0c9a25f98a429:core.Destroy.Core"(ptr %1), !dbg !143 // CHECK:STDOUT: ret ptr %2, !dbg !149 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare void @_Z24TakeNullablePtrWithThunkP9NullableCi(ptr noundef, i32 noundef) #1 // CHECK:STDOUT: // CHECK:STDOUT: declare noundef ptr @_Z26ReturnNullablePtrWithThunki(i32 noundef) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; uselistorder directives // CHECK:STDOUT: uselistorder ptr @"_CConvert.538322f9fda4254f:ImplicitAs.a276ba298c70ba87.Core.75a9143bcbb84fa5", { 1, 0 } // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 0, 2, 1 } // CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { "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 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } // CHECK:STDOUT: // CHECK:STDOUT: !llvm.dbg.cu = !{!47} // CHECK:STDOUT: !llvm.module.flags = !{!40, !41, !42, !2, !3} // CHECK:STDOUT: !llvm.errno.tbaa = !{!45} // CHECK:STDOUT: // CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3} // CHECK:STDOUT: !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) // CHECK:STDOUT: !7 = !{null, !6} // CHECK:STDOUT: !8 = !DISubroutineType(types: !7) // CHECK:STDOUT: !9 = !{!6} // CHECK:STDOUT: !10 = !DISubroutineType(types: !9) // CHECK:STDOUT: !35 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !36 = !{!"omnipotent char", !35, i64 0} // CHECK:STDOUT: !37 = !{!"any pointer", !36, i64 0} // CHECK:STDOUT: !40 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !41 = !{i32 7, !"PIE Level", i32 2} // CHECK:STDOUT: !42 = !{i32 7, !"uwtable", i32 2} // CHECK:STDOUT: !43 = !{!"int", !36, i64 0} // CHECK:STDOUT: !44 = !{!"__libc_errno", !43, i64 0} // CHECK:STDOUT: !45 = !{!44, !43, i64 0} // CHECK:STDOUT: !46 = !DIFile(filename: "nullable.carbon", directory: "") // CHECK:STDOUT: !47 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !46, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !48 = !DIFile(filename: "{{.*}}/prelude/types/optional.carbon", directory: "") // CHECK:STDOUT: !49 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.51fa064adaeb8681:core.Destroy.Core", scope: null, file: !48, line: 164, type: !8, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !52) // CHECK:STDOUT: !50 = !DILocalVariable(arg: 1, scope: !49, type: !6) // CHECK:STDOUT: !51 = !DILocation(line: 164, column: 19, scope: !49) // CHECK:STDOUT: !52 = !{!50} // CHECK:STDOUT: !53 = distinct !DISubprogram(name: "PassPtr", linkageName: "_CPassPtr.Main", scope: null, file: !46, line: 14, type: !8, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !57) // CHECK:STDOUT: !54 = !DILocalVariable(arg: 1, scope: !53, type: !6) // CHECK:STDOUT: !56 = !DILocation(line: 14, column: 1, scope: !53) // CHECK:STDOUT: !57 = !{!54} // CHECK:STDOUT: !58 = distinct !DISubprogram(name: "PassNonnullPtr", linkageName: "_CPassNonnullPtr.Main", scope: null, file: !46, line: 19, type: !8, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !66) // CHECK:STDOUT: !59 = !DILocalVariable(arg: 1, scope: !58, type: !6) // CHECK:STDOUT: !61 = !DILocation(line: 22, column: 23, scope: !58) // CHECK:STDOUT: !62 = !{!6, !6} // CHECK:STDOUT: !63 = !DISubroutineType(types: !62) // CHECK:STDOUT: !64 = !DILocation(line: 22, column: 3, scope: !58) // CHECK:STDOUT: !65 = !DILocation(line: 19, column: 1, scope: !58) // CHECK:STDOUT: !66 = !{!59} // CHECK:STDOUT: !67 = distinct !DISubprogram(name: "SubobjectDestroy", linkageName: "_CSubobjectDestroy.6789a803c53632c0:core.Destroy.Core", scope: null, file: !46, line: 22, type: !8, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !70) // CHECK:STDOUT: !68 = !DILocalVariable(arg: 1, scope: !67, type: !6) // CHECK:STDOUT: !69 = !DILocation(line: 22, column: 23, scope: !67) // CHECK:STDOUT: !70 = !{!68} // CHECK:STDOUT: !71 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.6789a803c53632c0:core.Destroy.Core", scope: null, file: !46, line: 22, type: !8, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !74) // CHECK:STDOUT: !72 = !DILocalVariable(arg: 1, scope: !71, type: !6) // CHECK:STDOUT: !73 = !DILocation(line: 22, column: 23, scope: !71) // CHECK:STDOUT: !74 = !{!72} // CHECK:STDOUT: !75 = distinct !DISubprogram(name: "SubobjectDestroy", linkageName: "_CSubobjectDestroy.5cf0c9a25f98a429:core.Destroy.Core", scope: null, file: !46, line: 22, type: !8, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !78) // CHECK:STDOUT: !76 = !DILocalVariable(arg: 1, scope: !75, type: !6) // CHECK:STDOUT: !77 = !DILocation(line: 22, column: 23, scope: !75) // CHECK:STDOUT: !78 = !{!76} // CHECK:STDOUT: !79 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.5cf0c9a25f98a429:core.Destroy.Core", scope: null, file: !46, line: 22, type: !8, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !82) // CHECK:STDOUT: !80 = !DILocalVariable(arg: 1, scope: !79, type: !6) // CHECK:STDOUT: !81 = !DILocation(line: 22, column: 23, scope: !79) // CHECK:STDOUT: !82 = !{!80} // CHECK:STDOUT: !83 = distinct !DISubprogram(name: "SubobjectDestroy", linkageName: "_CSubobjectDestroy.574ea10b2e6709a0:core.Destroy.Core", scope: null, file: !46, line: 22, type: !8, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !86) // CHECK:STDOUT: !84 = !DILocalVariable(arg: 1, scope: !83, type: !6) // CHECK:STDOUT: !85 = !DILocation(line: 22, column: 23, scope: !83) // CHECK:STDOUT: !86 = !{!84} // CHECK:STDOUT: !87 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.574ea10b2e6709a0:core.Destroy.Core", scope: null, file: !46, line: 22, type: !8, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !90) // CHECK:STDOUT: !88 = !DILocalVariable(arg: 1, scope: !87, type: !6) // CHECK:STDOUT: !89 = !DILocation(line: 22, column: 23, scope: !87) // CHECK:STDOUT: !90 = !{!88} // CHECK:STDOUT: !91 = distinct !DISubprogram(name: "ReturnPtr", linkageName: "_CReturnPtr.Main", scope: null, file: !46, line: 25, type: !10, spFlags: DISPFlagDefinition, unit: !47) // CHECK:STDOUT: !94 = !DILocation(line: 26, column: 10, scope: !91) // CHECK:STDOUT: !95 = !DILocation(line: 26, column: 3, scope: !91) // CHECK:STDOUT: !96 = distinct !DISubprogram(name: "PassPtrWithThunk", linkageName: "_CPassPtrWithThunk.Main", scope: null, file: !46, line: 29, type: !8, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !100) // CHECK:STDOUT: !97 = !DILocalVariable(arg: 1, scope: !96, type: !6) // CHECK:STDOUT: !99 = !DILocation(line: 29, column: 1, scope: !96) // CHECK:STDOUT: !100 = !{!97} // CHECK:STDOUT: !101 = distinct !DISubprogram(name: "PassNonnullPtrWithThunk", linkageName: "_CPassNonnullPtrWithThunk.Main", scope: null, file: !46, line: 34, type: !8, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !107) // CHECK:STDOUT: !102 = !DILocalVariable(arg: 1, scope: !101, type: !6) // CHECK:STDOUT: !104 = !DILocation(line: 35, column: 32, scope: !101) // CHECK:STDOUT: !105 = !DILocation(line: 35, column: 3, scope: !101) // CHECK:STDOUT: !106 = !DILocation(line: 34, column: 1, scope: !101) // CHECK:STDOUT: !107 = !{!102} // CHECK:STDOUT: !108 = distinct !DISubprogram(name: "ReturnPtrWithThunk", linkageName: "_CReturnPtrWithThunk.Main", scope: null, file: !46, line: 38, type: !10, spFlags: DISPFlagDefinition, unit: !47) // CHECK:STDOUT: !111 = !DILocation(line: 39, column: 10, scope: !108) // CHECK:STDOUT: !112 = !DILocation(line: 39, column: 3, scope: !108) // CHECK:STDOUT: !113 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.538322f9fda4254f:ImplicitAs.a276ba298c70ba87.Core.75a9143bcbb84fa5", scope: null, file: !48, line: 105, type: !63, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !120) // CHECK:STDOUT: !114 = !DILocalVariable(arg: 1, scope: !113, type: !6) // CHECK:STDOUT: !118 = !DILocation(line: 106, column: 12, scope: !113) // CHECK:STDOUT: !119 = !DILocation(line: 106, column: 5, scope: !113) // CHECK:STDOUT: !120 = !{!114} // CHECK:STDOUT: !121 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.9fdaf39d07a1dc4e:OptionalAs.24b7347a93330e68.Core.e83c25d1d2fd22c2", scope: null, file: !48, line: 80, type: !63, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !129) // CHECK:STDOUT: !122 = !DILocalVariable(arg: 1, scope: !121, type: !6) // CHECK:STDOUT: !127 = !DILocation(line: 81, column: 12, scope: !121) // CHECK:STDOUT: !128 = !DILocation(line: 81, column: 5, scope: !121) // CHECK:STDOUT: !129 = !{!122} // CHECK:STDOUT: !130 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.e83c25d1d2fd22c2", scope: null, file: !48, line: 33, type: !63, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !137) // CHECK:STDOUT: !131 = !DILocalVariable(arg: 1, scope: !130, type: !6) // CHECK:STDOUT: !135 = !DILocation(line: 34, column: 12, scope: !130) // CHECK:STDOUT: !136 = !DILocation(line: 34, column: 5, scope: !130) // CHECK:STDOUT: !137 = !{!131} // CHECK:STDOUT: !138 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.e8f8f92d3d08d149:OptionalStorage.Core.77dd513e5db6ef8d", scope: null, file: !48, line: 166, type: !63, spFlags: DISPFlagDefinition, unit: !47, retainedNodes: !150) // CHECK:STDOUT: !139 = !DILocalVariable(arg: 1, scope: !138, type: !6) // CHECK:STDOUT: !143 = !DILocation(line: 167, column: 14, scope: !138) // CHECK:STDOUT: !145 = !DILocation(line: 167, column: 18, scope: !138) // CHECK:STDOUT: !147 = !DILocation(line: 169, column: 5, scope: !138) // CHECK:STDOUT: !149 = !DILocation(line: 170, column: 5, scope: !138) // CHECK:STDOUT: !150 = !{!139} // CHECK:STDOUT: !151 = !{!"p1 _ZTS9NullableC", !37, i64 0} // CHECK:STDOUT: !152 = !{!151, !151, i64 0} // CHECK:STDOUT: // CHECK:STDOUT: ; --- // CHECK:STDOUT: ; ModuleID = 'add_const.carbon' // CHECK:STDOUT: source_filename = "add_const.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: ; Function Attrs: nounwind // CHECK:STDOUT: define void @_CConvert.Main() #0 !dbg !157 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %.loc11_21.1.temp = alloca ptr, align 8, !dbg !158 // CHECK:STDOUT: %.loc11_21.5.temp = alloca ptr, align 8, !dbg !158 // CHECK:STDOUT: %make.call = call ptr @_Z4makev(), !dbg !158 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc11_21.1.temp), !dbg !158 // CHECK:STDOUT: store ptr %make.call, ptr %.loc11_21.1.temp, align 8, !dbg !158 // CHECK:STDOUT: %.loc11_21.3 = load ptr, ptr %.loc11_21.1.temp, align 8, !dbg !158 // CHECK:STDOUT: %U.as_type.as.ImplicitAs.impl.Convert.call = call ptr @"_CConvert.538322f9fda4254f:ImplicitAs.a276ba298c70ba87.Core.7d29ea9e6f62bf96"(ptr %.loc11_21.3), !dbg !158 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc11_21.5.temp), !dbg !158 // CHECK:STDOUT: store ptr %U.as_type.as.ImplicitAs.impl.Convert.call, ptr %.loc11_21.5.temp, align 8, !dbg !158 // CHECK:STDOUT: %.loc11_21.7 = load ptr, ptr %.loc11_21.5.temp, align 8, !dbg !158 // CHECK:STDOUT: call void @_Z4takePK6ConstC(ptr %.loc11_21.7), !dbg !159 // CHECK:STDOUT: call void @"_CSelfDestruct.19661d0961df889d:core.Destroy.Core"(ptr %.loc11_21.5.temp), !dbg !158 // CHECK:STDOUT: call void @"_CSelfDestruct.78fd6ee82eacbbc3:core.Destroy.Core"(ptr %.loc11_21.1.temp), !dbg !158 // CHECK:STDOUT: ret void, !dbg !160 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.23bb4d554c74e0f1:core.Destroy.Core"(ptr %self) #0 !dbg !161 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !163 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare noundef ptr @_Z4makev() #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.131ece8d9a7a4272:core.Destroy.Core"(ptr %self) #0 !dbg !165 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !167 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: declare void @_Z4takePK6ConstC(ptr noundef) #1 // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSubobjectDestroy.bdb5ffe218b7af7d:core.Destroy.Core"(ptr %self) #0 !dbg !169 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !171 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.bdb5ffe218b7af7d:core.Destroy.Core"(ptr %self) #0 !dbg !173 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @"_CSubobjectDestroy.bdb5ffe218b7af7d:core.Destroy.Core"(ptr %self), !dbg !175 // CHECK:STDOUT: ret void, !dbg !175 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSubobjectDestroy.f914f15dcbbdbae9:core.Destroy.Core"(ptr %self) #0 !dbg !177 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !179 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.f914f15dcbbdbae9:core.Destroy.Core"(ptr %self) #0 !dbg !181 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @"_CSubobjectDestroy.f914f15dcbbdbae9:core.Destroy.Core"(ptr %self), !dbg !183 // CHECK:STDOUT: ret void, !dbg !183 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSubobjectDestroy.19661d0961df889d:core.Destroy.Core"(ptr %self) #0 !dbg !185 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !187 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.19661d0961df889d:core.Destroy.Core"(ptr %self) #0 !dbg !189 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @"_CSubobjectDestroy.19661d0961df889d:core.Destroy.Core"(ptr %self), !dbg !191 // CHECK:STDOUT: ret void, !dbg !191 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSubobjectDestroy.e3602e7640dfb844:core.Destroy.Core"(ptr %self) #0 !dbg !193 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !195 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.e3602e7640dfb844:core.Destroy.Core"(ptr %self) #0 !dbg !197 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @"_CSubobjectDestroy.e3602e7640dfb844:core.Destroy.Core"(ptr %self), !dbg !199 // CHECK:STDOUT: ret void, !dbg !199 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSubobjectDestroy.bc918cd0012c1190:core.Destroy.Core"(ptr %self) #0 !dbg !201 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !203 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.bc918cd0012c1190:core.Destroy.Core"(ptr %self) #0 !dbg !205 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @"_CSubobjectDestroy.bc918cd0012c1190:core.Destroy.Core"(ptr %self), !dbg !207 // CHECK:STDOUT: ret void, !dbg !207 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSubobjectDestroy.78fd6ee82eacbbc3:core.Destroy.Core"(ptr %self) #0 !dbg !209 { // CHECK:STDOUT: entry: // CHECK:STDOUT: ret void, !dbg !211 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define weak_odr void @"_CSelfDestruct.78fd6ee82eacbbc3:core.Destroy.Core"(ptr %self) #0 !dbg !213 { // CHECK:STDOUT: entry: // CHECK:STDOUT: call void @"_CSubobjectDestroy.78fd6ee82eacbbc3:core.Destroy.Core"(ptr %self), !dbg !215 // CHECK:STDOUT: ret void, !dbg !215 // 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 linkonce_odr ptr @"_CConvert.538322f9fda4254f:ImplicitAs.a276ba298c70ba87.Core.7d29ea9e6f62bf96"(ptr %self) #0 !dbg !217 { // CHECK:STDOUT: %1 = call ptr @"_CConvert.Optional.c661605f12aa337a.Core:OptionalAs.1dac4564233fecd1.Core.c5881e9a6965c8a5"(ptr %self), !dbg !222 // CHECK:STDOUT: ret ptr %1, !dbg !223 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.Optional.c661605f12aa337a.Core:OptionalAs.1dac4564233fecd1.Core.c5881e9a6965c8a5"(ptr %self) #0 !dbg !225 { // CHECK:STDOUT: %temp = alloca ptr, align 8, !dbg !232 // CHECK:STDOUT: %temp1 = alloca ptr, align 8, !dbg !232 // CHECK:STDOUT: %1 = call i1 @_CHasValue.Optional.Core.0c3518913b4fb338(ptr %self), !dbg !230 // CHECK:STDOUT: br i1 %1, label %2, label %7, !dbg !231 // CHECK:STDOUT: // CHECK:STDOUT: 2: ; preds = %0 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %temp), !dbg !232 // CHECK:STDOUT: %3 = call ptr @_CGet.Optional.Core.0c3518913b4fb338(ptr %self), !dbg !232 // CHECK:STDOUT: store ptr %3, ptr %temp, align 8, !dbg !232 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %temp1), !dbg !232 // CHECK:STDOUT: %4 = load ptr, ptr %temp, align 8, !dbg !232 // CHECK:STDOUT: store ptr %4, ptr %temp1, align 8, !dbg !232 // CHECK:STDOUT: %5 = load ptr, ptr %temp1, align 8, !dbg !232 // CHECK:STDOUT: %6 = call ptr @_CSome.Optional.Core.305e266058820aa4(ptr %5), !dbg !233 // CHECK:STDOUT: call void @"_CSelfDestruct.131ece8d9a7a4272:core.Destroy.Core"(ptr %temp1), !dbg !232 // CHECK:STDOUT: call void @"_CSelfDestruct.23bb4d554c74e0f1:core.Destroy.Core"(ptr %temp), !dbg !232 // CHECK:STDOUT: ret ptr %6, !dbg !234 // CHECK:STDOUT: // CHECK:STDOUT: 7: ; preds = %0 // CHECK:STDOUT: %8 = call ptr @_CNone.Optional.Core.305e266058820aa4(), !dbg !235 // CHECK:STDOUT: ret ptr %8, !dbg !236 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr i1 @_CHasValue.Optional.Core.0c3518913b4fb338(ptr %self) #0 !dbg !238 { // CHECK:STDOUT: %1 = call i1 @"_CHas.e8f8f92d3d08d149:OptionalStorage.Core.21c65d90918a10a4"(ptr %self), !dbg !244 // CHECK:STDOUT: ret i1 %1, !dbg !245 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr ptr @_CGet.Optional.Core.0c3518913b4fb338(ptr %self) #0 !dbg !247 { // CHECK:STDOUT: %1 = call ptr @"_CGet.e8f8f92d3d08d149:OptionalStorage.Core.21c65d90918a10a4"(ptr %self), !dbg !253 // CHECK:STDOUT: ret ptr %1, !dbg !254 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr ptr @_CSome.Optional.Core.305e266058820aa4(ptr %value) #0 !dbg !256 { // CHECK:STDOUT: %1 = call ptr @"_CSome.e8f8f92d3d08d149:OptionalStorage.Core.35c29317da7de352"(ptr %value), !dbg !261 // CHECK:STDOUT: ret ptr %1, !dbg !262 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr ptr @_CNone.Optional.Core.305e266058820aa4() #0 !dbg !264 { // CHECK:STDOUT: ret ptr null, !dbg !268 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr i1 @"_CHas.e8f8f92d3d08d149:OptionalStorage.Core.21c65d90918a10a4"(ptr %value) #0 !dbg !269 { // CHECK:STDOUT: %1 = icmp eq ptr %value, null, !dbg !275 // CHECK:STDOUT: %2 = xor i1 %1, true, !dbg !276 // CHECK:STDOUT: ret i1 %2, !dbg !277 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr ptr @"_CGet.e8f8f92d3d08d149:OptionalStorage.Core.21c65d90918a10a4"(ptr %value) #0 !dbg !279 { // CHECK:STDOUT: ret ptr %value, !dbg !285 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; Function Attrs: nounwind // CHECK:STDOUT: define linkonce_odr ptr @"_CSome.e8f8f92d3d08d149:OptionalStorage.Core.35c29317da7de352"(ptr %self) #0 !dbg !287 { // CHECK:STDOUT: %1 = alloca ptr, align 8, !dbg !292 // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %1), !dbg !292 // CHECK:STDOUT: store ptr poison, ptr %1, align 8, !dbg !292 // CHECK:STDOUT: store ptr %self, ptr %1, align 8, !dbg !296 // CHECK:STDOUT: %2 = load ptr, ptr %1, align 8, !dbg !294 // CHECK:STDOUT: call void @"_CSelfDestruct.f914f15dcbbdbae9:core.Destroy.Core"(ptr %1), !dbg !292 // CHECK:STDOUT: ret ptr %2, !dbg !298 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: ; uselistorder directives // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 0, 1, 2, 4, 3 } // CHECK:STDOUT: // CHECK:STDOUT: attributes #0 = { nounwind } // CHECK:STDOUT: attributes #1 = { "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: // CHECK:STDOUT: !llvm.dbg.cu = !{!154} // CHECK:STDOUT: !llvm.module.flags = !{!40, !41, !42, !2, !3} // CHECK:STDOUT: !llvm.errno.tbaa = !{!45} // CHECK:STDOUT: // CHECK:STDOUT: !2 = !{i32 7, !"Dwarf Version", i32 5} // CHECK:STDOUT: !3 = !{i32 2, !"Debug Info Version", i32 3} // CHECK:STDOUT: !6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) // CHECK:STDOUT: !7 = !{null, !6} // CHECK:STDOUT: !8 = !DISubroutineType(types: !7) // CHECK:STDOUT: !9 = !{!6} // CHECK:STDOUT: !10 = !DISubroutineType(types: !9) // CHECK:STDOUT: !35 = !{!"Simple C++ TBAA"} // CHECK:STDOUT: !36 = !{!"omnipotent char", !35, i64 0} // CHECK:STDOUT: !40 = !{i32 8, !"PIC Level", i32 2} // CHECK:STDOUT: !41 = !{i32 7, !"PIE Level", i32 2} // CHECK:STDOUT: !42 = !{i32 7, !"uwtable", i32 2} // CHECK:STDOUT: !43 = !{!"int", !36, i64 0} // CHECK:STDOUT: !44 = !{!"__libc_errno", !43, i64 0} // CHECK:STDOUT: !45 = !{!44, !43, i64 0} // CHECK:STDOUT: !48 = !DIFile(filename: "{{.*}}/prelude/types/optional.carbon", directory: "") // CHECK:STDOUT: !62 = !{!6, !6} // CHECK:STDOUT: !63 = !DISubroutineType(types: !62) // CHECK:STDOUT: !153 = !DIFile(filename: "add_const.carbon", directory: "") // CHECK:STDOUT: !154 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !153, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) // CHECK:STDOUT: !155 = !{null} // CHECK:STDOUT: !156 = !DISubroutineType(types: !155) // CHECK:STDOUT: !157 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Main", scope: null, file: !153, line: 10, type: !156, spFlags: DISPFlagDefinition, unit: !154) // CHECK:STDOUT: !158 = !DILocation(line: 11, column: 12, scope: !157) // CHECK:STDOUT: !159 = !DILocation(line: 11, column: 3, scope: !157) // CHECK:STDOUT: !160 = !DILocation(line: 10, column: 1, scope: !157) // CHECK:STDOUT: !161 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.23bb4d554c74e0f1:core.Destroy.Core", scope: null, file: !48, line: 164, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !164) // CHECK:STDOUT: !162 = !DILocalVariable(arg: 1, scope: !161, type: !6) // CHECK:STDOUT: !163 = !DILocation(line: 164, column: 19, scope: !161) // CHECK:STDOUT: !164 = !{!162} // CHECK:STDOUT: !165 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.131ece8d9a7a4272:core.Destroy.Core", scope: null, file: !48, line: 164, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !168) // CHECK:STDOUT: !166 = !DILocalVariable(arg: 1, scope: !165, type: !6) // CHECK:STDOUT: !167 = !DILocation(line: 164, column: 19, scope: !165) // CHECK:STDOUT: !168 = !{!166} // CHECK:STDOUT: !169 = distinct !DISubprogram(name: "SubobjectDestroy", linkageName: "_CSubobjectDestroy.bdb5ffe218b7af7d:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !172) // CHECK:STDOUT: !170 = !DILocalVariable(arg: 1, scope: !169, type: !6) // CHECK:STDOUT: !171 = !DILocation(line: 11, column: 12, scope: !169) // CHECK:STDOUT: !172 = !{!170} // CHECK:STDOUT: !173 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.bdb5ffe218b7af7d:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !176) // CHECK:STDOUT: !174 = !DILocalVariable(arg: 1, scope: !173, type: !6) // CHECK:STDOUT: !175 = !DILocation(line: 11, column: 12, scope: !173) // CHECK:STDOUT: !176 = !{!174} // CHECK:STDOUT: !177 = distinct !DISubprogram(name: "SubobjectDestroy", linkageName: "_CSubobjectDestroy.f914f15dcbbdbae9:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !180) // CHECK:STDOUT: !178 = !DILocalVariable(arg: 1, scope: !177, type: !6) // CHECK:STDOUT: !179 = !DILocation(line: 11, column: 12, scope: !177) // CHECK:STDOUT: !180 = !{!178} // CHECK:STDOUT: !181 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.f914f15dcbbdbae9:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !184) // CHECK:STDOUT: !182 = !DILocalVariable(arg: 1, scope: !181, type: !6) // CHECK:STDOUT: !183 = !DILocation(line: 11, column: 12, scope: !181) // CHECK:STDOUT: !184 = !{!182} // CHECK:STDOUT: !185 = distinct !DISubprogram(name: "SubobjectDestroy", linkageName: "_CSubobjectDestroy.19661d0961df889d:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !188) // CHECK:STDOUT: !186 = !DILocalVariable(arg: 1, scope: !185, type: !6) // CHECK:STDOUT: !187 = !DILocation(line: 11, column: 12, scope: !185) // CHECK:STDOUT: !188 = !{!186} // CHECK:STDOUT: !189 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.19661d0961df889d:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !192) // CHECK:STDOUT: !190 = !DILocalVariable(arg: 1, scope: !189, type: !6) // CHECK:STDOUT: !191 = !DILocation(line: 11, column: 12, scope: !189) // CHECK:STDOUT: !192 = !{!190} // CHECK:STDOUT: !193 = distinct !DISubprogram(name: "SubobjectDestroy", linkageName: "_CSubobjectDestroy.e3602e7640dfb844:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !196) // CHECK:STDOUT: !194 = !DILocalVariable(arg: 1, scope: !193, type: !6) // CHECK:STDOUT: !195 = !DILocation(line: 11, column: 12, scope: !193) // CHECK:STDOUT: !196 = !{!194} // CHECK:STDOUT: !197 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.e3602e7640dfb844:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !200) // CHECK:STDOUT: !198 = !DILocalVariable(arg: 1, scope: !197, type: !6) // CHECK:STDOUT: !199 = !DILocation(line: 11, column: 12, scope: !197) // CHECK:STDOUT: !200 = !{!198} // CHECK:STDOUT: !201 = distinct !DISubprogram(name: "SubobjectDestroy", linkageName: "_CSubobjectDestroy.bc918cd0012c1190:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !204) // CHECK:STDOUT: !202 = !DILocalVariable(arg: 1, scope: !201, type: !6) // CHECK:STDOUT: !203 = !DILocation(line: 11, column: 12, scope: !201) // CHECK:STDOUT: !204 = !{!202} // CHECK:STDOUT: !205 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.bc918cd0012c1190:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !208) // CHECK:STDOUT: !206 = !DILocalVariable(arg: 1, scope: !205, type: !6) // CHECK:STDOUT: !207 = !DILocation(line: 11, column: 12, scope: !205) // CHECK:STDOUT: !208 = !{!206} // CHECK:STDOUT: !209 = distinct !DISubprogram(name: "SubobjectDestroy", linkageName: "_CSubobjectDestroy.78fd6ee82eacbbc3:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !212) // CHECK:STDOUT: !210 = !DILocalVariable(arg: 1, scope: !209, type: !6) // CHECK:STDOUT: !211 = !DILocation(line: 11, column: 12, scope: !209) // CHECK:STDOUT: !212 = !{!210} // CHECK:STDOUT: !213 = distinct !DISubprogram(name: "SelfDestruct", linkageName: "_CSelfDestruct.78fd6ee82eacbbc3:core.Destroy.Core", scope: null, file: !153, line: 11, type: !8, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !216) // CHECK:STDOUT: !214 = !DILocalVariable(arg: 1, scope: !213, type: !6) // CHECK:STDOUT: !215 = !DILocation(line: 11, column: 12, scope: !213) // CHECK:STDOUT: !216 = !{!214} // CHECK:STDOUT: !217 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.538322f9fda4254f:ImplicitAs.a276ba298c70ba87.Core.7d29ea9e6f62bf96", scope: null, file: !48, line: 105, type: !63, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !224) // CHECK:STDOUT: !218 = !DILocalVariable(arg: 1, scope: !217, type: !6) // CHECK:STDOUT: !222 = !DILocation(line: 106, column: 12, scope: !217) // CHECK:STDOUT: !223 = !DILocation(line: 106, column: 5, scope: !217) // CHECK:STDOUT: !224 = !{!218} // CHECK:STDOUT: !225 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Optional.c661605f12aa337a.Core:OptionalAs.1dac4564233fecd1.Core.c5881e9a6965c8a5", scope: null, file: !48, line: 95, type: !63, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !237) // CHECK:STDOUT: !226 = !DILocalVariable(arg: 1, scope: !225, type: !6) // CHECK:STDOUT: !230 = !DILocation(line: 96, column: 9, scope: !225) // CHECK:STDOUT: !231 = !DILocation(line: 96, column: 8, scope: !225) // CHECK:STDOUT: !232 = !DILocation(line: 97, column: 31, scope: !225) // CHECK:STDOUT: !233 = !DILocation(line: 97, column: 14, scope: !225) // CHECK:STDOUT: !234 = !DILocation(line: 97, column: 7, scope: !225) // CHECK:STDOUT: !235 = !DILocation(line: 99, column: 12, scope: !225) // CHECK:STDOUT: !236 = !DILocation(line: 99, column: 5, scope: !225) // CHECK:STDOUT: !237 = !{!226} // CHECK:STDOUT: !238 = distinct !DISubprogram(name: "HasValue", linkageName: "_CHasValue.Optional.Core.0c3518913b4fb338", scope: null, file: !48, line: 36, type: !63, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !246) // CHECK:STDOUT: !239 = !DILocalVariable(arg: 1, scope: !238, type: !6) // CHECK:STDOUT: !244 = !DILocation(line: 37, column: 12, scope: !238) // CHECK:STDOUT: !245 = !DILocation(line: 37, column: 5, scope: !238) // CHECK:STDOUT: !246 = !{!239} // CHECK:STDOUT: !247 = distinct !DISubprogram(name: "Get", linkageName: "_CGet.Optional.Core.0c3518913b4fb338", scope: null, file: !48, line: 39, type: !63, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !255) // CHECK:STDOUT: !248 = !DILocalVariable(arg: 1, scope: !247, type: !6) // CHECK:STDOUT: !253 = !DILocation(line: 40, column: 12, scope: !247) // CHECK:STDOUT: !254 = !DILocation(line: 40, column: 5, scope: !247) // CHECK:STDOUT: !255 = !{!248} // CHECK:STDOUT: !256 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.305e266058820aa4", scope: null, file: !48, line: 33, type: !63, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !263) // CHECK:STDOUT: !257 = !DILocalVariable(arg: 1, scope: !256, type: !6) // CHECK:STDOUT: !261 = !DILocation(line: 34, column: 12, scope: !256) // CHECK:STDOUT: !262 = !DILocation(line: 34, column: 5, scope: !256) // CHECK:STDOUT: !263 = !{!257} // CHECK:STDOUT: !264 = distinct !DISubprogram(name: "None", linkageName: "_CNone.Optional.Core.305e266058820aa4", scope: null, file: !48, line: 30, type: !10, spFlags: DISPFlagDefinition, unit: !154) // CHECK:STDOUT: !268 = !DILocation(line: 31, column: 5, scope: !264) // CHECK:STDOUT: !269 = distinct !DISubprogram(name: "Has", linkageName: "_CHas.e8f8f92d3d08d149:OptionalStorage.Core.21c65d90918a10a4", scope: null, file: !48, line: 172, type: !63, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !278) // CHECK:STDOUT: !270 = !DILocalVariable(arg: 1, scope: !269, type: !6) // CHECK:STDOUT: !275 = !DILocation(line: 173, column: 16, scope: !269) // CHECK:STDOUT: !276 = !DILocation(line: 173, column: 12, scope: !269) // CHECK:STDOUT: !277 = !DILocation(line: 173, column: 5, scope: !269) // CHECK:STDOUT: !278 = !{!270} // CHECK:STDOUT: !279 = distinct !DISubprogram(name: "Get", linkageName: "_CGet.e8f8f92d3d08d149:OptionalStorage.Core.21c65d90918a10a4", scope: null, file: !48, line: 175, type: !63, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !286) // CHECK:STDOUT: !280 = !DILocalVariable(arg: 1, scope: !279, type: !6) // CHECK:STDOUT: !285 = !DILocation(line: 176, column: 5, scope: !279) // CHECK:STDOUT: !286 = !{!280} // CHECK:STDOUT: !287 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.e8f8f92d3d08d149:OptionalStorage.Core.35c29317da7de352", scope: null, file: !48, line: 166, type: !63, spFlags: DISPFlagDefinition, unit: !154, retainedNodes: !299) // CHECK:STDOUT: !288 = !DILocalVariable(arg: 1, scope: !287, type: !6) // CHECK:STDOUT: !292 = !DILocation(line: 167, column: 14, scope: !287) // CHECK:STDOUT: !294 = !DILocation(line: 167, column: 18, scope: !287) // CHECK:STDOUT: !296 = !DILocation(line: 169, column: 5, scope: !287) // CHECK:STDOUT: !298 = !DILocation(line: 170, column: 5, scope: !287) // CHECK:STDOUT: !299 = !{!288} // CHECK:STDOUT: