reference.carbon 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  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. var c1: Cpp.C* = Cpp.ReturnCRef();
  74. var c2: Cpp.C* = Cpp.ReturnCRRef();
  75. var c3: const Cpp.C* = Cpp.ReturnConstCRef();
  76. var n1: i32* = Cpp.ReturnIntRef();
  77. var n2: i32* = Cpp.ReturnIntRRef();
  78. var n3: 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. var c1: Cpp.C* = Cpp.ReturnCRef();
  94. var c2: Cpp.C* = Cpp.ReturnCRRef();
  95. var c3: const Cpp.C* = Cpp.ReturnConstCRef();
  96. var n1: i32* = Cpp.ReturnIntRef();
  97. var n2: i32* = Cpp.ReturnIntRRef();
  98. var n3: 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_18.3 = internal constant {} zeroinitializer
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: ; Function Attrs: nounwind
  108. // CHECK:STDOUT: define void @_CPassRefs.Main() #0 !dbg !7 {
  109. // CHECK:STDOUT: entry:
  110. // CHECK:STDOUT: %c.var = alloca {}, align 8, !dbg !10
  111. // CHECK:STDOUT: %.loc19_18.2.temp = alloca {}, align 8, !dbg !11
  112. // CHECK:STDOUT: %n.var = alloca i32, align 4, !dbg !12
  113. // CHECK:STDOUT: %.loc24_22.3.temp = alloca i32, align 4, !dbg !13
  114. // CHECK:STDOUT: %.loc25_23.2.temp = alloca i32, align 4, !dbg !14
  115. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c.var), !dbg !10
  116. // CHECK:STDOUT: call void @_Z8TakeCRefR1C(ptr %c.var), !dbg !15
  117. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc19_18.2.temp), !dbg !11
  118. // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.loc19_18.2.temp, ptr align 1 @C.val.loc19_18.3, i64 0, i1 false), !dbg !11
  119. // CHECK:STDOUT: call void @_Z9TakeCRRefO1C.carbon_thunk(ptr %.loc19_18.2.temp), !dbg !16
  120. // CHECK:STDOUT: call void @_Z13TakeConstCRefRK1C.carbon_thunk(ptr %c.var), !dbg !17
  121. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n.var), !dbg !12
  122. // CHECK:STDOUT: call void @_Z10TakeIntRefRi(ptr %n.var), !dbg !18
  123. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc24_22.3.temp), !dbg !13
  124. // CHECK:STDOUT: store i32 42, ptr %.loc24_22.3.temp, align 4, !dbg !13
  125. // CHECK:STDOUT: call void @_Z11TakeIntRRefOi.carbon_thunk(ptr %.loc24_22.3.temp), !dbg !19
  126. // CHECK:STDOUT: %.loc25_23.1 = load i32, ptr %n.var, align 4, !dbg !14
  127. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc25_23.2.temp), !dbg !14
  128. // CHECK:STDOUT: store i32 %.loc25_23.1, ptr %.loc25_23.2.temp, align 4, !dbg !14
  129. // CHECK:STDOUT: call void @_Z15TakeConstIntRefRKi.carbon_thunk(ptr %.loc25_23.2.temp), !dbg !20
  130. // CHECK:STDOUT: ret void, !dbg !21
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: declare void @_Z8TakeCRefR1C(ptr)
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: declare void @_Z10TakeIntRefRi(ptr)
  136. // CHECK:STDOUT:
  137. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  138. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
  141. // CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) #2
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  144. // CHECK:STDOUT: define dso_local void @_Z9TakeCRRefO1C.carbon_thunk(ptr %0) #3 {
  145. // CHECK:STDOUT: entry:
  146. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  147. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
  148. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8
  149. // CHECK:STDOUT: call void @_Z9TakeCRRefO1C(ptr nonnull align 1 dereferenceable(1) %1)
  150. // CHECK:STDOUT: ret void
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT:
  153. // CHECK:STDOUT: declare void @_Z9TakeCRRefO1C(ptr nonnull align 1 dereferenceable(1)) #4
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  156. // CHECK:STDOUT: define dso_local void @_Z13TakeConstCRefRK1C.carbon_thunk(ptr %0) #3 {
  157. // CHECK:STDOUT: entry:
  158. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  159. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
  160. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8
  161. // CHECK:STDOUT: call void @_Z13TakeConstCRefRK1C(ptr nonnull align 1 dereferenceable(1) %1)
  162. // CHECK:STDOUT: ret void
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: declare void @_Z13TakeConstCRefRK1C(ptr nonnull align 1 dereferenceable(1)) #4
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  168. // CHECK:STDOUT: define dso_local void @_Z11TakeIntRRefOi.carbon_thunk(ptr %0) #3 {
  169. // CHECK:STDOUT: entry:
  170. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  171. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
  172. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8
  173. // CHECK:STDOUT: call void @_Z11TakeIntRRefOi(ptr nonnull align 4 dereferenceable(4) %1)
  174. // CHECK:STDOUT: ret void
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: declare void @_Z11TakeIntRRefOi(ptr nonnull align 4 dereferenceable(4)) #4
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  180. // CHECK:STDOUT: define dso_local void @_Z15TakeConstIntRefRKi.carbon_thunk(ptr %0) #3 {
  181. // CHECK:STDOUT: entry:
  182. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  183. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
  184. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8
  185. // CHECK:STDOUT: call void @_Z15TakeConstIntRefRKi(ptr nonnull align 4 dereferenceable(4) %1)
  186. // CHECK:STDOUT: ret void
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: declare void @_Z15TakeConstIntRefRKi(ptr nonnull align 4 dereferenceable(4)) #4
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: ; uselistorder directives
  192. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 4, 3, 2, 1, 0 }
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: attributes #0 = { nounwind }
  195. // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  196. // CHECK:STDOUT: attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
  197. // CHECK:STDOUT: attributes #3 = { alwaysinline mustprogress "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="0" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  198. // CHECK:STDOUT: attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="0" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  201. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  204. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  205. // CHECK:STDOUT: !2 = !{i32 1, !"wchar_size", i32 4}
  206. // CHECK:STDOUT: !3 = !{i32 8, !"PIC Level", i32 0}
  207. // CHECK:STDOUT: !4 = !{i32 7, !"PIE Level", i32 2}
  208. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  209. // CHECK:STDOUT: !6 = !DIFile(filename: "pass_references.carbon", directory: "")
  210. // CHECK:STDOUT: !7 = distinct !DISubprogram(name: "PassRefs", linkageName: "_CPassRefs.Main", scope: null, file: !6, line: 16, type: !8, spFlags: DISPFlagDefinition, unit: !5)
  211. // CHECK:STDOUT: !8 = !DISubroutineType(types: !9)
  212. // CHECK:STDOUT: !9 = !{}
  213. // CHECK:STDOUT: !10 = !DILocation(line: 17, column: 3, scope: !7)
  214. // CHECK:STDOUT: !11 = !DILocation(line: 19, column: 17, scope: !7)
  215. // CHECK:STDOUT: !12 = !DILocation(line: 22, column: 3, scope: !7)
  216. // CHECK:STDOUT: !13 = !DILocation(line: 24, column: 19, scope: !7)
  217. // CHECK:STDOUT: !14 = !DILocation(line: 25, column: 23, scope: !7)
  218. // CHECK:STDOUT: !15 = !DILocation(line: 18, column: 3, scope: !7)
  219. // CHECK:STDOUT: !16 = !DILocation(line: 19, column: 3, scope: !7)
  220. // CHECK:STDOUT: !17 = !DILocation(line: 20, column: 3, scope: !7)
  221. // CHECK:STDOUT: !18 = !DILocation(line: 23, column: 3, scope: !7)
  222. // CHECK:STDOUT: !19 = !DILocation(line: 24, column: 3, scope: !7)
  223. // CHECK:STDOUT: !20 = !DILocation(line: 25, column: 3, scope: !7)
  224. // CHECK:STDOUT: !21 = !DILocation(line: 16, column: 1, scope: !7)
  225. // CHECK:STDOUT: ; ModuleID = 'pass_references_via_thunk.carbon'
  226. // CHECK:STDOUT: source_filename = "pass_references_via_thunk.carbon"
  227. // 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"
  228. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: %class.ForceThunk = type { i8 }
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: @C.val.loc20_18.3 = internal constant {} zeroinitializer
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: ; Function Attrs: nounwind
  235. // CHECK:STDOUT: define void @_CPassRefs.Main() #0 !dbg !7 {
  236. // CHECK:STDOUT: entry:
  237. // CHECK:STDOUT: %c.var = alloca {}, align 8, !dbg !10
  238. // CHECK:STDOUT: %.loc20_18.2.temp = alloca {}, align 8, !dbg !11
  239. // CHECK:STDOUT: %n.var = alloca i32, align 4, !dbg !12
  240. // CHECK:STDOUT: %.loc25_22.3.temp = alloca i32, align 4, !dbg !13
  241. // CHECK:STDOUT: %.loc26_23.2.temp = alloca i32, align 4, !dbg !14
  242. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c.var), !dbg !10
  243. // CHECK:STDOUT: call void @_Z8TakeCRefR1C10ForceThunk.carbon_thunk1(ptr %c.var), !dbg !15
  244. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc20_18.2.temp), !dbg !11
  245. // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.loc20_18.2.temp, ptr align 1 @C.val.loc20_18.3, i64 0, i1 false), !dbg !11
  246. // CHECK:STDOUT: call void @_Z9TakeCRRefRK1C10ForceThunk.carbon_thunk1(ptr %.loc20_18.2.temp), !dbg !16
  247. // CHECK:STDOUT: call void @_Z13TakeConstCRefRK1C10ForceThunk.carbon_thunk1(ptr %c.var), !dbg !17
  248. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n.var), !dbg !12
  249. // CHECK:STDOUT: call void @_Z10TakeIntRefRi10ForceThunk.carbon_thunk1(ptr %n.var), !dbg !18
  250. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc25_22.3.temp), !dbg !13
  251. // CHECK:STDOUT: store i32 42, ptr %.loc25_22.3.temp, align 4, !dbg !13
  252. // CHECK:STDOUT: call void @_Z11TakeIntRRefOi10ForceThunk.carbon_thunk1(ptr %.loc25_22.3.temp), !dbg !19
  253. // CHECK:STDOUT: %.loc26_23.1 = load i32, ptr %n.var, align 4, !dbg !14
  254. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc26_23.2.temp), !dbg !14
  255. // CHECK:STDOUT: store i32 %.loc26_23.1, ptr %.loc26_23.2.temp, align 4, !dbg !14
  256. // CHECK:STDOUT: call void @_Z15TakeConstIntRefRKi10ForceThunk.carbon_thunk1(ptr %.loc26_23.2.temp), !dbg !20
  257. // CHECK:STDOUT: ret void, !dbg !21
  258. // CHECK:STDOUT: }
  259. // CHECK:STDOUT:
  260. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  261. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
  264. // CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) #2
  265. // CHECK:STDOUT:
  266. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  267. // CHECK:STDOUT: define dso_local void @_Z8TakeCRefR1C10ForceThunk.carbon_thunk1(ptr nonnull align 1 dereferenceable(1) %0) #3 {
  268. // CHECK:STDOUT: entry:
  269. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  270. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  271. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
  272. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !nonnull !9
  273. // CHECK:STDOUT: call void @_Z8TakeCRefR1C10ForceThunk(ptr nonnull align 1 dereferenceable(1) %1)
  274. // CHECK:STDOUT: ret void
  275. // CHECK:STDOUT: }
  276. // CHECK:STDOUT:
  277. // CHECK:STDOUT: declare void @_Z8TakeCRefR1C10ForceThunk(ptr nonnull align 1 dereferenceable(1)) #4
  278. // CHECK:STDOUT:
  279. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  280. // CHECK:STDOUT: define dso_local void @_Z9TakeCRRefRK1C10ForceThunk.carbon_thunk1(ptr %0) #3 {
  281. // CHECK:STDOUT: entry:
  282. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  283. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  284. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
  285. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8
  286. // CHECK:STDOUT: call void @_Z9TakeCRRefRK1C10ForceThunk(ptr nonnull align 1 dereferenceable(1) %1)
  287. // CHECK:STDOUT: ret void
  288. // CHECK:STDOUT: }
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: declare void @_Z9TakeCRRefRK1C10ForceThunk(ptr nonnull align 1 dereferenceable(1)) #4
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  293. // CHECK:STDOUT: define dso_local void @_Z13TakeConstCRefRK1C10ForceThunk.carbon_thunk1(ptr %0) #3 {
  294. // CHECK:STDOUT: entry:
  295. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  296. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  297. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
  298. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8
  299. // CHECK:STDOUT: call void @_Z13TakeConstCRefRK1C10ForceThunk(ptr nonnull align 1 dereferenceable(1) %1)
  300. // CHECK:STDOUT: ret void
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: declare void @_Z13TakeConstCRefRK1C10ForceThunk(ptr nonnull align 1 dereferenceable(1)) #4
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  306. // CHECK:STDOUT: define dso_local void @_Z10TakeIntRefRi10ForceThunk.carbon_thunk1(ptr nonnull align 4 dereferenceable(4) %0) #3 {
  307. // CHECK:STDOUT: entry:
  308. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  309. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  310. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
  311. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8, !nonnull !9, !align !22
  312. // CHECK:STDOUT: call void @_Z10TakeIntRefRi10ForceThunk(ptr nonnull align 4 dereferenceable(4) %1)
  313. // CHECK:STDOUT: ret void
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: declare void @_Z10TakeIntRefRi10ForceThunk(ptr nonnull align 4 dereferenceable(4)) #4
  317. // CHECK:STDOUT:
  318. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  319. // CHECK:STDOUT: define dso_local void @_Z11TakeIntRRefOi10ForceThunk.carbon_thunk1(ptr %0) #3 {
  320. // CHECK:STDOUT: entry:
  321. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  322. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  323. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
  324. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8
  325. // CHECK:STDOUT: call void @_Z11TakeIntRRefOi10ForceThunk(ptr nonnull align 4 dereferenceable(4) %1)
  326. // CHECK:STDOUT: ret void
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT:
  329. // CHECK:STDOUT: declare void @_Z11TakeIntRRefOi10ForceThunk(ptr nonnull align 4 dereferenceable(4)) #4
  330. // CHECK:STDOUT:
  331. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  332. // CHECK:STDOUT: define dso_local void @_Z15TakeConstIntRefRKi10ForceThunk.carbon_thunk1(ptr %0) #3 {
  333. // CHECK:STDOUT: entry:
  334. // CHECK:STDOUT: %.addr = alloca ptr, align 8
  335. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  336. // CHECK:STDOUT: store ptr %0, ptr %.addr, align 8
  337. // CHECK:STDOUT: %1 = load ptr, ptr %.addr, align 8
  338. // CHECK:STDOUT: call void @_Z15TakeConstIntRefRKi10ForceThunk(ptr nonnull align 4 dereferenceable(4) %1)
  339. // CHECK:STDOUT: ret void
  340. // CHECK:STDOUT: }
  341. // CHECK:STDOUT:
  342. // CHECK:STDOUT: declare void @_Z15TakeConstIntRefRKi10ForceThunk(ptr nonnull align 4 dereferenceable(4)) #4
  343. // CHECK:STDOUT:
  344. // CHECK:STDOUT: ; uselistorder directives
  345. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 4, 3, 2, 1, 0 }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: attributes #0 = { nounwind }
  348. // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  349. // CHECK:STDOUT: attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
  350. // CHECK:STDOUT: attributes #3 = { alwaysinline mustprogress "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="0" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  351. // CHECK:STDOUT: attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="0" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  354. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  355. // CHECK:STDOUT:
  356. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  357. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  358. // CHECK:STDOUT: !2 = !{i32 1, !"wchar_size", i32 4}
  359. // CHECK:STDOUT: !3 = !{i32 8, !"PIC Level", i32 0}
  360. // CHECK:STDOUT: !4 = !{i32 7, !"PIE Level", i32 2}
  361. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  362. // CHECK:STDOUT: !6 = !DIFile(filename: "pass_references_via_thunk.carbon", directory: "")
  363. // CHECK:STDOUT: !7 = distinct !DISubprogram(name: "PassRefs", linkageName: "_CPassRefs.Main", scope: null, file: !6, line: 17, type: !8, spFlags: DISPFlagDefinition, unit: !5)
  364. // CHECK:STDOUT: !8 = !DISubroutineType(types: !9)
  365. // CHECK:STDOUT: !9 = !{}
  366. // CHECK:STDOUT: !10 = !DILocation(line: 18, column: 3, scope: !7)
  367. // CHECK:STDOUT: !11 = !DILocation(line: 20, column: 17, scope: !7)
  368. // CHECK:STDOUT: !12 = !DILocation(line: 23, column: 3, scope: !7)
  369. // CHECK:STDOUT: !13 = !DILocation(line: 25, column: 19, scope: !7)
  370. // CHECK:STDOUT: !14 = !DILocation(line: 26, column: 23, scope: !7)
  371. // CHECK:STDOUT: !15 = !DILocation(line: 19, column: 3, scope: !7)
  372. // CHECK:STDOUT: !16 = !DILocation(line: 20, column: 3, scope: !7)
  373. // CHECK:STDOUT: !17 = !DILocation(line: 21, column: 3, scope: !7)
  374. // CHECK:STDOUT: !18 = !DILocation(line: 24, column: 3, scope: !7)
  375. // CHECK:STDOUT: !19 = !DILocation(line: 25, column: 3, scope: !7)
  376. // CHECK:STDOUT: !20 = !DILocation(line: 26, column: 3, scope: !7)
  377. // CHECK:STDOUT: !21 = !DILocation(line: 17, column: 1, scope: !7)
  378. // CHECK:STDOUT: !22 = !{i64 4}
  379. // CHECK:STDOUT: ; ModuleID = 'return_references.carbon'
  380. // CHECK:STDOUT: source_filename = "return_references.carbon"
  381. // 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"
  382. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: ; Function Attrs: nounwind
  385. // CHECK:STDOUT: define void @_CGetRefs.Main() #0 !dbg !7 {
  386. // CHECK:STDOUT: entry:
  387. // CHECK:STDOUT: %c1.var = alloca ptr, align 8, !dbg !10
  388. // CHECK:STDOUT: %c2.var = alloca ptr, align 8, !dbg !11
  389. // CHECK:STDOUT: %c3.var = alloca ptr, align 8, !dbg !12
  390. // CHECK:STDOUT: %n1.var = alloca ptr, align 8, !dbg !13
  391. // CHECK:STDOUT: %n2.var = alloca ptr, align 8, !dbg !14
  392. // CHECK:STDOUT: %n3.var = alloca ptr, align 8, !dbg !15
  393. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c1.var), !dbg !10
  394. // CHECK:STDOUT: %ReturnCRef.call = call ptr @_Z10ReturnCRefv(), !dbg !16
  395. // CHECK:STDOUT: store ptr %ReturnCRef.call, ptr %c1.var, align 8, !dbg !10
  396. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c2.var), !dbg !11
  397. // CHECK:STDOUT: %ReturnCRRef.call = call ptr @_Z11ReturnCRRefv(), !dbg !17
  398. // CHECK:STDOUT: store ptr %ReturnCRRef.call, ptr %c2.var, align 8, !dbg !11
  399. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c3.var), !dbg !12
  400. // CHECK:STDOUT: %ReturnConstCRef.call = call ptr @_Z15ReturnConstCRefv(), !dbg !18
  401. // CHECK:STDOUT: store ptr %ReturnConstCRef.call, ptr %c3.var, align 8, !dbg !12
  402. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n1.var), !dbg !13
  403. // CHECK:STDOUT: %ReturnIntRef.call = call ptr @_Z12ReturnIntRefv(), !dbg !19
  404. // CHECK:STDOUT: store ptr %ReturnIntRef.call, ptr %n1.var, align 8, !dbg !13
  405. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n2.var), !dbg !14
  406. // CHECK:STDOUT: %ReturnIntRRef.call = call ptr @_Z13ReturnIntRRefv(), !dbg !20
  407. // CHECK:STDOUT: store ptr %ReturnIntRRef.call, ptr %n2.var, align 8, !dbg !14
  408. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n3.var), !dbg !15
  409. // CHECK:STDOUT: %ReturnConstIntRef.call = call ptr @_Z17ReturnConstIntRefv(), !dbg !21
  410. // CHECK:STDOUT: store ptr %ReturnConstIntRef.call, ptr %n3.var, align 8, !dbg !15
  411. // CHECK:STDOUT: ret void, !dbg !22
  412. // CHECK:STDOUT: }
  413. // CHECK:STDOUT:
  414. // CHECK:STDOUT: declare ptr @_Z10ReturnCRefv()
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: declare ptr @_Z11ReturnCRRefv()
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: declare ptr @_Z15ReturnConstCRefv()
  419. // CHECK:STDOUT:
  420. // CHECK:STDOUT: declare ptr @_Z12ReturnIntRefv()
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: declare ptr @_Z13ReturnIntRRefv()
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: declare ptr @_Z17ReturnConstIntRefv()
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  427. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: ; uselistorder directives
  430. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 5, 4, 3, 2, 1, 0 }
  431. // CHECK:STDOUT:
  432. // CHECK:STDOUT: attributes #0 = { nounwind }
  433. // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  434. // CHECK:STDOUT:
  435. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  436. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  437. // CHECK:STDOUT:
  438. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  439. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  440. // CHECK:STDOUT: !2 = !{i32 1, !"wchar_size", i32 4}
  441. // CHECK:STDOUT: !3 = !{i32 8, !"PIC Level", i32 0}
  442. // CHECK:STDOUT: !4 = !{i32 7, !"PIE Level", i32 2}
  443. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  444. // CHECK:STDOUT: !6 = !DIFile(filename: "return_references.carbon", directory: "")
  445. // CHECK:STDOUT: !7 = distinct !DISubprogram(name: "GetRefs", linkageName: "_CGetRefs.Main", scope: null, file: !6, line: 16, type: !8, spFlags: DISPFlagDefinition, unit: !5)
  446. // CHECK:STDOUT: !8 = !DISubroutineType(types: !9)
  447. // CHECK:STDOUT: !9 = !{}
  448. // CHECK:STDOUT: !10 = !DILocation(line: 17, column: 3, scope: !7)
  449. // CHECK:STDOUT: !11 = !DILocation(line: 18, column: 3, scope: !7)
  450. // CHECK:STDOUT: !12 = !DILocation(line: 19, column: 3, scope: !7)
  451. // CHECK:STDOUT: !13 = !DILocation(line: 21, column: 3, scope: !7)
  452. // CHECK:STDOUT: !14 = !DILocation(line: 22, column: 3, scope: !7)
  453. // CHECK:STDOUT: !15 = !DILocation(line: 23, column: 3, scope: !7)
  454. // CHECK:STDOUT: !16 = !DILocation(line: 17, column: 20, scope: !7)
  455. // CHECK:STDOUT: !17 = !DILocation(line: 18, column: 20, scope: !7)
  456. // CHECK:STDOUT: !18 = !DILocation(line: 19, column: 26, scope: !7)
  457. // CHECK:STDOUT: !19 = !DILocation(line: 21, column: 18, scope: !7)
  458. // CHECK:STDOUT: !20 = !DILocation(line: 22, column: 18, scope: !7)
  459. // CHECK:STDOUT: !21 = !DILocation(line: 23, column: 24, scope: !7)
  460. // CHECK:STDOUT: !22 = !DILocation(line: 16, column: 1, scope: !7)
  461. // CHECK:STDOUT: ; ModuleID = 'return_references_via_thunk.carbon'
  462. // CHECK:STDOUT: source_filename = "return_references_via_thunk.carbon"
  463. // 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"
  464. // CHECK:STDOUT: target triple = "x86_64-unknown-linux-gnu"
  465. // CHECK:STDOUT:
  466. // CHECK:STDOUT: %class.ForceThunk = type { i8 }
  467. // CHECK:STDOUT:
  468. // CHECK:STDOUT: ; Function Attrs: nounwind
  469. // CHECK:STDOUT: define void @_CGetRefs.Main() #0 !dbg !7 {
  470. // CHECK:STDOUT: entry:
  471. // CHECK:STDOUT: %c1.var = alloca ptr, align 8, !dbg !10
  472. // CHECK:STDOUT: %c2.var = alloca ptr, align 8, !dbg !11
  473. // CHECK:STDOUT: %c3.var = alloca ptr, align 8, !dbg !12
  474. // CHECK:STDOUT: %n1.var = alloca ptr, align 8, !dbg !13
  475. // CHECK:STDOUT: %n2.var = alloca ptr, align 8, !dbg !14
  476. // CHECK:STDOUT: %n3.var = alloca ptr, align 8, !dbg !15
  477. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c1.var), !dbg !10
  478. // CHECK:STDOUT: %ReturnCRef__carbon_thunk.call = call ptr @_Z10ReturnCRef10ForceThunk.carbon_thunk0(), !dbg !16
  479. // CHECK:STDOUT: store ptr %ReturnCRef__carbon_thunk.call, ptr %c1.var, align 8, !dbg !10
  480. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c2.var), !dbg !11
  481. // CHECK:STDOUT: %ReturnCRRef__carbon_thunk.call = call ptr @_Z11ReturnCRRef10ForceThunk.carbon_thunk0(), !dbg !17
  482. // CHECK:STDOUT: store ptr %ReturnCRRef__carbon_thunk.call, ptr %c2.var, align 8, !dbg !11
  483. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %c3.var), !dbg !12
  484. // CHECK:STDOUT: %ReturnConstCRef__carbon_thunk.call = call ptr @_Z15ReturnConstCRef10ForceThunk.carbon_thunk0(), !dbg !18
  485. // CHECK:STDOUT: store ptr %ReturnConstCRef__carbon_thunk.call, ptr %c3.var, align 8, !dbg !12
  486. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n1.var), !dbg !13
  487. // CHECK:STDOUT: %ReturnIntRef__carbon_thunk.call = call ptr @_Z12ReturnIntRef10ForceThunk.carbon_thunk0(), !dbg !19
  488. // CHECK:STDOUT: store ptr %ReturnIntRef__carbon_thunk.call, ptr %n1.var, align 8, !dbg !13
  489. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n2.var), !dbg !14
  490. // CHECK:STDOUT: %ReturnIntRRef__carbon_thunk.call = call ptr @_Z13ReturnIntRRef10ForceThunk.carbon_thunk0(), !dbg !20
  491. // CHECK:STDOUT: store ptr %ReturnIntRRef__carbon_thunk.call, ptr %n2.var, align 8, !dbg !14
  492. // CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n3.var), !dbg !15
  493. // CHECK:STDOUT: %ReturnConstIntRef__carbon_thunk.call = call ptr @_Z17ReturnConstIntRef10ForceThunk.carbon_thunk0(), !dbg !21
  494. // CHECK:STDOUT: store ptr %ReturnConstIntRef__carbon_thunk.call, ptr %n3.var, align 8, !dbg !15
  495. // CHECK:STDOUT: ret void, !dbg !22
  496. // CHECK:STDOUT: }
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
  499. // CHECK:STDOUT: declare void @llvm.lifetime.start.p0(ptr captures(none)) #1
  500. // CHECK:STDOUT:
  501. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  502. // CHECK:STDOUT: define dso_local nonnull align 1 dereferenceable(1) ptr @_Z10ReturnCRef10ForceThunk.carbon_thunk0() #2 {
  503. // CHECK:STDOUT: entry:
  504. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  505. // CHECK:STDOUT: %call = call nonnull align 1 dereferenceable(1) ptr @_Z10ReturnCRef10ForceThunk()
  506. // CHECK:STDOUT: ret ptr %call
  507. // CHECK:STDOUT: }
  508. // CHECK:STDOUT:
  509. // CHECK:STDOUT: declare nonnull align 1 dereferenceable(1) ptr @_Z10ReturnCRef10ForceThunk() #3
  510. // CHECK:STDOUT:
  511. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  512. // CHECK:STDOUT: define dso_local nonnull align 1 dereferenceable(1) ptr @_Z11ReturnCRRef10ForceThunk.carbon_thunk0() #2 {
  513. // CHECK:STDOUT: entry:
  514. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  515. // CHECK:STDOUT: %call = call nonnull align 1 dereferenceable(1) ptr @_Z11ReturnCRRef10ForceThunk()
  516. // CHECK:STDOUT: ret ptr %call
  517. // CHECK:STDOUT: }
  518. // CHECK:STDOUT:
  519. // CHECK:STDOUT: declare nonnull align 1 dereferenceable(1) ptr @_Z11ReturnCRRef10ForceThunk() #3
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  522. // CHECK:STDOUT: define dso_local nonnull align 1 dereferenceable(1) ptr @_Z15ReturnConstCRef10ForceThunk.carbon_thunk0() #2 {
  523. // CHECK:STDOUT: entry:
  524. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  525. // CHECK:STDOUT: %call = call nonnull align 1 dereferenceable(1) ptr @_Z15ReturnConstCRef10ForceThunk()
  526. // CHECK:STDOUT: ret ptr %call
  527. // CHECK:STDOUT: }
  528. // CHECK:STDOUT:
  529. // CHECK:STDOUT: declare nonnull align 1 dereferenceable(1) ptr @_Z15ReturnConstCRef10ForceThunk() #3
  530. // CHECK:STDOUT:
  531. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  532. // CHECK:STDOUT: define dso_local nonnull align 4 dereferenceable(4) ptr @_Z12ReturnIntRef10ForceThunk.carbon_thunk0() #2 {
  533. // CHECK:STDOUT: entry:
  534. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  535. // CHECK:STDOUT: %call = call nonnull align 4 dereferenceable(4) ptr @_Z12ReturnIntRef10ForceThunk()
  536. // CHECK:STDOUT: ret ptr %call
  537. // CHECK:STDOUT: }
  538. // CHECK:STDOUT:
  539. // CHECK:STDOUT: declare nonnull align 4 dereferenceable(4) ptr @_Z12ReturnIntRef10ForceThunk() #3
  540. // CHECK:STDOUT:
  541. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  542. // CHECK:STDOUT: define dso_local nonnull align 4 dereferenceable(4) ptr @_Z13ReturnIntRRef10ForceThunk.carbon_thunk0() #2 {
  543. // CHECK:STDOUT: entry:
  544. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  545. // CHECK:STDOUT: %call = call nonnull align 4 dereferenceable(4) ptr @_Z13ReturnIntRRef10ForceThunk()
  546. // CHECK:STDOUT: ret ptr %call
  547. // CHECK:STDOUT: }
  548. // CHECK:STDOUT:
  549. // CHECK:STDOUT: declare nonnull align 4 dereferenceable(4) ptr @_Z13ReturnIntRRef10ForceThunk() #3
  550. // CHECK:STDOUT:
  551. // CHECK:STDOUT: ; Function Attrs: alwaysinline mustprogress
  552. // CHECK:STDOUT: define dso_local nonnull align 4 dereferenceable(4) ptr @_Z17ReturnConstIntRef10ForceThunk.carbon_thunk0() #2 {
  553. // CHECK:STDOUT: entry:
  554. // CHECK:STDOUT: %agg.tmp = alloca %class.ForceThunk, align 1
  555. // CHECK:STDOUT: %call = call nonnull align 4 dereferenceable(4) ptr @_Z17ReturnConstIntRef10ForceThunk()
  556. // CHECK:STDOUT: ret ptr %call
  557. // CHECK:STDOUT: }
  558. // CHECK:STDOUT:
  559. // CHECK:STDOUT: declare nonnull align 4 dereferenceable(4) ptr @_Z17ReturnConstIntRef10ForceThunk() #3
  560. // CHECK:STDOUT:
  561. // CHECK:STDOUT: ; uselistorder directives
  562. // CHECK:STDOUT: uselistorder ptr @llvm.lifetime.start.p0, { 5, 4, 3, 2, 1, 0 }
  563. // CHECK:STDOUT:
  564. // CHECK:STDOUT: attributes #0 = { nounwind }
  565. // CHECK:STDOUT: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
  566. // CHECK:STDOUT: attributes #2 = { alwaysinline mustprogress "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="0" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  567. // CHECK:STDOUT: attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="0" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
  568. // CHECK:STDOUT:
  569. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
  570. // CHECK:STDOUT: !llvm.dbg.cu = !{!5}
  571. // CHECK:STDOUT:
  572. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  573. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  574. // CHECK:STDOUT: !2 = !{i32 1, !"wchar_size", i32 4}
  575. // CHECK:STDOUT: !3 = !{i32 8, !"PIC Level", i32 0}
  576. // CHECK:STDOUT: !4 = !{i32 7, !"PIE Level", i32 2}
  577. // CHECK:STDOUT: !5 = distinct !DICompileUnit(language: DW_LANG_C, file: !6, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  578. // CHECK:STDOUT: !6 = !DIFile(filename: "return_references_via_thunk.carbon", directory: "")
  579. // CHECK:STDOUT: !7 = distinct !DISubprogram(name: "GetRefs", linkageName: "_CGetRefs.Main", scope: null, file: !6, line: 17, type: !8, spFlags: DISPFlagDefinition, unit: !5)
  580. // CHECK:STDOUT: !8 = !DISubroutineType(types: !9)
  581. // CHECK:STDOUT: !9 = !{}
  582. // CHECK:STDOUT: !10 = !DILocation(line: 18, column: 3, scope: !7)
  583. // CHECK:STDOUT: !11 = !DILocation(line: 19, column: 3, scope: !7)
  584. // CHECK:STDOUT: !12 = !DILocation(line: 20, column: 3, scope: !7)
  585. // CHECK:STDOUT: !13 = !DILocation(line: 22, column: 3, scope: !7)
  586. // CHECK:STDOUT: !14 = !DILocation(line: 23, column: 3, scope: !7)
  587. // CHECK:STDOUT: !15 = !DILocation(line: 24, column: 3, scope: !7)
  588. // CHECK:STDOUT: !16 = !DILocation(line: 18, column: 20, scope: !7)
  589. // CHECK:STDOUT: !17 = !DILocation(line: 19, column: 20, scope: !7)
  590. // CHECK:STDOUT: !18 = !DILocation(line: 20, column: 26, scope: !7)
  591. // CHECK:STDOUT: !19 = !DILocation(line: 22, column: 18, scope: !7)
  592. // CHECK:STDOUT: !20 = !DILocation(line: 23, column: 18, scope: !7)
  593. // CHECK:STDOUT: !21 = !DILocation(line: 24, column: 24, scope: !7)
  594. // CHECK:STDOUT: !22 = !DILocation(line: 17, column: 1, scope: !7)