pointer.carbon 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/full.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/interop/cpp/pointer.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interop/cpp/pointer.carbon
  12. // ============================================================================
  13. // Non-null pointers
  14. // ============================================================================
  15. // --- nonnull.carbon
  16. library "[[@TEST_NAME]]";
  17. import Cpp inline '''
  18. class C {};
  19. auto TakePtr(C* _Nonnull) -> void;
  20. auto ReturnPtr() -> C* _Nonnull;
  21. auto TakePtrWithThunk(C* _Nonnull, int = 0) -> void;
  22. auto ReturnPtrWithThunk(int = 0) -> C* _Nonnull;
  23. ''';
  24. fn PassPtr(p: Cpp.C*) {
  25. Cpp.TakePtr(p);
  26. }
  27. fn ReturnPtr() -> Cpp.C* {
  28. return Cpp.ReturnPtr();
  29. }
  30. fn PassPtrWithThunk(p: Cpp.C*) {
  31. Cpp.TakePtrWithThunk(p);
  32. }
  33. fn ReturnPtrWithThunk() -> Cpp.C* {
  34. return Cpp.ReturnPtrWithThunk();
  35. }
  36. // ============================================================================
  37. // Nullable pointers
  38. // ============================================================================
  39. // --- nullable.carbon
  40. library "[[@TEST_NAME]]";
  41. import Cpp inline '''
  42. class C {};
  43. auto TakePtr(C*) -> void;
  44. auto ReturnPtr() -> C*;
  45. auto TakePtrWithThunk(C*, int = 0) -> void;
  46. auto ReturnPtrWithThunk(int = 0) -> C*;
  47. ''';
  48. fn PassPtr(_: Core.Optional(Cpp.C*)) {
  49. // TODO: Add support for passing an optional here.
  50. // Cpp.TakePtr(p);
  51. }
  52. fn PassNonnullPtr(p: Cpp.C*) {
  53. // TODO: The `value_of_initializer` optimization doesn't get used here, so we
  54. // unnecessarily round-trip this value through memory.
  55. Cpp.TakePtr(p);
  56. }
  57. fn ReturnPtr() -> Core.Optional(Cpp.C*) {
  58. return Cpp.ReturnPtr();
  59. }
  60. fn PassPtrWithThunk(_: Core.Optional(Cpp.C*)) {
  61. // TODO: Add support for passing an optional here.
  62. // Cpp.TakePtrWithThunk(p);
  63. }
  64. fn PassNonnullPtrWithThunk(p: Cpp.C*) {
  65. Cpp.TakePtrWithThunk(p);
  66. }
  67. fn ReturnPtrWithThunk() -> Core.Optional(Cpp.C*) {
  68. return Cpp.ReturnPtrWithThunk();
  69. }
  70. // CHECK:STDOUT: ; ModuleID = 'nonnull.carbon'
  71. // CHECK:STDOUT: source_filename = "nonnull.carbon"
  72. // 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"
  73. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  76. // CHECK:STDOUT: define dso_local void @_Z16TakePtrWithThunkP1Ci.carbon_thunk1(ptr noundef %0) #0 {
  77. // CHECK:STDOUT: entry:
  78. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  79. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !12
  80. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !12
  81. // CHECK:STDOUT: call void @_Z16TakePtrWithThunkP1Ci(ptr noundef %1, i32 noundef 0)
  82. // CHECK:STDOUT: ret void
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: declare void @_Z16TakePtrWithThunkP1Ci(ptr noundef, i32 noundef) #1
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  88. // CHECK:STDOUT: define dso_local noundef ptr @_Z18ReturnPtrWithThunki.carbon_thunk0() #0 {
  89. // CHECK:STDOUT: entry:
  90. // CHECK:STDOUT: %call = call noundef ptr @_Z18ReturnPtrWithThunki(i32 noundef 0)
  91. // CHECK:STDOUT: ret ptr %call
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: declare noundef ptr @_Z18ReturnPtrWithThunki(i32 noundef) #1
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: ; Function Attrs: nounwind
  97. // CHECK:STDOUT: define void @_CPassPtr.Main(ptr %p) #2 !dbg !15 {
  98. // CHECK:STDOUT: entry:
  99. // CHECK:STDOUT: call void @_Z7TakePtrP1C(ptr %p), !dbg !21
  100. // CHECK:STDOUT: ret void, !dbg !22
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: declare void @_Z7TakePtrP1C(ptr noundef) #1
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: ; Function Attrs: nounwind
  106. // CHECK:STDOUT: define ptr @_CReturnPtr.Main() #2 !dbg !23 {
  107. // CHECK:STDOUT: entry:
  108. // CHECK:STDOUT: %ReturnPtr.call = call ptr @_Z9ReturnPtrv(), !dbg !26
  109. // CHECK:STDOUT: ret ptr %ReturnPtr.call, !dbg !27
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: declare noundef ptr @_Z9ReturnPtrv() #1
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: ; Function Attrs: nounwind
  115. // CHECK:STDOUT: define void @_CPassPtrWithThunk.Main(ptr %p) #2 !dbg !28 {
  116. // CHECK:STDOUT: entry:
  117. // CHECK:STDOUT: call void @_Z16TakePtrWithThunkP1Ci.carbon_thunk1(ptr %p), !dbg !31
  118. // CHECK:STDOUT: ret void, !dbg !32
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: ; Function Attrs: nounwind
  122. // CHECK:STDOUT: define ptr @_CReturnPtrWithThunk.Main() #2 !dbg !33 {
  123. // CHECK:STDOUT: entry:
  124. // CHECK:STDOUT: %ReturnPtrWithThunk__carbon_thunk.call = call ptr @_Z18ReturnPtrWithThunki.carbon_thunk0(), !dbg !34
  125. // CHECK:STDOUT: ret ptr %ReturnPtrWithThunk__carbon_thunk.call, !dbg !35
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: attributes #0 = { 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" }
  129. // 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" }
  130. // CHECK:STDOUT: attributes #2 = { nounwind }
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4, !5}
  133. // CHECK:STDOUT: !llvm.dbg.cu = !{!6}
  134. // CHECK:STDOUT: !llvm.errno.tbaa = !{!8}
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  137. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  138. // CHECK:STDOUT: !2 = !{i32 1, !"wchar_size", i32 4}
  139. // CHECK:STDOUT: !3 = !{i32 8, !"PIC Level", i32 2}
  140. // CHECK:STDOUT: !4 = !{i32 7, !"PIE Level", i32 2}
  141. // CHECK:STDOUT: !5 = !{i32 7, !"uwtable", i32 2}
  142. // CHECK:STDOUT: !6 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !7, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  143. // CHECK:STDOUT: !7 = !DIFile(filename: "nonnull.carbon", directory: "")
  144. // CHECK:STDOUT: !8 = !{!9, !9, i64 0}
  145. // CHECK:STDOUT: !9 = !{!"int", !10, i64 0}
  146. // CHECK:STDOUT: !10 = !{!"omnipotent char", !11, i64 0}
  147. // CHECK:STDOUT: !11 = !{!"Simple C++ TBAA"}
  148. // CHECK:STDOUT: !12 = !{!13, !13, i64 0}
  149. // CHECK:STDOUT: !13 = !{!"p1 _ZTS1C", !14, i64 0}
  150. // CHECK:STDOUT: !14 = !{!"any pointer", !10, i64 0}
  151. // CHECK:STDOUT: !15 = distinct !DISubprogram(name: "PassPtr", linkageName: "_CPassPtr.Main", scope: null, file: !7, line: 14, type: !16, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !19)
  152. // CHECK:STDOUT: !16 = !DISubroutineType(types: !17)
  153. // CHECK:STDOUT: !17 = !{null, !18}
  154. // CHECK:STDOUT: !18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 8)
  155. // CHECK:STDOUT: !19 = !{!20}
  156. // CHECK:STDOUT: !20 = !DILocalVariable(arg: 1, scope: !15, type: !18)
  157. // CHECK:STDOUT: !21 = !DILocation(line: 15, column: 3, scope: !15)
  158. // CHECK:STDOUT: !22 = !DILocation(line: 14, column: 1, scope: !15)
  159. // CHECK:STDOUT: !23 = distinct !DISubprogram(name: "ReturnPtr", linkageName: "_CReturnPtr.Main", scope: null, file: !7, line: 18, type: !24, spFlags: DISPFlagDefinition, unit: !6)
  160. // CHECK:STDOUT: !24 = !DISubroutineType(types: !25)
  161. // CHECK:STDOUT: !25 = !{!18}
  162. // CHECK:STDOUT: !26 = !DILocation(line: 19, column: 10, scope: !23)
  163. // CHECK:STDOUT: !27 = !DILocation(line: 19, column: 3, scope: !23)
  164. // CHECK:STDOUT: !28 = distinct !DISubprogram(name: "PassPtrWithThunk", linkageName: "_CPassPtrWithThunk.Main", scope: null, file: !7, line: 22, type: !16, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !29)
  165. // CHECK:STDOUT: !29 = !{!30}
  166. // CHECK:STDOUT: !30 = !DILocalVariable(arg: 1, scope: !28, type: !18)
  167. // CHECK:STDOUT: !31 = !DILocation(line: 23, column: 3, scope: !28)
  168. // CHECK:STDOUT: !32 = !DILocation(line: 22, column: 1, scope: !28)
  169. // CHECK:STDOUT: !33 = distinct !DISubprogram(name: "ReturnPtrWithThunk", linkageName: "_CReturnPtrWithThunk.Main", scope: null, file: !7, line: 26, type: !24, spFlags: DISPFlagDefinition, unit: !6)
  170. // CHECK:STDOUT: !34 = !DILocation(line: 27, column: 10, scope: !33)
  171. // CHECK:STDOUT: !35 = !DILocation(line: 27, column: 3, scope: !33)
  172. // CHECK:STDOUT: ; ModuleID = 'nullable.carbon'
  173. // CHECK:STDOUT: source_filename = "nullable.carbon"
  174. // 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"
  175. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  178. // CHECK:STDOUT: define dso_local void @_Z16TakePtrWithThunkP1Ci.carbon_thunk1(ptr noundef %0) #0 {
  179. // CHECK:STDOUT: entry:
  180. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  181. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !12
  182. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !12
  183. // CHECK:STDOUT: call void @_Z16TakePtrWithThunkP1Ci(ptr noundef %1, i32 noundef 0)
  184. // CHECK:STDOUT: ret void
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: declare void @_Z16TakePtrWithThunkP1Ci(ptr noundef, i32 noundef) #1
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  190. // CHECK:STDOUT: define dso_local noundef ptr @_Z18ReturnPtrWithThunki.carbon_thunk0() #0 {
  191. // CHECK:STDOUT: entry:
  192. // CHECK:STDOUT: %call = call noundef ptr @_Z18ReturnPtrWithThunki(i32 noundef 0)
  193. // CHECK:STDOUT: ret ptr %call
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: declare noundef ptr @_Z18ReturnPtrWithThunki(i32 noundef) #1
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: ; Function Attrs: nounwind
  199. // CHECK:STDOUT: define void @_CPassPtr.Main(ptr %_) #2 !dbg !15 {
  200. // CHECK:STDOUT: entry:
  201. // CHECK:STDOUT: ret void, !dbg !21
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: ; Function Attrs: nounwind
  205. // CHECK:STDOUT: define void @_CPassNonnullPtr.Main(ptr %p) #2 !dbg !22 {
  206. // CHECK:STDOUT: entry:
  207. // CHECK:STDOUT: %.loc22_15.2.temp = alloca ptr, align 8, !dbg !25
  208. // CHECK:STDOUT: %U.binding.as_type.as.ImplicitAs.impl.Convert.call = call ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.e76fd6d2be138e4a"(ptr %p), !dbg !25
  209. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc22_15.2.temp), !dbg !25
  210. // CHECK:STDOUT: store ptr %U.binding.as_type.as.ImplicitAs.impl.Convert.call, ptr %.loc22_15.2.temp, align 8, !dbg !25
  211. // CHECK:STDOUT: %.loc22_15.4 = load ptr, ptr %.loc22_15.2.temp, align 8, !dbg !25
  212. // CHECK:STDOUT: call void @_Z7TakePtrP1C(ptr %.loc22_15.4), !dbg !26
  213. // CHECK:STDOUT: ret void, !dbg !27
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: declare void @_Z7TakePtrP1C(ptr noundef) #1
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: ; Function Attrs: nounwind
  219. // CHECK:STDOUT: define ptr @_CReturnPtr.Main() #2 !dbg !28 {
  220. // CHECK:STDOUT: entry:
  221. // CHECK:STDOUT: %ReturnPtr.call = call ptr @_Z9ReturnPtrv(), !dbg !31
  222. // CHECK:STDOUT: ret ptr %ReturnPtr.call, !dbg !32
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: declare noundef ptr @_Z9ReturnPtrv() #1
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: ; Function Attrs: nounwind
  228. // CHECK:STDOUT: define void @_CPassPtrWithThunk.Main(ptr %_) #2 !dbg !33 {
  229. // CHECK:STDOUT: entry:
  230. // CHECK:STDOUT: ret void, !dbg !36
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: ; Function Attrs: nounwind
  234. // CHECK:STDOUT: define void @_CPassNonnullPtrWithThunk.Main(ptr %p) #2 !dbg !37 {
  235. // CHECK:STDOUT: entry:
  236. // CHECK:STDOUT: %.loc35_24.2.temp = alloca ptr, align 8, !dbg !40
  237. // CHECK:STDOUT: %U.binding.as_type.as.ImplicitAs.impl.Convert.call = call ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.e76fd6d2be138e4a"(ptr %p), !dbg !40
  238. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc35_24.2.temp), !dbg !40
  239. // CHECK:STDOUT: store ptr %U.binding.as_type.as.ImplicitAs.impl.Convert.call, ptr %.loc35_24.2.temp, align 8, !dbg !40
  240. // CHECK:STDOUT: %.loc35_24.4 = load ptr, ptr %.loc35_24.2.temp, align 8, !dbg !40
  241. // CHECK:STDOUT: call void @_Z16TakePtrWithThunkP1Ci.carbon_thunk1(ptr %.loc35_24.4), !dbg !41
  242. // CHECK:STDOUT: ret void, !dbg !42
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: ; Function Attrs: nounwind
  246. // CHECK:STDOUT: define ptr @_CReturnPtrWithThunk.Main() #2 !dbg !43 {
  247. // CHECK:STDOUT: entry:
  248. // CHECK:STDOUT: %ReturnPtrWithThunk__carbon_thunk.call = call ptr @_Z18ReturnPtrWithThunki.carbon_thunk0(), !dbg !44
  249. // CHECK:STDOUT: ret ptr %ReturnPtrWithThunk__carbon_thunk.call, !dbg !45
  250. // CHECK:STDOUT: }
  251. // CHECK:STDOUT:
  252. // CHECK:STDOUT: ; Function Attrs: nounwind
  253. // CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.e76fd6d2be138e4a"(ptr %self) #2 !dbg !46 {
  254. // CHECK:STDOUT: %1 = call ptr @"_CConvert.90961d7b1ce4f089:OptionalAs.0e326e799dad0c64.Core.8f431b36581f9e63"(ptr %self), !dbg !52
  255. // CHECK:STDOUT: ret ptr %1, !dbg !53
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  259. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #3
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: ; Function Attrs: nounwind
  262. // CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.90961d7b1ce4f089:OptionalAs.0e326e799dad0c64.Core.8f431b36581f9e63"(ptr %self) #2 !dbg !54 {
  263. // CHECK:STDOUT: %1 = call ptr @_CSome.Optional.Core.8f431b36581f9e63(ptr %self), !dbg !57
  264. // CHECK:STDOUT: ret ptr %1, !dbg !58
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT:
  267. // CHECK:STDOUT: ; Function Attrs: nounwind
  268. // CHECK:STDOUT: define linkonce_odr ptr @_CSome.Optional.Core.8f431b36581f9e63(ptr %value) #2 !dbg !59 {
  269. // CHECK:STDOUT: %1 = call ptr @"_CSome.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655"(ptr %value), !dbg !62
  270. // CHECK:STDOUT: ret ptr %1, !dbg !63
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: ; Function Attrs: nounwind
  274. // CHECK:STDOUT: define linkonce_odr ptr @"_CSome.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655"(ptr %self) #2 !dbg !64 {
  275. // CHECK:STDOUT: %1 = alloca ptr, align 8, !dbg !67
  276. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %1), !dbg !67
  277. // CHECK:STDOUT: store ptr %self, ptr %1, align 8, !dbg !68
  278. // CHECK:STDOUT: %2 = load ptr, ptr %1, align 8, !dbg !69
  279. // CHECK:STDOUT: ret ptr %2, !dbg !70
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: ; uselistorder directives
  283. // CHECK:STDOUT: uselistorder ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.e76fd6d2be138e4a", { 1, 0 }
  284. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 0, 2, 1 }
  285. // CHECK:STDOUT:
  286. // CHECK:STDOUT: attributes #0 = { 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" }
  287. // 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" }
  288. // CHECK:STDOUT: attributes #2 = { nounwind }
  289. // CHECK:STDOUT: attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4, !5}
  292. // CHECK:STDOUT: !llvm.dbg.cu = !{!6}
  293. // CHECK:STDOUT: !llvm.errno.tbaa = !{!8}
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  296. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  297. // CHECK:STDOUT: !2 = !{i32 1, !"wchar_size", i32 4}
  298. // CHECK:STDOUT: !3 = !{i32 8, !"PIC Level", i32 2}
  299. // CHECK:STDOUT: !4 = !{i32 7, !"PIE Level", i32 2}
  300. // CHECK:STDOUT: !5 = !{i32 7, !"uwtable", i32 2}
  301. // CHECK:STDOUT: !6 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !7, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  302. // CHECK:STDOUT: !7 = !DIFile(filename: "nullable.carbon", directory: "")
  303. // CHECK:STDOUT: !8 = !{!9, !9, i64 0}
  304. // CHECK:STDOUT: !9 = !{!"int", !10, i64 0}
  305. // CHECK:STDOUT: !10 = !{!"omnipotent char", !11, i64 0}
  306. // CHECK:STDOUT: !11 = !{!"Simple C++ TBAA"}
  307. // CHECK:STDOUT: !12 = !{!13, !13, i64 0}
  308. // CHECK:STDOUT: !13 = !{!"p1 _ZTS1C", !14, i64 0}
  309. // CHECK:STDOUT: !14 = !{!"any pointer", !10, i64 0}
  310. // CHECK:STDOUT: !15 = distinct !DISubprogram(name: "PassPtr", linkageName: "_CPassPtr.Main", scope: null, file: !7, line: 14, type: !16, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !19)
  311. // CHECK:STDOUT: !16 = !DISubroutineType(types: !17)
  312. // CHECK:STDOUT: !17 = !{null, !18}
  313. // CHECK:STDOUT: !18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 8)
  314. // CHECK:STDOUT: !19 = !{!20}
  315. // CHECK:STDOUT: !20 = !DILocalVariable(arg: 1, scope: !15, type: !18)
  316. // CHECK:STDOUT: !21 = !DILocation(line: 14, column: 1, scope: !15)
  317. // CHECK:STDOUT: !22 = distinct !DISubprogram(name: "PassNonnullPtr", linkageName: "_CPassNonnullPtr.Main", scope: null, file: !7, line: 19, type: !16, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !23)
  318. // CHECK:STDOUT: !23 = !{!24}
  319. // CHECK:STDOUT: !24 = !DILocalVariable(arg: 1, scope: !22, type: !18)
  320. // CHECK:STDOUT: !25 = !DILocation(line: 22, column: 15, scope: !22)
  321. // CHECK:STDOUT: !26 = !DILocation(line: 22, column: 3, scope: !22)
  322. // CHECK:STDOUT: !27 = !DILocation(line: 19, column: 1, scope: !22)
  323. // CHECK:STDOUT: !28 = distinct !DISubprogram(name: "ReturnPtr", linkageName: "_CReturnPtr.Main", scope: null, file: !7, line: 25, type: !29, spFlags: DISPFlagDefinition, unit: !6)
  324. // CHECK:STDOUT: !29 = !DISubroutineType(types: !30)
  325. // CHECK:STDOUT: !30 = !{!18}
  326. // CHECK:STDOUT: !31 = !DILocation(line: 26, column: 10, scope: !28)
  327. // CHECK:STDOUT: !32 = !DILocation(line: 26, column: 3, scope: !28)
  328. // CHECK:STDOUT: !33 = distinct !DISubprogram(name: "PassPtrWithThunk", linkageName: "_CPassPtrWithThunk.Main", scope: null, file: !7, line: 29, type: !16, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !34)
  329. // CHECK:STDOUT: !34 = !{!35}
  330. // CHECK:STDOUT: !35 = !DILocalVariable(arg: 1, scope: !33, type: !18)
  331. // CHECK:STDOUT: !36 = !DILocation(line: 29, column: 1, scope: !33)
  332. // CHECK:STDOUT: !37 = distinct !DISubprogram(name: "PassNonnullPtrWithThunk", linkageName: "_CPassNonnullPtrWithThunk.Main", scope: null, file: !7, line: 34, type: !16, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !38)
  333. // CHECK:STDOUT: !38 = !{!39}
  334. // CHECK:STDOUT: !39 = !DILocalVariable(arg: 1, scope: !37, type: !18)
  335. // CHECK:STDOUT: !40 = !DILocation(line: 35, column: 24, scope: !37)
  336. // CHECK:STDOUT: !41 = !DILocation(line: 35, column: 3, scope: !37)
  337. // CHECK:STDOUT: !42 = !DILocation(line: 34, column: 1, scope: !37)
  338. // CHECK:STDOUT: !43 = distinct !DISubprogram(name: "ReturnPtrWithThunk", linkageName: "_CReturnPtrWithThunk.Main", scope: null, file: !7, line: 38, type: !29, spFlags: DISPFlagDefinition, unit: !6)
  339. // CHECK:STDOUT: !44 = !DILocation(line: 39, column: 10, scope: !43)
  340. // CHECK:STDOUT: !45 = !DILocation(line: 39, column: 3, scope: !43)
  341. // CHECK:STDOUT: !46 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.e76fd6d2be138e4a", scope: null, file: !47, line: 93, type: !48, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !50)
  342. // CHECK:STDOUT: !47 = !DIFile(filename: "{{.*}}/prelude/types/optional.carbon", directory: "")
  343. // CHECK:STDOUT: !48 = !DISubroutineType(types: !49)
  344. // CHECK:STDOUT: !49 = !{!18, !18}
  345. // CHECK:STDOUT: !50 = !{!51}
  346. // CHECK:STDOUT: !51 = !DILocalVariable(arg: 1, scope: !46, type: !18)
  347. // CHECK:STDOUT: !52 = !DILocation(line: 94, column: 12, scope: !46)
  348. // CHECK:STDOUT: !53 = !DILocation(line: 94, column: 5, scope: !46)
  349. // CHECK:STDOUT: !54 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.90961d7b1ce4f089:OptionalAs.0e326e799dad0c64.Core.8f431b36581f9e63", scope: null, file: !47, line: 68, type: !48, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !55)
  350. // CHECK:STDOUT: !55 = !{!56}
  351. // CHECK:STDOUT: !56 = !DILocalVariable(arg: 1, scope: !54, type: !18)
  352. // CHECK:STDOUT: !57 = !DILocation(line: 69, column: 12, scope: !54)
  353. // CHECK:STDOUT: !58 = !DILocation(line: 69, column: 5, scope: !54)
  354. // CHECK:STDOUT: !59 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.8f431b36581f9e63", scope: null, file: !47, line: 29, type: !48, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !60)
  355. // CHECK:STDOUT: !60 = !{!61}
  356. // CHECK:STDOUT: !61 = !DILocalVariable(arg: 1, scope: !59, type: !18)
  357. // CHECK:STDOUT: !62 = !DILocation(line: 30, column: 12, scope: !59)
  358. // CHECK:STDOUT: !63 = !DILocation(line: 30, column: 5, scope: !59)
  359. // CHECK:STDOUT: !64 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655", scope: null, file: !47, line: 138, type: !48, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !65)
  360. // CHECK:STDOUT: !65 = !{!66}
  361. // CHECK:STDOUT: !66 = !DILocalVariable(arg: 1, scope: !64, type: !18)
  362. // CHECK:STDOUT: !67 = !DILocation(line: 139, column: 14, scope: !64)
  363. // CHECK:STDOUT: !68 = !DILocation(line: 140, column: 5, scope: !64)
  364. // CHECK:STDOUT: !69 = !DILocation(line: 139, column: 18, scope: !64)
  365. // CHECK:STDOUT: !70 = !DILocation(line: 141, column: 5, scope: !64)