reference.carbon 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  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/int.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/reference.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/interop/cpp/reference.carbon
  12. // ============================================================================
  13. // Reference params
  14. // ============================================================================
  15. // --- pass_references.carbon
  16. library "[[@TEST_NAME]]";
  17. import Cpp inline '''
  18. class C {};
  19. auto TakeCRef(C&) -> void;
  20. auto TakeCRRef(C&&) -> void;
  21. auto TakeConstCRef(const C&) -> void;
  22. auto TakeIntRef(int&) -> void;
  23. auto TakeIntRRef(int&&) -> void;
  24. auto TakeConstIntRef(const int&) -> void;
  25. ''';
  26. fn PassRefs() {
  27. var c: Cpp.C;
  28. Cpp.TakeCRef(ref c);
  29. Cpp.TakeCRRef({} as Cpp.C);
  30. Cpp.TakeConstCRef(c);
  31. var n: i32;
  32. Cpp.TakeIntRef(ref n);
  33. Cpp.TakeIntRRef(42 as i32);
  34. Cpp.TakeConstIntRef(n);
  35. }
  36. // --- pass_references_via_thunk.carbon
  37. library "[[@TEST_NAME]]";
  38. import Cpp inline '''
  39. class C {};
  40. class ForceThunk {};
  41. auto TakeCRef(C&, ForceThunk = {}) -> void;
  42. auto TakeCRRef(const C&, ForceThunk = {}) -> void;
  43. auto TakeConstCRef(const C&, ForceThunk = {}) -> void;
  44. auto TakeIntRef(int&, ForceThunk = {}) -> void;
  45. auto TakeIntRRef(int&&, ForceThunk = {}) -> void;
  46. auto TakeConstIntRef(const int&, ForceThunk = {}) -> void;
  47. ''';
  48. fn PassRefs() {
  49. var c: Cpp.C;
  50. Cpp.TakeCRef(ref c);
  51. Cpp.TakeCRRef({} as Cpp.C);
  52. Cpp.TakeConstCRef(c);
  53. var n: i32;
  54. Cpp.TakeIntRef(ref n);
  55. Cpp.TakeIntRRef(42 as i32);
  56. Cpp.TakeConstIntRef(n);
  57. }
  58. // ============================================================================
  59. // Reference return values
  60. // ============================================================================
  61. // --- return_references.carbon
  62. library "[[@TEST_NAME]]";
  63. import Cpp inline '''
  64. class C {};
  65. auto ReturnCRef() -> C&;
  66. auto ReturnCRRef() -> C&&;
  67. auto ReturnConstCRef() -> const C&;
  68. auto ReturnIntRef() -> int&;
  69. auto ReturnIntRRef() -> int&&;
  70. auto ReturnConstIntRef() -> const int&;
  71. ''';
  72. fn GetRefs() {
  73. let ref _: Cpp.C = Cpp.ReturnCRef();
  74. let ref _: Cpp.C = Cpp.ReturnCRRef();
  75. let ref _: const Cpp.C = Cpp.ReturnConstCRef();
  76. let ref _: i32 = Cpp.ReturnIntRef();
  77. let ref _: i32 = Cpp.ReturnIntRRef();
  78. let ref _: const i32 = Cpp.ReturnConstIntRef();
  79. }
  80. // --- return_references_via_thunk.carbon
  81. library "[[@TEST_NAME]]";
  82. import Cpp inline '''
  83. class C {};
  84. class ForceThunk {};
  85. auto ReturnCRef(ForceThunk = {}) -> C&;
  86. auto ReturnCRRef(ForceThunk = {}) -> C&&;
  87. auto ReturnConstCRef(ForceThunk = {}) -> const C&;
  88. auto ReturnIntRef(ForceThunk = {}) -> int&;
  89. auto ReturnIntRRef(ForceThunk = {}) -> int&&;
  90. auto ReturnConstIntRef(ForceThunk = {}) -> const int&;
  91. ''';
  92. fn GetRefs() {
  93. let ref _: Cpp.C = Cpp.ReturnCRef();
  94. let ref _: Cpp.C = Cpp.ReturnCRRef();
  95. let ref _: const Cpp.C = Cpp.ReturnConstCRef();
  96. let ref _: i32 = Cpp.ReturnIntRef();
  97. let ref _: i32 = Cpp.ReturnIntRRef();
  98. let ref _: const i32 = Cpp.ReturnConstIntRef();
  99. }
  100. // CHECK:STDOUT: ; ModuleID = 'pass_references.carbon'
  101. // CHECK:STDOUT: source_filename = "pass_references.carbon"
  102. // 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"
  103. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: @C.val.loc19_20 = internal constant {} zeroinitializer
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: ; Function Attrs: nounwind
  108. // CHECK:STDOUT: define void @_CPassRefs.Main() #0 !dbg !11 {
  109. // CHECK:STDOUT: entry:
  110. // CHECK:STDOUT: %c.var = alloca {}, align 8, !dbg !14
  111. // CHECK:STDOUT: %_.var.1 = alloca {}, align 8, !dbg !15
  112. // CHECK:STDOUT: %n.var = alloca i32, align 4, !dbg !16
  113. // CHECK:STDOUT: %_.var.2 = alloca i32, align 4, !dbg !17
  114. // CHECK:STDOUT: %.loc25_23.2.temp = alloca i32, align 4, !dbg !18
  115. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c.var), !dbg !14
  116. // CHECK:STDOUT: call void @"_COp.d288d62be0e5d791:DefaultOrUnformed.Core.93349b0fe912a29b"(ptr %c.var), !dbg !14
  117. // CHECK:STDOUT: call void @_Z8TakeCRefR1C(ptr %c.var), !dbg !19
  118. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %_.var.1), !dbg !15
  119. // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %_.var.1, ptr align 1 @C.val.loc19_20, i64 0, i1 false), !dbg !15
  120. // CHECK:STDOUT: call void @_Z9TakeCRRefO1C.carbon_thunk(ptr %_.var.1), !dbg !20
  121. // CHECK:STDOUT: call void @_Z13TakeConstCRefRK1C.carbon_thunk(ptr %c.var), !dbg !21
  122. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n.var), !dbg !16
  123. // CHECK:STDOUT: store i32 poison, ptr %n.var, align 4, !dbg !16
  124. // CHECK:STDOUT: call void @_Z10TakeIntRefRi(ptr %n.var), !dbg !22
  125. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %_.var.2), !dbg !17
  126. // CHECK:STDOUT: store i32 42, ptr %_.var.2, align 4, !dbg !17
  127. // CHECK:STDOUT: call void @_Z11TakeIntRRefOi.carbon_thunk(ptr %_.var.2), !dbg !23
  128. // CHECK:STDOUT: %.loc25_23.1 = load i32, ptr %n.var, align 4, !dbg !18
  129. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc25_23.2.temp), !dbg !18
  130. // CHECK:STDOUT: store i32 %.loc25_23.1, ptr %.loc25_23.2.temp, align 4, !dbg !18
  131. // CHECK:STDOUT: call void @_Z15TakeConstIntRefRKi.carbon_thunk(ptr %.loc25_23.2.temp), !dbg !24
  132. // CHECK:STDOUT: call void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %.loc25_23.2.temp), !dbg !18
  133. // CHECK:STDOUT: call void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %_.var.2), !dbg !17
  134. // CHECK:STDOUT: call void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %n.var), !dbg !16
  135. // CHECK:STDOUT: ret void, !dbg !25
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
  139. // CHECK:STDOUT: define internal void @_ZN1CC1Ev.carbon_thunk(ptr noundef %return) #1 {
  140. // CHECK:STDOUT: entry:
  141. // CHECK:STDOUT: %return.addr = alloca ptr, align 8
  142. // CHECK:STDOUT: store ptr %return, ptr %return.addr, align 8, !tbaa !26
  143. // CHECK:STDOUT: %0 = load ptr, ptr %return.addr, align 8, !tbaa !26
  144. // CHECK:STDOUT: ret void
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT:
  147. // CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
  148. // CHECK:STDOUT: define void @"_COp:thunk.C.Cpp"(ptr sret({}) %return) #2 !dbg !29 {
  149. // CHECK:STDOUT: entry:
  150. // CHECK:STDOUT: call void @_ZN1CC1Ev.carbon_thunk(ptr %return), !dbg !33
  151. // CHECK:STDOUT: ret void, !dbg !33
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: declare void @_Z8TakeCRefR1C(ptr noundef nonnull align 1 dereferenceable(1)) #3
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  157. // CHECK:STDOUT: define internal void @_Z9TakeCRRefO1C.carbon_thunk(ptr noundef %0) #4 {
  158. // CHECK:STDOUT: entry:
  159. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  160. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !26
  161. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !26
  162. // CHECK:STDOUT: call void @_Z9TakeCRRefO1C(ptr noundef nonnull align 1 dereferenceable(1) %1)
  163. // CHECK:STDOUT: ret void
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  167. // CHECK:STDOUT: define internal void @_Z13TakeConstCRefRK1C.carbon_thunk(ptr noundef %0) #4 {
  168. // CHECK:STDOUT: entry:
  169. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  170. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !26
  171. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !26
  172. // CHECK:STDOUT: call void @_Z13TakeConstCRefRK1C(ptr noundef nonnull align 1 dereferenceable(1) %1)
  173. // CHECK:STDOUT: ret void
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: declare void @_Z10TakeIntRefRi(ptr noundef nonnull align 4 dereferenceable(4)) #3
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  179. // CHECK:STDOUT: define internal void @_Z11TakeIntRRefOi.carbon_thunk(ptr noundef %0) #4 {
  180. // CHECK:STDOUT: entry:
  181. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  182. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !34
  183. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !34
  184. // CHECK:STDOUT: call void @_Z11TakeIntRRefOi(ptr noundef nonnull align 4 dereferenceable(4) %1)
  185. // CHECK:STDOUT: ret void
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  189. // CHECK:STDOUT: define internal void @_Z15TakeConstIntRefRKi.carbon_thunk(ptr noundef %0) #4 {
  190. // CHECK:STDOUT: entry:
  191. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  192. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !34
  193. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !34
  194. // CHECK:STDOUT: call void @_Z15TakeConstIntRefRKi(ptr noundef nonnull align 4 dereferenceable(4) %1)
  195. // CHECK:STDOUT: ret void
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: ; Function Attrs: nounwind
  199. // CHECK:STDOUT: define weak_odr void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %self) #0 !dbg !36 {
  200. // CHECK:STDOUT: entry:
  201. // CHECK:STDOUT: ret void, !dbg !42
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  205. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #5
  206. // CHECK:STDOUT:
  207. // CHECK:STDOUT: ; Function Attrs: nounwind
  208. // CHECK:STDOUT: define linkonce_odr void @"_COp.d288d62be0e5d791:DefaultOrUnformed.Core.93349b0fe912a29b"(ptr sret({}) %return) #0 !dbg !43 {
  209. // CHECK:STDOUT: call void @"_COp:thunk.C.Cpp"(ptr %return), !dbg !45
  210. // CHECK:STDOUT: ret void, !dbg !46
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
  214. // CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) #6
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: declare void @_Z9TakeCRRefO1C(ptr noundef nonnull align 1 dereferenceable(1)) #3
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: declare void @_Z13TakeConstCRefRK1C(ptr noundef nonnull align 1 dereferenceable(1)) #3
  219. // CHECK:STDOUT:
  220. // CHECK:STDOUT: declare void @_Z11TakeIntRRefOi(ptr noundef nonnull align 4 dereferenceable(4)) #3
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: declare void @_Z15TakeConstIntRefRKi(ptr noundef nonnull align 4 dereferenceable(4)) #3
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: ; uselistorder directives
  225. // CHECK:STDOUT: uselistorder ptr @"_COp.7e389eab4a7e5487:core.Destroy.Core", { 2, 1, 0 }
  226. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 4, 3, 2, 1, 0 }
  227. // CHECK:STDOUT:
  228. // CHECK:STDOUT: attributes #0 = { nounwind }
  229. // CHECK:STDOUT: attributes #1 = { alwaysinline mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  230. // CHECK:STDOUT: attributes #2 = { alwaysinline nounwind }
  231. // CHECK:STDOUT: attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  232. // CHECK:STDOUT: attributes #4 = { 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" }
  233. // CHECK:STDOUT: attributes #5 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  234. // CHECK:STDOUT: attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  237. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  238. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  241. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  242. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  243. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  244. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  245. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  246. // CHECK:STDOUT: !6 = !DIFile(filename: "pass_references.carbon", directory: "")
  247. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  248. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  249. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  250. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  251. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "PassRefs", linkageName: "_CPassRefs.Main", scope: null, file: !6, line: 16, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  252. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  253. // CHECK:STDOUT: !13 = !{null}
  254. // CHECK:STDOUT: !14 = !DILocation(line: 17, column: 3, scope: !11)
  255. // CHECK:STDOUT: !15 = !DILocation(line: 8, column: 19, scope: !11)
  256. // CHECK:STDOUT: !16 = !DILocation(line: 22, column: 3, scope: !11)
  257. // CHECK:STDOUT: !17 = !DILocation(line: 12, column: 23, scope: !11)
  258. // CHECK:STDOUT: !18 = !DILocation(line: 25, column: 23, scope: !11)
  259. // CHECK:STDOUT: !19 = !DILocation(line: 18, column: 3, scope: !11)
  260. // CHECK:STDOUT: !20 = !DILocation(line: 19, column: 3, scope: !11)
  261. // CHECK:STDOUT: !21 = !DILocation(line: 20, column: 3, scope: !11)
  262. // CHECK:STDOUT: !22 = !DILocation(line: 23, column: 3, scope: !11)
  263. // CHECK:STDOUT: !23 = !DILocation(line: 24, column: 3, scope: !11)
  264. // CHECK:STDOUT: !24 = !DILocation(line: 25, column: 3, scope: !11)
  265. // CHECK:STDOUT: !25 = !DILocation(line: 16, column: 1, scope: !11)
  266. // CHECK:STDOUT: !26 = !{!27, !27, i64 0}
  267. // CHECK:STDOUT: !27 = !{!"p1 _ZTS1C", !28, i64 0}
  268. // CHECK:STDOUT: !28 = !{!"any pointer", !9, i64 0}
  269. // CHECK:STDOUT: !29 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk.C.Cpp", scope: null, file: !6, line: 5, type: !30, spFlags: DISPFlagDefinition, unit: !5)
  270. // CHECK:STDOUT: !30 = !DISubroutineType(types: !31)
  271. // CHECK:STDOUT: !31 = !{!32}
  272. // CHECK:STDOUT: !32 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
  273. // CHECK:STDOUT: !33 = !DILocation(line: 5, column: 7, scope: !29)
  274. // CHECK:STDOUT: !34 = !{!35, !35, i64 0}
  275. // CHECK:STDOUT: !35 = !{!"p1 int", !28, i64 0}
  276. // CHECK:STDOUT: !36 = distinct !DISubprogram(name: "Op", linkageName: "_COp.7e389eab4a7e5487:core.Destroy.Core", scope: null, file: !6, line: 25, type: !37, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !40)
  277. // CHECK:STDOUT: !37 = !DISubroutineType(types: !38)
  278. // CHECK:STDOUT: !38 = !{null, !39}
  279. // CHECK:STDOUT: !39 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  280. // CHECK:STDOUT: !40 = !{!41}
  281. // CHECK:STDOUT: !41 = !DILocalVariable(arg: 1, scope: !36, type: !39)
  282. // CHECK:STDOUT: !42 = !DILocation(line: 25, column: 23, scope: !36)
  283. // CHECK:STDOUT: !43 = distinct !DISubprogram(name: "Op", linkageName: "_COp.d288d62be0e5d791:DefaultOrUnformed.Core.93349b0fe912a29b", scope: null, file: !44, line: 9, type: !30, spFlags: DISPFlagDefinition, unit: !5)
  284. // CHECK:STDOUT: !44 = !DIFile(filename: "min_prelude/parts/default.carbon", directory: "")
  285. // CHECK:STDOUT: !45 = !DILocation(line: 9, column: 28, scope: !43)
  286. // CHECK:STDOUT: !46 = !DILocation(line: 9, column: 21, scope: !43)
  287. // CHECK:STDOUT: ; ModuleID = 'pass_references_via_thunk.carbon'
  288. // CHECK:STDOUT: source_filename = "pass_references_via_thunk.carbon"
  289. // 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"
  290. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: %class.ForceThunk = type { i8 }
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: @C.val = internal constant {} zeroinitializer
  295. // CHECK:STDOUT: @C.val.loc20_20.3 = internal constant {} zeroinitializer
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: ; Function Attrs: nounwind
  298. // CHECK:STDOUT: define void @_CPassRefs.Main() #0 !dbg !11 {
  299. // CHECK:STDOUT: entry:
  300. // CHECK:STDOUT: %c.var = alloca {}, align 8, !dbg !14
  301. // CHECK:STDOUT: %.loc20_18.2.temp = alloca {}, align 8, !dbg !15
  302. // CHECK:STDOUT: %n.var = alloca i32, align 4, !dbg !16
  303. // CHECK:STDOUT: %_.var = alloca i32, align 4, !dbg !17
  304. // CHECK:STDOUT: %.loc26_23.2.temp = alloca i32, align 4, !dbg !18
  305. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c.var), !dbg !14
  306. // CHECK:STDOUT: call void @"_COp.d288d62be0e5d791:DefaultOrUnformed.Core.93349b0fe912a29b"(ptr %c.var), !dbg !14
  307. // CHECK:STDOUT: call void @_Z8TakeCRefR1C10ForceThunk.carbon_thunk1(ptr %c.var), !dbg !19
  308. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc20_18.2.temp), !dbg !15
  309. // CHECK:STDOUT: call void @_Z9TakeCRRefRK1C10ForceThunk.carbon_thunk1(ptr @C.val.loc20_20.3), !dbg !20
  310. // CHECK:STDOUT: call void @_Z13TakeConstCRefRK1C10ForceThunk.carbon_thunk1(ptr %c.var), !dbg !21
  311. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n.var), !dbg !16
  312. // CHECK:STDOUT: store i32 poison, ptr %n.var, align 4, !dbg !16
  313. // CHECK:STDOUT: call void @_Z10TakeIntRefRi10ForceThunk.carbon_thunk1(ptr %n.var), !dbg !22
  314. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %_.var), !dbg !17
  315. // CHECK:STDOUT: store i32 42, ptr %_.var, align 4, !dbg !17
  316. // CHECK:STDOUT: call void @_Z11TakeIntRRefOi10ForceThunk.carbon_thunk1(ptr %_.var), !dbg !23
  317. // CHECK:STDOUT: %.loc26_23.1 = load i32, ptr %n.var, align 4, !dbg !18
  318. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc26_23.2.temp), !dbg !18
  319. // CHECK:STDOUT: store i32 %.loc26_23.1, ptr %.loc26_23.2.temp, align 4, !dbg !18
  320. // CHECK:STDOUT: call void @_Z15TakeConstIntRefRKi10ForceThunk.carbon_thunk1(ptr %.loc26_23.2.temp), !dbg !24
  321. // CHECK:STDOUT: call void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %.loc26_23.2.temp), !dbg !18
  322. // CHECK:STDOUT: call void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %_.var), !dbg !17
  323. // CHECK:STDOUT: call void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %n.var), !dbg !16
  324. // CHECK:STDOUT: ret void, !dbg !25
  325. // CHECK:STDOUT: }
  326. // CHECK:STDOUT:
  327. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress nounwind uwtable
  328. // CHECK:STDOUT: define internal void @_ZN1CC1Ev.carbon_thunk(ptr noundef %return) #1 {
  329. // CHECK:STDOUT: entry:
  330. // CHECK:STDOUT: %return.addr = alloca ptr, align 8
  331. // CHECK:STDOUT: store ptr %return, ptr %return.addr, align 8, !tbaa !26
  332. // CHECK:STDOUT: %0 = load ptr, ptr %return.addr, align 8, !tbaa !26
  333. // CHECK:STDOUT: ret void
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: ; Function Attrs: alwaysinline nounwind
  337. // CHECK:STDOUT: define void @"_COp:thunk.C.Cpp"(ptr sret({}) %return) #2 !dbg !29 {
  338. // CHECK:STDOUT: entry:
  339. // CHECK:STDOUT: call void @_ZN1CC1Ev.carbon_thunk(ptr %return), !dbg !33
  340. // CHECK:STDOUT: ret void, !dbg !33
  341. // CHECK:STDOUT: }
  342. // CHECK:STDOUT:
  343. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  344. // CHECK:STDOUT: define internal void @_Z8TakeCRefR1C10ForceThunk.carbon_thunk1(ptr noundef nonnull align 1 dereferenceable(1) %0) #3 {
  345. // CHECK:STDOUT: entry:
  346. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  347. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  348. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !26
  349. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !26, !nonnull !34
  350. // CHECK:STDOUT: call void @_Z8TakeCRefR1C10ForceThunk(ptr noundef nonnull align 1 dereferenceable(1) %1)
  351. // CHECK:STDOUT: ret void
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT:
  354. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  355. // CHECK:STDOUT: define internal void @_Z9TakeCRRefRK1C10ForceThunk.carbon_thunk1(ptr noundef %0) #3 {
  356. // CHECK:STDOUT: entry:
  357. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  358. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  359. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !26
  360. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !26
  361. // CHECK:STDOUT: call void @_Z9TakeCRRefRK1C10ForceThunk(ptr noundef nonnull align 1 dereferenceable(1) %1)
  362. // CHECK:STDOUT: ret void
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  366. // CHECK:STDOUT: define internal void @_Z13TakeConstCRefRK1C10ForceThunk.carbon_thunk1(ptr noundef %0) #3 {
  367. // CHECK:STDOUT: entry:
  368. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  369. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  370. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !26
  371. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !26
  372. // CHECK:STDOUT: call void @_Z13TakeConstCRefRK1C10ForceThunk(ptr noundef nonnull align 1 dereferenceable(1) %1)
  373. // CHECK:STDOUT: ret void
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  377. // CHECK:STDOUT: define internal void @_Z10TakeIntRefRi10ForceThunk.carbon_thunk1(ptr noundef nonnull align 4 dereferenceable(4) %0) #3 {
  378. // CHECK:STDOUT: entry:
  379. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  380. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  381. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !35
  382. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !35, !nonnull !34, !align !37
  383. // CHECK:STDOUT: call void @_Z10TakeIntRefRi10ForceThunk(ptr noundef nonnull align 4 dereferenceable(4) %1)
  384. // CHECK:STDOUT: ret void
  385. // CHECK:STDOUT: }
  386. // CHECK:STDOUT:
  387. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  388. // CHECK:STDOUT: define internal void @_Z11TakeIntRRefOi10ForceThunk.carbon_thunk1(ptr noundef %0) #3 {
  389. // CHECK:STDOUT: entry:
  390. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  391. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  392. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !35
  393. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !35
  394. // CHECK:STDOUT: call void @_Z11TakeIntRRefOi10ForceThunk(ptr noundef nonnull align 4 dereferenceable(4) %1)
  395. // CHECK:STDOUT: ret void
  396. // CHECK:STDOUT: }
  397. // CHECK:STDOUT:
  398. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  399. // CHECK:STDOUT: define internal void @_Z15TakeConstIntRefRKi10ForceThunk.carbon_thunk1(ptr noundef %0) #3 {
  400. // CHECK:STDOUT: entry:
  401. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  402. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  403. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8, !tbaa !35
  404. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !tbaa !35
  405. // CHECK:STDOUT: call void @_Z15TakeConstIntRefRKi10ForceThunk(ptr noundef nonnull align 4 dereferenceable(4) %1)
  406. // CHECK:STDOUT: ret void
  407. // CHECK:STDOUT: }
  408. // CHECK:STDOUT:
  409. // CHECK:STDOUT: ; Function Attrs: nounwind
  410. // CHECK:STDOUT: define weak_odr void @"_COp.7e389eab4a7e5487:core.Destroy.Core"(ptr %self) #0 !dbg !38 {
  411. // CHECK:STDOUT: entry:
  412. // CHECK:STDOUT: ret void, !dbg !44
  413. // CHECK:STDOUT: }
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  416. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #4
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: ; Function Attrs: nounwind
  419. // CHECK:STDOUT: define linkonce_odr void @"_COp.d288d62be0e5d791:DefaultOrUnformed.Core.93349b0fe912a29b"(ptr sret({}) %return) #0 !dbg !45 {
  420. // CHECK:STDOUT: call void @"_COp:thunk.C.Cpp"(ptr %return), !dbg !47
  421. // CHECK:STDOUT: ret void, !dbg !48
  422. // CHECK:STDOUT: }
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: declare void @_Z8TakeCRefR1C10ForceThunk(ptr noundef nonnull align 1 dereferenceable(1)) #5
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: declare void @_Z9TakeCRRefRK1C10ForceThunk(ptr noundef nonnull align 1 dereferenceable(1)) #5
  427. // CHECK:STDOUT:
  428. // CHECK:STDOUT: declare void @_Z13TakeConstCRefRK1C10ForceThunk(ptr noundef nonnull align 1 dereferenceable(1)) #5
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: declare void @_Z10TakeIntRefRi10ForceThunk(ptr noundef nonnull align 4 dereferenceable(4)) #5
  431. // CHECK:STDOUT:
  432. // CHECK:STDOUT: declare void @_Z11TakeIntRRefOi10ForceThunk(ptr noundef nonnull align 4 dereferenceable(4)) #5
  433. // CHECK:STDOUT:
  434. // CHECK:STDOUT: declare void @_Z15TakeConstIntRefRKi10ForceThunk(ptr noundef nonnull align 4 dereferenceable(4)) #5
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: ; uselistorder directives
  437. // CHECK:STDOUT: uselistorder ptr @"_COp.7e389eab4a7e5487:core.Destroy.Core", { 2, 1, 0 }
  438. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 4, 3, 2, 1, 0 }
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: attributes #0 = { nounwind }
  441. // CHECK:STDOUT: attributes #1 = { alwaysinline mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  442. // CHECK:STDOUT: attributes #2 = { alwaysinline nounwind }
  443. // CHECK:STDOUT: attributes #3 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  444. // CHECK:STDOUT: attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  445. // CHECK:STDOUT: attributes #5 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  446. // CHECK:STDOUT:
  447. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  448. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  449. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  450. // CHECK:STDOUT:
  451. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  452. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  453. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  454. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  455. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  456. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  457. // CHECK:STDOUT: !6 = !DIFile(filename: "pass_references_via_thunk.carbon", directory: "")
  458. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  459. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  460. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  461. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  462. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "PassRefs", linkageName: "_CPassRefs.Main", scope: null, file: !6, line: 17, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  463. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  464. // CHECK:STDOUT: !13 = !{null}
  465. // CHECK:STDOUT: !14 = !DILocation(line: 18, column: 3, scope: !11)
  466. // CHECK:STDOUT: !15 = !DILocation(line: 20, column: 17, scope: !11)
  467. // CHECK:STDOUT: !16 = !DILocation(line: 23, column: 3, scope: !11)
  468. // CHECK:STDOUT: !17 = !DILocation(line: 13, column: 23, scope: !11)
  469. // CHECK:STDOUT: !18 = !DILocation(line: 26, column: 23, scope: !11)
  470. // CHECK:STDOUT: !19 = !DILocation(line: 19, column: 3, scope: !11)
  471. // CHECK:STDOUT: !20 = !DILocation(line: 20, column: 3, scope: !11)
  472. // CHECK:STDOUT: !21 = !DILocation(line: 21, column: 3, scope: !11)
  473. // CHECK:STDOUT: !22 = !DILocation(line: 24, column: 3, scope: !11)
  474. // CHECK:STDOUT: !23 = !DILocation(line: 25, column: 3, scope: !11)
  475. // CHECK:STDOUT: !24 = !DILocation(line: 26, column: 3, scope: !11)
  476. // CHECK:STDOUT: !25 = !DILocation(line: 17, column: 1, scope: !11)
  477. // CHECK:STDOUT: !26 = !{!27, !27, i64 0}
  478. // CHECK:STDOUT: !27 = !{!"p1 _ZTS1C", !28, i64 0}
  479. // CHECK:STDOUT: !28 = !{!"any pointer", !9, i64 0}
  480. // CHECK:STDOUT: !29 = distinct !DISubprogram(name: "Op", linkageName: "_COp:thunk.C.Cpp", scope: null, file: !6, line: 5, type: !30, spFlags: DISPFlagDefinition, unit: !5)
  481. // CHECK:STDOUT: !30 = !DISubroutineType(types: !31)
  482. // CHECK:STDOUT: !31 = !{!32}
  483. // CHECK:STDOUT: !32 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
  484. // CHECK:STDOUT: !33 = !DILocation(line: 5, column: 7, scope: !29)
  485. // CHECK:STDOUT: !34 = !{}
  486. // CHECK:STDOUT: !35 = !{!36, !36, i64 0}
  487. // CHECK:STDOUT: !36 = !{!"p1 int", !28, i64 0}
  488. // CHECK:STDOUT: !37 = !{i64 4}
  489. // CHECK:STDOUT: !38 = distinct !DISubprogram(name: "Op", linkageName: "_COp.7e389eab4a7e5487:core.Destroy.Core", scope: null, file: !6, line: 26, type: !39, spFlags: DISPFlagDefinition, unit: !5, retainedNodes: !42)
  490. // CHECK:STDOUT: !39 = !DISubroutineType(types: !40)
  491. // CHECK:STDOUT: !40 = !{null, !41}
  492. // CHECK:STDOUT: !41 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
  493. // CHECK:STDOUT: !42 = !{!43}
  494. // CHECK:STDOUT: !43 = !DILocalVariable(arg: 1, scope: !38, type: !41)
  495. // CHECK:STDOUT: !44 = !DILocation(line: 26, column: 23, scope: !38)
  496. // CHECK:STDOUT: !45 = distinct !DISubprogram(name: "Op", linkageName: "_COp.d288d62be0e5d791:DefaultOrUnformed.Core.93349b0fe912a29b", scope: null, file: !46, line: 9, type: !30, spFlags: DISPFlagDefinition, unit: !5)
  497. // CHECK:STDOUT: !46 = !DIFile(filename: "min_prelude/parts/default.carbon", directory: "")
  498. // CHECK:STDOUT: !47 = !DILocation(line: 9, column: 28, scope: !45)
  499. // CHECK:STDOUT: !48 = !DILocation(line: 9, column: 21, scope: !45)
  500. // CHECK:STDOUT: ; ModuleID = 'return_references.carbon'
  501. // CHECK:STDOUT: source_filename = "return_references.carbon"
  502. // 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"
  503. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  504. // CHECK:STDOUT:
  505. // CHECK:STDOUT: ; Function Attrs: nounwind
  506. // CHECK:STDOUT: define void @_CGetRefs.Main() #0 !dbg !11 {
  507. // CHECK:STDOUT: entry:
  508. // CHECK:STDOUT: %ReturnCRef.call = call ptr @_Z10ReturnCRefv(), !dbg !14
  509. // CHECK:STDOUT: %ReturnCRRef.call = call ptr @_Z11ReturnCRRefv(), !dbg !15
  510. // CHECK:STDOUT: %ReturnConstCRef.call = call ptr @_Z15ReturnConstCRefv(), !dbg !16
  511. // CHECK:STDOUT: %ReturnIntRef.call = call ptr @_Z12ReturnIntRefv(), !dbg !17
  512. // CHECK:STDOUT: %ReturnIntRRef.call = call ptr @_Z13ReturnIntRRefv(), !dbg !18
  513. // CHECK:STDOUT: %ReturnConstIntRef.call = call ptr @_Z17ReturnConstIntRefv(), !dbg !19
  514. // CHECK:STDOUT: ret void, !dbg !20
  515. // CHECK:STDOUT: }
  516. // CHECK:STDOUT:
  517. // CHECK:STDOUT: declare noundef nonnull align 1 dereferenceable(1) ptr @_Z10ReturnCRefv() #1
  518. // CHECK:STDOUT:
  519. // CHECK:STDOUT: declare noundef nonnull align 1 dereferenceable(1) ptr @_Z11ReturnCRRefv() #1
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: declare noundef nonnull align 1 dereferenceable(1) ptr @_Z15ReturnConstCRefv() #1
  522. // CHECK:STDOUT:
  523. // CHECK:STDOUT: declare noundef nonnull align 4 dereferenceable(4) ptr @_Z12ReturnIntRefv() #1
  524. // CHECK:STDOUT:
  525. // CHECK:STDOUT: declare noundef nonnull align 4 dereferenceable(4) ptr @_Z13ReturnIntRRefv() #1
  526. // CHECK:STDOUT:
  527. // CHECK:STDOUT: declare noundef nonnull align 4 dereferenceable(4) ptr @_Z17ReturnConstIntRefv() #1
  528. // CHECK:STDOUT:
  529. // CHECK:STDOUT: attributes #0 = { nounwind }
  530. // 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" }
  531. // CHECK:STDOUT:
  532. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  533. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  534. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  535. // CHECK:STDOUT:
  536. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  537. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  538. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  539. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  540. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  541. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  542. // CHECK:STDOUT: !6 = !DIFile(filename: "return_references.carbon", directory: "")
  543. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  544. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  545. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  546. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  547. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "GetRefs", linkageName: "_CGetRefs.Main", scope: null, file: !6, line: 16, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  548. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  549. // CHECK:STDOUT: !13 = !{null}
  550. // CHECK:STDOUT: !14 = !DILocation(line: 17, column: 22, scope: !11)
  551. // CHECK:STDOUT: !15 = !DILocation(line: 18, column: 22, scope: !11)
  552. // CHECK:STDOUT: !16 = !DILocation(line: 19, column: 28, scope: !11)
  553. // CHECK:STDOUT: !17 = !DILocation(line: 21, column: 20, scope: !11)
  554. // CHECK:STDOUT: !18 = !DILocation(line: 22, column: 20, scope: !11)
  555. // CHECK:STDOUT: !19 = !DILocation(line: 23, column: 26, scope: !11)
  556. // CHECK:STDOUT: !20 = !DILocation(line: 16, column: 1, scope: !11)
  557. // CHECK:STDOUT: ; ModuleID = 'return_references_via_thunk.carbon'
  558. // CHECK:STDOUT: source_filename = "return_references_via_thunk.carbon"
  559. // 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"
  560. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  561. // CHECK:STDOUT:
  562. // CHECK:STDOUT: %class.ForceThunk = type { i8 }
  563. // CHECK:STDOUT:
  564. // CHECK:STDOUT: ; Function Attrs: nounwind
  565. // CHECK:STDOUT: define void @_CGetRefs.Main() #0 !dbg !11 {
  566. // CHECK:STDOUT: entry:
  567. // CHECK:STDOUT: %ReturnCRef__carbon_thunk.call = call ptr @_Z10ReturnCRef10ForceThunk.carbon_thunk0(), !dbg !14
  568. // CHECK:STDOUT: %ReturnCRRef__carbon_thunk.call = call ptr @_Z11ReturnCRRef10ForceThunk.carbon_thunk0(), !dbg !15
  569. // CHECK:STDOUT: %ReturnConstCRef__carbon_thunk.call = call ptr @_Z15ReturnConstCRef10ForceThunk.carbon_thunk0(), !dbg !16
  570. // CHECK:STDOUT: %ReturnIntRef__carbon_thunk.call = call ptr @_Z12ReturnIntRef10ForceThunk.carbon_thunk0(), !dbg !17
  571. // CHECK:STDOUT: %ReturnIntRRef__carbon_thunk.call = call ptr @_Z13ReturnIntRRef10ForceThunk.carbon_thunk0(), !dbg !18
  572. // CHECK:STDOUT: %ReturnConstIntRef__carbon_thunk.call = call ptr @_Z17ReturnConstIntRef10ForceThunk.carbon_thunk0(), !dbg !19
  573. // CHECK:STDOUT: ret void, !dbg !20
  574. // CHECK:STDOUT: }
  575. // CHECK:STDOUT:
  576. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  577. // CHECK:STDOUT: define internal noundef nonnull align 1 dereferenceable(1) ptr @_Z10ReturnCRef10ForceThunk.carbon_thunk0() #1 {
  578. // CHECK:STDOUT: entry:
  579. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  580. // CHECK:STDOUT: %call = call noundef nonnull align 1 dereferenceable(1) ptr @_Z10ReturnCRef10ForceThunk()
  581. // CHECK:STDOUT: ret ptr %call
  582. // CHECK:STDOUT: }
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  585. // CHECK:STDOUT: define internal noundef nonnull align 1 dereferenceable(1) ptr @_Z11ReturnCRRef10ForceThunk.carbon_thunk0() #1 {
  586. // CHECK:STDOUT: entry:
  587. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  588. // CHECK:STDOUT: %call = call noundef nonnull align 1 dereferenceable(1) ptr @_Z11ReturnCRRef10ForceThunk()
  589. // CHECK:STDOUT: ret ptr %call
  590. // CHECK:STDOUT: }
  591. // CHECK:STDOUT:
  592. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  593. // CHECK:STDOUT: define internal noundef nonnull align 1 dereferenceable(1) ptr @_Z15ReturnConstCRef10ForceThunk.carbon_thunk0() #1 {
  594. // CHECK:STDOUT: entry:
  595. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  596. // CHECK:STDOUT: %call = call noundef nonnull align 1 dereferenceable(1) ptr @_Z15ReturnConstCRef10ForceThunk()
  597. // CHECK:STDOUT: ret ptr %call
  598. // CHECK:STDOUT: }
  599. // CHECK:STDOUT:
  600. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  601. // CHECK:STDOUT: define internal noundef nonnull align 4 dereferenceable(4) ptr @_Z12ReturnIntRef10ForceThunk.carbon_thunk0() #1 {
  602. // CHECK:STDOUT: entry:
  603. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  604. // CHECK:STDOUT: %call = call noundef nonnull align 4 dereferenceable(4) ptr @_Z12ReturnIntRef10ForceThunk()
  605. // CHECK:STDOUT: ret ptr %call
  606. // CHECK:STDOUT: }
  607. // CHECK:STDOUT:
  608. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  609. // CHECK:STDOUT: define internal noundef nonnull align 4 dereferenceable(4) ptr @_Z13ReturnIntRRef10ForceThunk.carbon_thunk0() #1 {
  610. // CHECK:STDOUT: entry:
  611. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  612. // CHECK:STDOUT: %call = call noundef nonnull align 4 dereferenceable(4) ptr @_Z13ReturnIntRRef10ForceThunk()
  613. // CHECK:STDOUT: ret ptr %call
  614. // CHECK:STDOUT: }
  615. // CHECK:STDOUT:
  616. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress uwtable
  617. // CHECK:STDOUT: define internal noundef nonnull align 4 dereferenceable(4) ptr @_Z17ReturnConstIntRef10ForceThunk.carbon_thunk0() #1 {
  618. // CHECK:STDOUT: entry:
  619. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  620. // CHECK:STDOUT: %call = call noundef nonnull align 4 dereferenceable(4) ptr @_Z17ReturnConstIntRef10ForceThunk()
  621. // CHECK:STDOUT: ret ptr %call
  622. // CHECK:STDOUT: }
  623. // CHECK:STDOUT:
  624. // CHECK:STDOUT: declare noundef nonnull align 1 dereferenceable(1) ptr @_Z10ReturnCRef10ForceThunk() #2
  625. // CHECK:STDOUT:
  626. // CHECK:STDOUT: declare noundef nonnull align 1 dereferenceable(1) ptr @_Z11ReturnCRRef10ForceThunk() #2
  627. // CHECK:STDOUT:
  628. // CHECK:STDOUT: declare noundef nonnull align 1 dereferenceable(1) ptr @_Z15ReturnConstCRef10ForceThunk() #2
  629. // CHECK:STDOUT:
  630. // CHECK:STDOUT: declare noundef nonnull align 4 dereferenceable(4) ptr @_Z12ReturnIntRef10ForceThunk() #2
  631. // CHECK:STDOUT:
  632. // CHECK:STDOUT: declare noundef nonnull align 4 dereferenceable(4) ptr @_Z13ReturnIntRRef10ForceThunk() #2
  633. // CHECK:STDOUT:
  634. // CHECK:STDOUT: declare noundef nonnull align 4 dereferenceable(4) ptr @_Z17ReturnConstIntRef10ForceThunk() #2
  635. // CHECK:STDOUT:
  636. // CHECK:STDOUT: attributes #0 = { nounwind }
  637. // CHECK:STDOUT: attributes #1 = { alwaysinline mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  638. // CHECK:STDOUT: attributes #2 = { "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" }
  639. // CHECK:STDOUT:
  640. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  641. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  642. // CHECK:STDOUT: !llvm.errno.tbaa = !{!7}
  643. // CHECK:STDOUT:
  644. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  645. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  646. // CHECK:STDOUT: !2 = !{i32 8, !"PIC Level", i32 2}
  647. // CHECK:STDOUT: !3 = !{i32 7, !"PIE Level", i32 2}
  648. // CHECK:STDOUT: !4 = !{i32 7, !"uwtable", i32 2}
  649. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  650. // CHECK:STDOUT: !6 = !DIFile(filename: "return_references_via_thunk.carbon", directory: "")
  651. // CHECK:STDOUT: !7 = !{!8, !8, i64 0}
  652. // CHECK:STDOUT: !8 = !{!"int", !9, i64 0}
  653. // CHECK:STDOUT: !9 = !{!"omnipotent char", !10, i64 0}
  654. // CHECK:STDOUT: !10 = !{!"Simple C++ TBAA"}
  655. // CHECK:STDOUT: !11 = distinct !DISubprogram(name: "GetRefs", linkageName: "_CGetRefs.Main", scope: null, file: !6, line: 17, type: !12, spFlags: DISPFlagDefinition, unit: !5)
  656. // CHECK:STDOUT: !12 = !DISubroutineType(types: !13)
  657. // CHECK:STDOUT: !13 = !{null}
  658. // CHECK:STDOUT: !14 = !DILocation(line: 18, column: 22, scope: !11)
  659. // CHECK:STDOUT: !15 = !DILocation(line: 19, column: 22, scope: !11)
  660. // CHECK:STDOUT: !16 = !DILocation(line: 20, column: 28, scope: !11)
  661. // CHECK:STDOUT: !17 = !DILocation(line: 22, column: 20, scope: !11)
  662. // CHECK:STDOUT: !18 = !DILocation(line: 23, column: 20, scope: !11)
  663. // CHECK:STDOUT: !19 = !DILocation(line: 24, column: 26, scope: !11)
  664. // CHECK:STDOUT: !20 = !DILocation(line: 17, column: 1, scope: !11)