pointer.carbon 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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. // --- add_const.carbon
  71. import Cpp inline '''
  72. class C {};
  73. C *make();
  74. void take(const C*);
  75. ''';
  76. fn Convert() {
  77. Cpp.take(Cpp.make());
  78. }
  79. // CHECK:STDOUT: ; ModuleID = 'nonnull.carbon'
  80. // CHECK:STDOUT: source_filename = "nonnull.carbon"
  81. // 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"
  82. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  85. // CHECK:STDOUT: define dso_local void @_Z16TakePtrWithThunkP1Ci.carbon_thunk1(ptr noundef %0) #0 {
  86. // CHECK:STDOUT: entry:
  87. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  88. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !11
  89. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !11
  90. // CHECK:STDOUT: call void @_Z16TakePtrWithThunkP1Ci(ptr noundef %1, i32 noundef 0)
  91. // CHECK:STDOUT: ret void
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: declare void @_Z16TakePtrWithThunkP1Ci(ptr noundef, i32 noundef) #1
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  97. // CHECK:STDOUT: define dso_local noundef ptr @_Z18ReturnPtrWithThunki.carbon_thunk0() #0 {
  98. // CHECK:STDOUT: entry:
  99. // CHECK:STDOUT: %call = call noundef ptr @_Z18ReturnPtrWithThunki(i32 noundef 0)
  100. // CHECK:STDOUT: ret ptr %call
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: declare noundef ptr @_Z18ReturnPtrWithThunki(i32 noundef) #1
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: ; Function Attrs: nounwind
  106. // CHECK:STDOUT: define void @_CPassPtr.Main(ptr %p) #2 !dbg !14 {
  107. // CHECK:STDOUT: entry:
  108. // CHECK:STDOUT: call void @_Z7TakePtrP1C(ptr %p), !dbg !20
  109. // CHECK:STDOUT: ret void, !dbg !21
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: declare void @_Z7TakePtrP1C(ptr noundef) #1
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: ; Function Attrs: nounwind
  115. // CHECK:STDOUT: define ptr @_CReturnPtr.Main() #2 !dbg !22 {
  116. // CHECK:STDOUT: entry:
  117. // CHECK:STDOUT: %ReturnPtr.call = call ptr @_Z9ReturnPtrv(), !dbg !25
  118. // CHECK:STDOUT: ret ptr %ReturnPtr.call, !dbg !26
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: declare noundef ptr @_Z9ReturnPtrv() #1
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: ; Function Attrs: nounwind
  124. // CHECK:STDOUT: define void @_CPassPtrWithThunk.Main(ptr %p) #2 !dbg !27 {
  125. // CHECK:STDOUT: entry:
  126. // CHECK:STDOUT: call void @_Z16TakePtrWithThunkP1Ci.carbon_thunk1(ptr %p), !dbg !30
  127. // CHECK:STDOUT: ret void, !dbg !31
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: ; Function Attrs: nounwind
  131. // CHECK:STDOUT: define ptr @_CReturnPtrWithThunk.Main() #2 !dbg !32 {
  132. // CHECK:STDOUT: entry:
  133. // CHECK:STDOUT: %ReturnPtrWithThunk__carbon_thunk.call = call ptr @_Z18ReturnPtrWithThunki.carbon_thunk0(), !dbg !33
  134. // CHECK:STDOUT: ret ptr %ReturnPtrWithThunk__carbon_thunk.call, !dbg !34
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT:
  137. // 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" }
  138. // 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" }
  139. // CHECK:STDOUT: attributes #2 = { nounwind }
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  142. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  143. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  144. // CHECK:STDOUT:
  145. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  146. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  147. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  148. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  149. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  150. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  151. // CHECK:STDOUT: !6 = !DIFile(filename: "nonnull.carbon", directory: "")
  152. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  153. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  154. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  155. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  156. // CHECK:STDOUT: !11 = !{!12, !12, i64 0}
  157. // CHECK:STDOUT: !12 = !{!"p1 _ZTS1C", !13, i64 0}
  158. // CHECK:STDOUT: !13 = !{!"any pointer", !9, i64 0}
  159. // CHECK:STDOUT: !14 = distinct !DISubprogram(name: "PassPtr", linkageName: "_CPassPtr.Main", scope: null, file: !6, line: 14, type: !15, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !18)
  160. // CHECK:STDOUT: !15 = !DISubroutineType(types: !16)
  161. // CHECK:STDOUT: !16 = !{null, !17}
  162. // CHECK:STDOUT: !17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
  163. // CHECK:STDOUT: !18 = !{!19}
  164. // CHECK:STDOUT: !19 = !DILocalVariable(arg: 1, scope: !14, type: !17)
  165. // CHECK:STDOUT: !20 = !DILocation(line: 15, column: 3, scope: !14)
  166. // CHECK:STDOUT: !21 = !DILocation(line: 14, column: 1, scope: !14)
  167. // CHECK:STDOUT: !22 = distinct !DISubprogram(name: "ReturnPtr", linkageName: "_CReturnPtr.Main", scope: null, file: !6, line: 18, type: !23, spFlags: DISPFlagDefinition, unit: !5)
  168. // CHECK:STDOUT: !23 = !DISubroutineType(types: !24)
  169. // CHECK:STDOUT: !24 = !{!17}
  170. // CHECK:STDOUT: !25 = !DILocation(line: 19, column: 10, scope: !22)
  171. // CHECK:STDOUT: !26 = !DILocation(line: 19, column: 3, scope: !22)
  172. // CHECK:STDOUT: !27 = distinct !DISubprogram(name: "PassPtrWithThunk", linkageName: "_CPassPtrWithThunk.Main", scope: null, file: !6, line: 22, type: !15, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !28)
  173. // CHECK:STDOUT: !28 = !{!29}
  174. // CHECK:STDOUT: !29 = !DILocalVariable(arg: 1, scope: !27, type: !17)
  175. // CHECK:STDOUT: !30 = !DILocation(line: 23, column: 3, scope: !27)
  176. // CHECK:STDOUT: !31 = !DILocation(line: 22, column: 1, scope: !27)
  177. // CHECK:STDOUT: !32 = distinct !DISubprogram(name: "ReturnPtrWithThunk", linkageName: "_CReturnPtrWithThunk.Main", scope: null, file: !6, line: 26, type: !23, spFlags: DISPFlagDefinition, unit: !5)
  178. // CHECK:STDOUT: !33 = !DILocation(line: 27, column: 10, scope: !32)
  179. // CHECK:STDOUT: !34 = !DILocation(line: 27, column: 3, scope: !32)
  180. // CHECK:STDOUT: ; ModuleID = 'nullable.carbon'
  181. // CHECK:STDOUT: source_filename = "nullable.carbon"
  182. // 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"
  183. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  186. // CHECK:STDOUT: define dso_local void @_Z16TakePtrWithThunkP1Ci.carbon_thunk1(ptr noundef %0) #0 {
  187. // CHECK:STDOUT: entry:
  188. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  189. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !11
  190. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !11
  191. // CHECK:STDOUT: call void @_Z16TakePtrWithThunkP1Ci(ptr noundef %1, i32 noundef 0)
  192. // CHECK:STDOUT: ret void
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: declare void @_Z16TakePtrWithThunkP1Ci(ptr noundef, i32 noundef) #1
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  198. // CHECK:STDOUT: define dso_local noundef ptr @_Z18ReturnPtrWithThunki.carbon_thunk0() #0 {
  199. // CHECK:STDOUT: entry:
  200. // CHECK:STDOUT: %call = call noundef ptr @_Z18ReturnPtrWithThunki(i32 noundef 0)
  201. // CHECK:STDOUT: ret ptr %call
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: declare noundef ptr @_Z18ReturnPtrWithThunki(i32 noundef) #1
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: ; Function Attrs: nounwind
  207. // CHECK:STDOUT: define void @_CPassPtr.Main(ptr %_) #2 !dbg !14 {
  208. // CHECK:STDOUT: entry:
  209. // CHECK:STDOUT: ret void, !dbg !20
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: ; Function Attrs: nounwind
  213. // CHECK:STDOUT: define void @_CPassNonnullPtr.Main(ptr %p) #2 !dbg !21 {
  214. // CHECK:STDOUT: entry:
  215. // CHECK:STDOUT: %.loc22_15.2.temp = alloca ptr, align 8, !dbg !24
  216. // CHECK:STDOUT: %U.binding.as_type.as.ImplicitAs.impl.Convert.call = call ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.e76fd6d2be138e4a"(ptr %p), !dbg !24
  217. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc22_15.2.temp), !dbg !24
  218. // CHECK:STDOUT: store ptr %U.binding.as_type.as.ImplicitAs.impl.Convert.call, ptr %.loc22_15.2.temp, align 8, !dbg !24
  219. // CHECK:STDOUT: %.loc22_15.4 = load ptr, ptr %.loc22_15.2.temp, align 8, !dbg !24
  220. // CHECK:STDOUT: call void @_Z7TakePtrP1C(ptr %.loc22_15.4), !dbg !25
  221. // CHECK:STDOUT: call void @"_COp.b17d31fafee11ec0:core.Destroy.Core"(ptr %.loc22_15.2.temp), !dbg !24
  222. // CHECK:STDOUT: ret void, !dbg !26
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: declare void @_Z7TakePtrP1C(ptr noundef) #1
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: ; Function Attrs: nounwind
  228. // CHECK:STDOUT: define weak_odr void @"_COp.52ae03024b07a1ce:core.Destroy.Core"(ptr %self) #2 !dbg !27 {
  229. // CHECK:STDOUT: entry:
  230. // CHECK:STDOUT: ret void, !dbg !30
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: ; Function Attrs: nounwind
  234. // CHECK:STDOUT: define weak_odr void @"_COp.b17d31fafee11ec0:core.Destroy.Core"(ptr %self) #2 !dbg !31 {
  235. // CHECK:STDOUT: entry:
  236. // CHECK:STDOUT: ret void, !dbg !34
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: ; Function Attrs: nounwind
  240. // CHECK:STDOUT: define ptr @_CReturnPtr.Main() #2 !dbg !35 {
  241. // CHECK:STDOUT: entry:
  242. // CHECK:STDOUT: %ReturnPtr.call = call ptr @_Z9ReturnPtrv(), !dbg !38
  243. // CHECK:STDOUT: ret ptr %ReturnPtr.call, !dbg !39
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: declare noundef ptr @_Z9ReturnPtrv() #1
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: ; Function Attrs: nounwind
  249. // CHECK:STDOUT: define void @_CPassPtrWithThunk.Main(ptr %_) #2 !dbg !40 {
  250. // CHECK:STDOUT: entry:
  251. // CHECK:STDOUT: ret void, !dbg !43
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: ; Function Attrs: nounwind
  255. // CHECK:STDOUT: define void @_CPassNonnullPtrWithThunk.Main(ptr %p) #2 !dbg !44 {
  256. // CHECK:STDOUT: entry:
  257. // CHECK:STDOUT: %.loc35_24.2.temp = alloca ptr, align 8, !dbg !47
  258. // CHECK:STDOUT: %U.binding.as_type.as.ImplicitAs.impl.Convert.call = call ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.e76fd6d2be138e4a"(ptr %p), !dbg !47
  259. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc35_24.2.temp), !dbg !47
  260. // CHECK:STDOUT: store ptr %U.binding.as_type.as.ImplicitAs.impl.Convert.call, ptr %.loc35_24.2.temp, align 8, !dbg !47
  261. // CHECK:STDOUT: %.loc35_24.4 = load ptr, ptr %.loc35_24.2.temp, align 8, !dbg !47
  262. // CHECK:STDOUT: call void @_Z16TakePtrWithThunkP1Ci.carbon_thunk1(ptr %.loc35_24.4), !dbg !48
  263. // CHECK:STDOUT: call void @"_COp.b17d31fafee11ec0:core.Destroy.Core"(ptr %.loc35_24.2.temp), !dbg !47
  264. // CHECK:STDOUT: ret void, !dbg !49
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT:
  267. // CHECK:STDOUT: ; Function Attrs: nounwind
  268. // CHECK:STDOUT: define ptr @_CReturnPtrWithThunk.Main() #2 !dbg !50 {
  269. // CHECK:STDOUT: entry:
  270. // CHECK:STDOUT: %ReturnPtrWithThunk__carbon_thunk.call = call ptr @_Z18ReturnPtrWithThunki.carbon_thunk0(), !dbg !51
  271. // CHECK:STDOUT: ret ptr %ReturnPtrWithThunk__carbon_thunk.call, !dbg !52
  272. // CHECK:STDOUT: }
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: ; Function Attrs: nounwind
  275. // CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.e76fd6d2be138e4a"(ptr %self) #2 !dbg !53 {
  276. // CHECK:STDOUT: %1 = call ptr @"_CConvert.90961d7b1ce4f089:OptionalAs.0e326e799dad0c64.Core.8f431b36581f9e63"(ptr %self), !dbg !59
  277. // CHECK:STDOUT: ret ptr %1, !dbg !60
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  281. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #3
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: ; Function Attrs: nounwind
  284. // CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.90961d7b1ce4f089:OptionalAs.0e326e799dad0c64.Core.8f431b36581f9e63"(ptr %self) #2 !dbg !61 {
  285. // CHECK:STDOUT: %1 = call ptr @_CSome.Optional.Core.8f431b36581f9e63(ptr %self), !dbg !64
  286. // CHECK:STDOUT: ret ptr %1, !dbg !65
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: ; Function Attrs: nounwind
  290. // CHECK:STDOUT: define linkonce_odr ptr @_CSome.Optional.Core.8f431b36581f9e63(ptr %value) #2 !dbg !66 {
  291. // CHECK:STDOUT: %1 = call ptr @"_CSome.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655"(ptr %value), !dbg !69
  292. // CHECK:STDOUT: ret ptr %1, !dbg !70
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: ; Function Attrs: nounwind
  296. // CHECK:STDOUT: define linkonce_odr ptr @"_CSome.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655"(ptr %self) #2 !dbg !71 {
  297. // CHECK:STDOUT: %1 = alloca ptr, align 8, !dbg !74
  298. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %1), !dbg !74
  299. // CHECK:STDOUT: store ptr poison, ptr %1, align 8, !dbg !74
  300. // CHECK:STDOUT: store ptr %self, ptr %1, align 8, !dbg !75
  301. // CHECK:STDOUT: %2 = load ptr, ptr %1, align 8, !dbg !76
  302. // CHECK:STDOUT: call void @"_COp.52ae03024b07a1ce:core.Destroy.Core"(ptr %1), !dbg !74
  303. // CHECK:STDOUT: ret ptr %2, !dbg !77
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: ; uselistorder directives
  307. // CHECK:STDOUT: uselistorder ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.e76fd6d2be138e4a", { 1, 0 }
  308. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 0, 2, 1 }
  309. // CHECK:STDOUT:
  310. // 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" }
  311. // 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" }
  312. // CHECK:STDOUT: attributes #2 = { nounwind }
  313. // CHECK:STDOUT: attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  316. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  317. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  318. // CHECK:STDOUT:
  319. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  320. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  321. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  322. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  323. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  324. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  325. // CHECK:STDOUT: !6 = !DIFile(filename: "nullable.carbon", directory: "")
  326. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  327. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  328. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  329. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  330. // CHECK:STDOUT: !11 = !{!12, !12, i64 0}
  331. // CHECK:STDOUT: !12 = !{!"p1 _ZTS1C", !13, i64 0}
  332. // CHECK:STDOUT: !13 = !{!"any pointer", !9, i64 0}
  333. // CHECK:STDOUT: !14 = distinct !DISubprogram(name: "PassPtr", linkageName: "_CPassPtr.Main", scope: null, file: !6, line: 14, type: !15, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !18)
  334. // CHECK:STDOUT: !15 = !DISubroutineType(types: !16)
  335. // CHECK:STDOUT: !16 = !{null, !17}
  336. // CHECK:STDOUT: !17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
  337. // CHECK:STDOUT: !18 = !{!19}
  338. // CHECK:STDOUT: !19 = !DILocalVariable(arg: 1, scope: !14, type: !17)
  339. // CHECK:STDOUT: !20 = !DILocation(line: 14, column: 1, scope: !14)
  340. // CHECK:STDOUT: !21 = distinct !DISubprogram(name: "PassNonnullPtr", linkageName: "_CPassNonnullPtr.Main", scope: null, file: !6, line: 19, type: !15, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !22)
  341. // CHECK:STDOUT: !22 = !{!23}
  342. // CHECK:STDOUT: !23 = !DILocalVariable(arg: 1, scope: !21, type: !17)
  343. // CHECK:STDOUT: !24 = !DILocation(line: 22, column: 15, scope: !21)
  344. // CHECK:STDOUT: !25 = !DILocation(line: 22, column: 3, scope: !21)
  345. // CHECK:STDOUT: !26 = !DILocation(line: 19, column: 1, scope: !21)
  346. // CHECK:STDOUT: !27 = distinct !DISubprogram(name: "Op", linkageName: "_COp.52ae03024b07a1ce:core.Destroy.Core", scope: null, file: !6, line: 22, type: !15, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !28)
  347. // CHECK:STDOUT: !28 = !{!29}
  348. // CHECK:STDOUT: !29 = !DILocalVariable(arg: 1, scope: !27, type: !17)
  349. // CHECK:STDOUT: !30 = !DILocation(line: 22, column: 15, scope: !27)
  350. // CHECK:STDOUT: !31 = distinct !DISubprogram(name: "Op", linkageName: "_COp.b17d31fafee11ec0:core.Destroy.Core", scope: null, file: !6, line: 22, type: !15, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !32)
  351. // CHECK:STDOUT: !32 = !{!33}
  352. // CHECK:STDOUT: !33 = !DILocalVariable(arg: 1, scope: !31, type: !17)
  353. // CHECK:STDOUT: !34 = !DILocation(line: 22, column: 15, scope: !31)
  354. // CHECK:STDOUT: !35 = distinct !DISubprogram(name: "ReturnPtr", linkageName: "_CReturnPtr.Main", scope: null, file: !6, line: 25, type: !36, spFlags: DISPFlagDefinition, unit: !5)
  355. // CHECK:STDOUT: !36 = !DISubroutineType(types: !37)
  356. // CHECK:STDOUT: !37 = !{!17}
  357. // CHECK:STDOUT: !38 = !DILocation(line: 26, column: 10, scope: !35)
  358. // CHECK:STDOUT: !39 = !DILocation(line: 26, column: 3, scope: !35)
  359. // CHECK:STDOUT: !40 = distinct !DISubprogram(name: "PassPtrWithThunk", linkageName: "_CPassPtrWithThunk.Main", scope: null, file: !6, line: 29, type: !15, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !41)
  360. // CHECK:STDOUT: !41 = !{!42}
  361. // CHECK:STDOUT: !42 = !DILocalVariable(arg: 1, scope: !40, type: !17)
  362. // CHECK:STDOUT: !43 = !DILocation(line: 29, column: 1, scope: !40)
  363. // CHECK:STDOUT: !44 = distinct !DISubprogram(name: "PassNonnullPtrWithThunk", linkageName: "_CPassNonnullPtrWithThunk.Main", scope: null, file: !6, line: 34, type: !15, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !45)
  364. // CHECK:STDOUT: !45 = !{!46}
  365. // CHECK:STDOUT: !46 = !DILocalVariable(arg: 1, scope: !44, type: !17)
  366. // CHECK:STDOUT: !47 = !DILocation(line: 35, column: 24, scope: !44)
  367. // CHECK:STDOUT: !48 = !DILocation(line: 35, column: 3, scope: !44)
  368. // CHECK:STDOUT: !49 = !DILocation(line: 34, column: 1, scope: !44)
  369. // CHECK:STDOUT: !50 = distinct !DISubprogram(name: "ReturnPtrWithThunk", linkageName: "_CReturnPtrWithThunk.Main", scope: null, file: !6, line: 38, type: !36, spFlags: DISPFlagDefinition, unit: !5)
  370. // CHECK:STDOUT: !51 = !DILocation(line: 39, column: 10, scope: !50)
  371. // CHECK:STDOUT: !52 = !DILocation(line: 39, column: 3, scope: !50)
  372. // CHECK:STDOUT: !53 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.e76fd6d2be138e4a", scope: null, file: !54, line: 96, type: !55, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !57)
  373. // CHECK:STDOUT: !54 = !DIFile(filename: "{{.*}}/prelude/types/optional.carbon", directory: "")
  374. // CHECK:STDOUT: !55 = !DISubroutineType(types: !56)
  375. // CHECK:STDOUT: !56 = !{!17, !17}
  376. // CHECK:STDOUT: !57 = !{!58}
  377. // CHECK:STDOUT: !58 = !DILocalVariable(arg: 1, scope: !53, type: !17)
  378. // CHECK:STDOUT: !59 = !DILocation(line: 97, column: 12, scope: !53)
  379. // CHECK:STDOUT: !60 = !DILocation(line: 97, column: 5, scope: !53)
  380. // CHECK:STDOUT: !61 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.90961d7b1ce4f089:OptionalAs.0e326e799dad0c64.Core.8f431b36581f9e63", scope: null, file: !54, line: 71, type: !55, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !62)
  381. // CHECK:STDOUT: !62 = !{!63}
  382. // CHECK:STDOUT: !63 = !DILocalVariable(arg: 1, scope: !61, type: !17)
  383. // CHECK:STDOUT: !64 = !DILocation(line: 72, column: 12, scope: !61)
  384. // CHECK:STDOUT: !65 = !DILocation(line: 72, column: 5, scope: !61)
  385. // CHECK:STDOUT: !66 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.8f431b36581f9e63", scope: null, file: !54, line: 30, type: !55, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !67)
  386. // CHECK:STDOUT: !67 = !{!68}
  387. // CHECK:STDOUT: !68 = !DILocalVariable(arg: 1, scope: !66, type: !17)
  388. // CHECK:STDOUT: !69 = !DILocation(line: 31, column: 12, scope: !66)
  389. // CHECK:STDOUT: !70 = !DILocation(line: 31, column: 5, scope: !66)
  390. // CHECK:STDOUT: !71 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655", scope: null, file: !54, line: 150, type: !55, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !72)
  391. // CHECK:STDOUT: !72 = !{!73}
  392. // CHECK:STDOUT: !73 = !DILocalVariable(arg: 1, scope: !71, type: !17)
  393. // CHECK:STDOUT: !74 = !DILocation(line: 151, column: 14, scope: !71)
  394. // CHECK:STDOUT: !75 = !DILocation(line: 153, column: 5, scope: !71)
  395. // CHECK:STDOUT: !76 = !DILocation(line: 151, column: 18, scope: !71)
  396. // CHECK:STDOUT: !77 = !DILocation(line: 154, column: 5, scope: !71)
  397. // CHECK:STDOUT: ; ModuleID = 'add_const.carbon'
  398. // CHECK:STDOUT: source_filename = "add_const.carbon"
  399. // 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"
  400. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: ; Function Attrs: nounwind
  403. // CHECK:STDOUT: define void @_CConvert.Main() #0 !dbg !11 {
  404. // CHECK:STDOUT: entry:
  405. // CHECK:STDOUT: %.loc9_21.1.temp = alloca ptr, align 8, !dbg !14
  406. // CHECK:STDOUT: %.loc9_21.5.temp = alloca ptr, align 8, !dbg !14
  407. // CHECK:STDOUT: %make.call = call ptr @_Z4makev(), !dbg !14
  408. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc9_21.1.temp), !dbg !14
  409. // CHECK:STDOUT: store ptr %make.call, ptr %.loc9_21.1.temp, align 8, !dbg !14
  410. // CHECK:STDOUT: %.loc9_21.3 = load ptr, ptr %.loc9_21.1.temp, align 8, !dbg !14
  411. // CHECK:STDOUT: %U.binding.as_type.as.ImplicitAs.impl.Convert.call = call ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.ace022aad6522dbd"(ptr %.loc9_21.3), !dbg !14
  412. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc9_21.5.temp), !dbg !14
  413. // CHECK:STDOUT: store ptr %U.binding.as_type.as.ImplicitAs.impl.Convert.call, ptr %.loc9_21.5.temp, align 8, !dbg !14
  414. // CHECK:STDOUT: %.loc9_21.7 = load ptr, ptr %.loc9_21.5.temp, align 8, !dbg !14
  415. // CHECK:STDOUT: call void @_Z4takePK1C(ptr %.loc9_21.7), !dbg !15
  416. // CHECK:STDOUT: call void @"_COp.155dfcb6d80d9d93:core.Destroy.Core"(ptr %.loc9_21.5.temp), !dbg !14
  417. // CHECK:STDOUT: call void @"_COp.bc29d15ac9e36600:core.Destroy.Core"(ptr %.loc9_21.1.temp), !dbg !14
  418. // CHECK:STDOUT: ret void, !dbg !16
  419. // CHECK:STDOUT: }
  420. // CHECK:STDOUT:
  421. // CHECK:STDOUT: declare noundef ptr @_Z4makev() #1
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: declare void @_Z4takePK1C(ptr noundef) #1
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: ; Function Attrs: nounwind
  426. // CHECK:STDOUT: define weak_odr void @"_COp.e036a220112b6940:core.Destroy.Core"(ptr %self) #0 !dbg !17 {
  427. // CHECK:STDOUT: entry:
  428. // CHECK:STDOUT: ret void, !dbg !23
  429. // CHECK:STDOUT: }
  430. // CHECK:STDOUT:
  431. // CHECK:STDOUT: ; Function Attrs: nounwind
  432. // CHECK:STDOUT: define weak_odr void @"_COp.155dfcb6d80d9d93:core.Destroy.Core"(ptr %self) #0 !dbg !24 {
  433. // CHECK:STDOUT: entry:
  434. // CHECK:STDOUT: ret void, !dbg !27
  435. // CHECK:STDOUT: }
  436. // CHECK:STDOUT:
  437. // CHECK:STDOUT: ; Function Attrs: nounwind
  438. // CHECK:STDOUT: define weak_odr void @"_COp.52ae03024b07a1ce:core.Destroy.Core"(ptr %self) #0 !dbg !28 {
  439. // CHECK:STDOUT: entry:
  440. // CHECK:STDOUT: ret void, !dbg !31
  441. // CHECK:STDOUT: }
  442. // CHECK:STDOUT:
  443. // CHECK:STDOUT: ; Function Attrs: nounwind
  444. // CHECK:STDOUT: define weak_odr void @"_COp.bc29d15ac9e36600:core.Destroy.Core"(ptr %self) #0 !dbg !32 {
  445. // CHECK:STDOUT: entry:
  446. // CHECK:STDOUT: ret void, !dbg !35
  447. // CHECK:STDOUT: }
  448. // CHECK:STDOUT:
  449. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  450. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #2
  451. // CHECK:STDOUT:
  452. // CHECK:STDOUT: ; Function Attrs: nounwind
  453. // CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.ace022aad6522dbd"(ptr %self) #0 !dbg !36 {
  454. // CHECK:STDOUT: %1 = call ptr @"_CConvert.Optional.6443ea83fd43c001.Core:OptionalAs.c7a50af9bdd61b43.Core.9cffbb0df40531a7"(ptr %self), !dbg !42
  455. // CHECK:STDOUT: ret ptr %1, !dbg !43
  456. // CHECK:STDOUT: }
  457. // CHECK:STDOUT:
  458. // CHECK:STDOUT: ; Function Attrs: nounwind
  459. // CHECK:STDOUT: define linkonce_odr ptr @"_CConvert.Optional.6443ea83fd43c001.Core:OptionalAs.c7a50af9bdd61b43.Core.9cffbb0df40531a7"(ptr %self) #0 !dbg !44 {
  460. // CHECK:STDOUT: %temp = alloca ptr, align 8, !dbg !47
  461. // CHECK:STDOUT: %temp1 = alloca ptr, align 8, !dbg !47
  462. // CHECK:STDOUT: %1 = call i1 @_CHasValue.Optional.Core.e4de4a7eec6ed951(ptr %self), !dbg !48
  463. // CHECK:STDOUT: br i1 %1, label %2, label %7, !dbg !49
  464. // CHECK:STDOUT:
  465. // CHECK:STDOUT: 2: ; preds = %0
  466. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %temp), !dbg !47
  467. // CHECK:STDOUT: %3 = call ptr @_CGet.Optional.Core.e4de4a7eec6ed951(ptr %self), !dbg !47
  468. // CHECK:STDOUT: store ptr %3, ptr %temp, align 8, !dbg !47
  469. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %temp1), !dbg !47
  470. // CHECK:STDOUT: %4 = load ptr, ptr %temp, align 8, !dbg !47
  471. // CHECK:STDOUT: store ptr %4, ptr %temp1, align 8, !dbg !47
  472. // CHECK:STDOUT: %5 = load ptr, ptr %temp1, align 8, !dbg !47
  473. // CHECK:STDOUT: %6 = call ptr @_CSome.Optional.Core.6c9458c8cde1135d(ptr %5), !dbg !50
  474. // CHECK:STDOUT: ret ptr %6, !dbg !51
  475. // CHECK:STDOUT:
  476. // CHECK:STDOUT: 7: ; preds = %0
  477. // CHECK:STDOUT: %8 = call ptr @_CNone.Optional.Core.6c9458c8cde1135d(), !dbg !52
  478. // CHECK:STDOUT: ret ptr %8, !dbg !53
  479. // CHECK:STDOUT: }
  480. // CHECK:STDOUT:
  481. // CHECK:STDOUT: ; Function Attrs: nounwind
  482. // CHECK:STDOUT: define linkonce_odr i1 @_CHasValue.Optional.Core.e4de4a7eec6ed951(ptr %self) #0 !dbg !54 {
  483. // CHECK:STDOUT: %1 = call i1 @"_CHas.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655"(ptr %self), !dbg !57
  484. // CHECK:STDOUT: ret i1 %1, !dbg !58
  485. // CHECK:STDOUT: }
  486. // CHECK:STDOUT:
  487. // CHECK:STDOUT: ; Function Attrs: nounwind
  488. // CHECK:STDOUT: define linkonce_odr ptr @_CGet.Optional.Core.e4de4a7eec6ed951(ptr %self) #0 !dbg !59 {
  489. // CHECK:STDOUT: %1 = call ptr @"_CGet.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655"(ptr %self), !dbg !62
  490. // CHECK:STDOUT: ret ptr %1, !dbg !63
  491. // CHECK:STDOUT: }
  492. // CHECK:STDOUT:
  493. // CHECK:STDOUT: ; Function Attrs: nounwind
  494. // CHECK:STDOUT: define linkonce_odr ptr @_CSome.Optional.Core.6c9458c8cde1135d(ptr %value) #0 !dbg !64 {
  495. // CHECK:STDOUT: %1 = call ptr @"_CSome.e8f8f92d3d08d149:OptionalStorage.Core.27e79123988f1998"(ptr %value), !dbg !67
  496. // CHECK:STDOUT: ret ptr %1, !dbg !68
  497. // CHECK:STDOUT: }
  498. // CHECK:STDOUT:
  499. // CHECK:STDOUT: ; Function Attrs: nounwind
  500. // CHECK:STDOUT: define linkonce_odr ptr @_CNone.Optional.Core.6c9458c8cde1135d() #0 !dbg !69 {
  501. // CHECK:STDOUT: ret ptr null, !dbg !72
  502. // CHECK:STDOUT: }
  503. // CHECK:STDOUT:
  504. // CHECK:STDOUT: ; Function Attrs: nounwind
  505. // CHECK:STDOUT: define linkonce_odr i1 @"_CHas.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655"(ptr %value) #0 !dbg !73 {
  506. // CHECK:STDOUT: %1 = icmp eq ptr %value, null, !dbg !76
  507. // CHECK:STDOUT: %2 = xor i1 %1, true, !dbg !77
  508. // CHECK:STDOUT: ret i1 %2, !dbg !78
  509. // CHECK:STDOUT: }
  510. // CHECK:STDOUT:
  511. // CHECK:STDOUT: ; Function Attrs: nounwind
  512. // CHECK:STDOUT: define linkonce_odr ptr @"_CGet.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655"(ptr %value) #0 !dbg !79 {
  513. // CHECK:STDOUT: ret ptr %value, !dbg !82
  514. // CHECK:STDOUT: }
  515. // CHECK:STDOUT:
  516. // CHECK:STDOUT: ; Function Attrs: nounwind
  517. // CHECK:STDOUT: define linkonce_odr ptr @"_CSome.e8f8f92d3d08d149:OptionalStorage.Core.27e79123988f1998"(ptr %self) #0 !dbg !83 {
  518. // CHECK:STDOUT: %1 = alloca ptr, align 8, !dbg !86
  519. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %1), !dbg !86
  520. // CHECK:STDOUT: store ptr poison, ptr %1, align 8, !dbg !86
  521. // CHECK:STDOUT: store ptr %self, ptr %1, align 8, !dbg !87
  522. // CHECK:STDOUT: %2 = load ptr, ptr %1, align 8, !dbg !88
  523. // CHECK:STDOUT: call void @"_COp.e036a220112b6940:core.Destroy.Core"(ptr %1), !dbg !86
  524. // CHECK:STDOUT: ret ptr %2, !dbg !89
  525. // CHECK:STDOUT: }
  526. // CHECK:STDOUT:
  527. // CHECK:STDOUT: ; uselistorder directives
  528. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 0, 1, 2, 4, 3 }
  529. // CHECK:STDOUT:
  530. // CHECK:STDOUT: attributes #0 = { nounwind }
  531. // 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" }
  532. // CHECK:STDOUT: attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  533. // CHECK:STDOUT:
  534. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  535. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  536. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  537. // CHECK:STDOUT:
  538. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  539. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  540. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  541. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  542. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  543. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  544. // CHECK:STDOUT: !6 = !DIFile(filename: "add_const.carbon", directory: "")
  545. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  546. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  547. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  548. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  549. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Main", scope: null, file: !6, line: 8, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  550. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  551. // CHECK:STDOUT: !13 = !{null}
  552. // CHECK:STDOUT: !14 = !DILocation(line: 9, column: 12, scope: !11)
  553. // CHECK:STDOUT: !15 = !DILocation(line: 9, column: 3, scope: !11)
  554. // CHECK:STDOUT: !16 = !DILocation(line: 8, column: 1, scope: !11)
  555. // CHECK:STDOUT: !17 = distinct !DISubprogram(name: "Op", linkageName: "_COp.e036a220112b6940:core.Destroy.Core", scope: null, file: !6, line: 9, type: !18, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !21)
  556. // CHECK:STDOUT: !18 = !DISubroutineType(types: !19)
  557. // CHECK:STDOUT: !19 = !{null, !20}
  558. // CHECK:STDOUT: !20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
  559. // CHECK:STDOUT: !21 = !{!22}
  560. // CHECK:STDOUT: !22 = !DILocalVariable(arg: 1, scope: !17, type: !20)
  561. // CHECK:STDOUT: !23 = !DILocation(line: 9, column: 12, scope: !17)
  562. // CHECK:STDOUT: !24 = distinct !DISubprogram(name: "Op", linkageName: "_COp.155dfcb6d80d9d93:core.Destroy.Core", scope: null, file: !6, line: 9, type: !18, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !25)
  563. // CHECK:STDOUT: !25 = !{!26}
  564. // CHECK:STDOUT: !26 = !DILocalVariable(arg: 1, scope: !24, type: !20)
  565. // CHECK:STDOUT: !27 = !DILocation(line: 9, column: 12, scope: !24)
  566. // CHECK:STDOUT: !28 = distinct !DISubprogram(name: "Op", linkageName: "_COp.52ae03024b07a1ce:core.Destroy.Core", scope: null, file: !6, line: 9, type: !18, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !29)
  567. // CHECK:STDOUT: !29 = !{!30}
  568. // CHECK:STDOUT: !30 = !DILocalVariable(arg: 1, scope: !28, type: !20)
  569. // CHECK:STDOUT: !31 = !DILocation(line: 9, column: 12, scope: !28)
  570. // CHECK:STDOUT: !32 = distinct !DISubprogram(name: "Op", linkageName: "_COp.bc29d15ac9e36600:core.Destroy.Core", scope: null, file: !6, line: 9, type: !18, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !33)
  571. // CHECK:STDOUT: !33 = !{!34}
  572. // CHECK:STDOUT: !34 = !DILocalVariable(arg: 1, scope: !32, type: !20)
  573. // CHECK:STDOUT: !35 = !DILocation(line: 9, column: 12, scope: !32)
  574. // CHECK:STDOUT: !36 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.e5cf8fcbb4feaae2:ImplicitAs.0f95c9e18c91e00a.Core.ace022aad6522dbd", scope: null, file: !37, line: 96, type: !38, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !40)
  575. // CHECK:STDOUT: !37 = !DIFile(filename: "{{.*}}/prelude/types/optional.carbon", directory: "")
  576. // CHECK:STDOUT: !38 = !DISubroutineType(types: !39)
  577. // CHECK:STDOUT: !39 = !{!20, !20}
  578. // CHECK:STDOUT: !40 = !{!41}
  579. // CHECK:STDOUT: !41 = !DILocalVariable(arg: 1, scope: !36, type: !20)
  580. // CHECK:STDOUT: !42 = !DILocation(line: 97, column: 12, scope: !36)
  581. // CHECK:STDOUT: !43 = !DILocation(line: 97, column: 5, scope: !36)
  582. // CHECK:STDOUT: !44 = distinct !DISubprogram(name: "Convert", linkageName: "_CConvert.Optional.6443ea83fd43c001.Core:OptionalAs.c7a50af9bdd61b43.Core.9cffbb0df40531a7", scope: null, file: !37, line: 86, type: !38, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !45)
  583. // CHECK:STDOUT: !45 = !{!46}
  584. // CHECK:STDOUT: !46 = !DILocalVariable(arg: 1, scope: !44, type: !20)
  585. // CHECK:STDOUT: !47 = !DILocation(line: 88, column: 31, scope: !44)
  586. // CHECK:STDOUT: !48 = !DILocation(line: 87, column: 9, scope: !44)
  587. // CHECK:STDOUT: !49 = !DILocation(line: 87, column: 8, scope: !44)
  588. // CHECK:STDOUT: !50 = !DILocation(line: 88, column: 14, scope: !44)
  589. // CHECK:STDOUT: !51 = !DILocation(line: 88, column: 7, scope: !44)
  590. // CHECK:STDOUT: !52 = !DILocation(line: 90, column: 12, scope: !44)
  591. // CHECK:STDOUT: !53 = !DILocation(line: 90, column: 5, scope: !44)
  592. // CHECK:STDOUT: !54 = distinct !DISubprogram(name: "HasValue", linkageName: "_CHasValue.Optional.Core.e4de4a7eec6ed951", scope: null, file: !37, line: 33, type: !38, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !55)
  593. // CHECK:STDOUT: !55 = !{!56}
  594. // CHECK:STDOUT: !56 = !DILocalVariable(arg: 1, scope: !54, type: !20)
  595. // CHECK:STDOUT: !57 = !DILocation(line: 34, column: 12, scope: !54)
  596. // CHECK:STDOUT: !58 = !DILocation(line: 34, column: 5, scope: !54)
  597. // CHECK:STDOUT: !59 = distinct !DISubprogram(name: "Get", linkageName: "_CGet.Optional.Core.e4de4a7eec6ed951", scope: null, file: !37, line: 36, type: !38, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !60)
  598. // CHECK:STDOUT: !60 = !{!61}
  599. // CHECK:STDOUT: !61 = !DILocalVariable(arg: 1, scope: !59, type: !20)
  600. // CHECK:STDOUT: !62 = !DILocation(line: 37, column: 12, scope: !59)
  601. // CHECK:STDOUT: !63 = !DILocation(line: 37, column: 5, scope: !59)
  602. // CHECK:STDOUT: !64 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.Optional.Core.6c9458c8cde1135d", scope: null, file: !37, line: 30, type: !38, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !65)
  603. // CHECK:STDOUT: !65 = !{!66}
  604. // CHECK:STDOUT: !66 = !DILocalVariable(arg: 1, scope: !64, type: !20)
  605. // CHECK:STDOUT: !67 = !DILocation(line: 31, column: 12, scope: !64)
  606. // CHECK:STDOUT: !68 = !DILocation(line: 31, column: 5, scope: !64)
  607. // CHECK:STDOUT: !69 = distinct !DISubprogram(name: "None", linkageName: "_CNone.Optional.Core.6c9458c8cde1135d", scope: null, file: !37, line: 27, type: !70, spFlags: DISPFlagDefinition, unit: !5)
  608. // CHECK:STDOUT: !70 = !DISubroutineType(types: !71)
  609. // CHECK:STDOUT: !71 = !{!20}
  610. // CHECK:STDOUT: !72 = !DILocation(line: 28, column: 5, scope: !69)
  611. // CHECK:STDOUT: !73 = distinct !DISubprogram(name: "Has", linkageName: "_CHas.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655", scope: null, file: !37, line: 156, type: !38, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !74)
  612. // CHECK:STDOUT: !74 = !{!75}
  613. // CHECK:STDOUT: !75 = !DILocalVariable(arg: 1, scope: !73, type: !20)
  614. // CHECK:STDOUT: !76 = !DILocation(line: 157, column: 16, scope: !73)
  615. // CHECK:STDOUT: !77 = !DILocation(line: 157, column: 12, scope: !73)
  616. // CHECK:STDOUT: !78 = !DILocation(line: 157, column: 5, scope: !73)
  617. // CHECK:STDOUT: !79 = distinct !DISubprogram(name: "Get", linkageName: "_CGet.e8f8f92d3d08d149:OptionalStorage.Core.f53db17714b9f655", scope: null, file: !37, line: 159, type: !38, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !80)
  618. // CHECK:STDOUT: !80 = !{!81}
  619. // CHECK:STDOUT: !81 = !DILocalVariable(arg: 1, scope: !79, type: !20)
  620. // CHECK:STDOUT: !82 = !DILocation(line: 160, column: 5, scope: !79)
  621. // CHECK:STDOUT: !83 = distinct !DISubprogram(name: "Some", linkageName: "_CSome.e8f8f92d3d08d149:OptionalStorage.Core.27e79123988f1998", scope: null, file: !37, line: 150, type: !38, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !84)
  622. // CHECK:STDOUT: !84 = !{!85}
  623. // CHECK:STDOUT: !85 = !DILocalVariable(arg: 1, scope: !83, type: !20)
  624. // CHECK:STDOUT: !86 = !DILocation(line: 151, column: 14, scope: !83)
  625. // CHECK:STDOUT: !87 = !DILocation(line: 153, column: 5, scope: !83)
  626. // CHECK:STDOUT: !88 = !DILocation(line: 151, column: 18, scope: !83)
  627. // CHECK:STDOUT: !89 = !DILocation(line: 154, column: 5, scope: !83)