tree: d5de9cf6b0d399a3e847d629be93fbe0ab6dae43 [path history] [tgz]
  1. building/
  2. const_prop/
  3. copy-prop/
  4. dataflow-const-prop/
  5. dead-store-elimination/
  6. deref-patterns/
  7. dest-prop/
  8. inline/
  9. issues/
  10. nll/
  11. pre-codegen/
  12. sroa/
  13. address_of.address_of_reborrow.SimplifyCfg-initial.after.mir
  14. address_of.borrow_and_cast.SimplifyCfg-initial.after.mir
  15. address_of.rs
  16. array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir
  17. array_index_is_temporary.rs
  18. asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir
  19. asm_unwind_panic_abort.rs
  20. basic_assignment.main.ElaborateDrops.diff
  21. basic_assignment.main.SimplifyCfg-initial.after.mir
  22. basic_assignment.rs
  23. bool_compare.opt1.InstSimplify.diff
  24. bool_compare.opt2.InstSimplify.diff
  25. bool_compare.opt3.InstSimplify.diff
  26. bool_compare.opt4.InstSimplify.diff
  27. bool_compare.rs
  28. box_expr.main.ElaborateDrops.before.mir
  29. box_expr.rs
  30. byte_slice.main.SimplifyCfg-elaborate-drops.after.mir
  31. byte_slice.rs
  32. casts.redundant.InstSimplify.diff
  33. casts.redundant.PreCodegen.after.mir
  34. casts.roundtrip.PreCodegen.after.mir
  35. casts.rs
  36. combine_array_len.norm2.InstSimplify.diff
  37. combine_array_len.rs
  38. combine_clone_of_primitives.rs
  39. combine_clone_of_primitives.{impl#0}-clone.InstSimplify.diff
  40. combine_transmutes.adt_transmutes.InstSimplify.diff
  41. combine_transmutes.identity_transmutes.InstSimplify.diff
  42. combine_transmutes.integer_transmutes.InstSimplify.diff
  43. combine_transmutes.rs
  44. const_allocation.main.ConstProp.after.32bit.mir
  45. const_allocation.main.ConstProp.after.64bit.mir
  46. const_allocation.rs
  47. const_allocation2.main.ConstProp.after.32bit.mir
  48. const_allocation2.main.ConstProp.after.64bit.mir
  49. const_allocation2.rs
  50. const_allocation3.main.ConstProp.after.32bit.mir
  51. const_allocation3.main.ConstProp.after.64bit.mir
  52. const_allocation3.rs
  53. const_debuginfo.main.ConstDebugInfo.diff
  54. const_debuginfo.rs
  55. const_goto.issue_77355_opt.ConstGoto.diff
  56. const_goto.rs
  57. const_goto_const_eval_fail.f.ConstGoto.diff
  58. const_goto_const_eval_fail.rs
  59. const_goto_storage.match_nested_if.ConstGoto.diff
  60. const_goto_storage.rs
  61. const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir
  62. const_promotion_extern_static.BAR.PromoteTemps.diff
  63. const_promotion_extern_static.BOP.built.after.mir
  64. const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir
  65. const_promotion_extern_static.FOO.PromoteTemps.diff
  66. const_promotion_extern_static.rs
  67. const_prop_miscompile.bar.ConstProp.diff
  68. const_prop_miscompile.foo.ConstProp.diff
  69. const_prop_miscompile.rs
  70. coverage_graphviz.bar.InstrumentCoverage.0.dot
  71. coverage_graphviz.main.InstrumentCoverage.0.dot
  72. coverage_graphviz.rs
  73. deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff
  74. deduplicate_blocks.rs
  75. derefer_complex_case.main.Derefer.diff
  76. derefer_complex_case.rs
  77. derefer_inline_test.main.Derefer.diff
  78. derefer_inline_test.rs
  79. derefer_terminator_test.main.Derefer.diff
  80. derefer_terminator_test.rs
  81. derefer_test.main.Derefer.diff
  82. derefer_test.rs
  83. derefer_test_multiple.main.Derefer.diff
  84. derefer_test_multiple.rs
  85. dont_yeet_assert.generic.InstSimplify.diff
  86. dont_yeet_assert.rs
  87. early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff
  88. early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff
  89. early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff
  90. early_otherwise_branch.rs
  91. early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff
  92. early_otherwise_branch_3_element_tuple.rs
  93. early_otherwise_branch_68867.rs
  94. early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff
  95. early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff
  96. early_otherwise_branch_noopt.rs
  97. early_otherwise_branch_soundness.no_deref_ptr.EarlyOtherwiseBranch.diff
  98. early_otherwise_branch_soundness.no_downcast.EarlyOtherwiseBranch.diff
  99. early_otherwise_branch_soundness.rs
  100. enum_opt.cand.EnumSizeOpt.32bit.diff
  101. enum_opt.cand.EnumSizeOpt.64bit.diff
  102. enum_opt.invalid.EnumSizeOpt.32bit.diff
  103. enum_opt.invalid.EnumSizeOpt.64bit.diff
  104. enum_opt.rs
  105. enum_opt.trunc.EnumSizeOpt.32bit.diff
  106. enum_opt.trunc.EnumSizeOpt.64bit.diff
  107. enum_opt.unin.EnumSizeOpt.32bit.diff
  108. enum_opt.unin.EnumSizeOpt.64bit.diff
  109. equal_true.opt.InstSimplify.diff
  110. equal_true.rs
  111. exponential_or.match_tuple.SimplifyCfg-initial.after.mir
  112. exponential_or.rs
  113. fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir
  114. fn_ptr_shim.rs
  115. funky_arms.float_to_exponential_common.ConstProp.diff
  116. funky_arms.rs
  117. generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir
  118. generator_drop_cleanup.rs
  119. generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir
  120. generator_storage_dead_unwind.rs
  121. generator_tiny.main-{closure#0}.generator_resume.0.mir
  122. generator_tiny.rs
  123. graphviz.main.built.after.dot
  124. graphviz.rs
  125. if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff
  126. if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff
  127. if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff
  128. if_condition_int.opt_char.SimplifyComparisonIntegral.diff
  129. if_condition_int.opt_i8.SimplifyComparisonIntegral.diff
  130. if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff
  131. if_condition_int.opt_negative.SimplifyComparisonIntegral.diff
  132. if_condition_int.opt_u32.SimplifyComparisonIntegral.diff
  133. if_condition_int.rs
  134. instrument_coverage.bar.InstrumentCoverage.diff
  135. instrument_coverage.main.InstrumentCoverage.diff
  136. instrument_coverage.rs
  137. instsimplify_duplicate_switch_targets.assert_zero.InstSimplify.diff
  138. instsimplify_duplicate_switch_targets.rs
  139. intrinsic_asserts.generic.InstSimplify.diff
  140. intrinsic_asserts.panics.InstSimplify.diff
  141. intrinsic_asserts.removable.InstSimplify.diff
  142. intrinsic_asserts.rs
  143. issue_101973.inner.ConstProp.diff
  144. issue_101973.rs
  145. issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.mir
  146. issue_104451_unwindable_intrinsics.rs
  147. issue_38669.main.SimplifyCfg-initial.after.mir
  148. issue_38669.rs
  149. issue_41110.main.ElaborateDrops.diff
  150. issue_41110.rs
  151. issue_41110.test.ElaborateDrops.diff
  152. issue_41697.rs
  153. issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir
  154. issue_41888.main.ElaborateDrops.diff
  155. issue_41888.rs
  156. issue_62289.rs
  157. issue_62289.test.ElaborateDrops.before.mir
  158. issue_72181.bar.built.after.mir
  159. issue_72181.foo.built.after.mir
  160. issue_72181.main.built.after.mir
  161. issue_72181.rs
  162. issue_72181_1.f.built.after.mir
  163. issue_72181_1.main.built.after.mir
  164. issue_72181_1.rs
  165. issue_76432.rs
  166. issue_76432.test.SimplifyComparisonIntegral.diff
  167. issue_78192.f.InstSimplify.diff
  168. issue_78192.rs
  169. issue_91633.bar.built.after.mir
  170. issue_91633.foo.built.after.mir
  171. issue_91633.fun.built.after.mir
  172. issue_91633.hey.built.after.mir
  173. issue_91633.rs
  174. issue_99325.main.built.after.mir
  175. issue_99325.rs
  176. loop_test.main.SimplifyCfg-promote-consts.after.mir
  177. loop_test.rs
  178. lower_array_len.array_bound.NormalizeArrayLen.diff
  179. lower_array_len.array_bound_mut.NormalizeArrayLen.diff
  180. lower_array_len.array_len.NormalizeArrayLen.diff
  181. lower_array_len.array_len_by_value.NormalizeArrayLen.diff
  182. lower_array_len.array_len_raw.NormalizeArrayLen.diff
  183. lower_array_len.array_len_reborrow.NormalizeArrayLen.diff
  184. lower_array_len.rs
  185. lower_intrinsics.align_of.LowerIntrinsics.diff
  186. lower_intrinsics.assume.LowerIntrinsics.diff
  187. lower_intrinsics.discriminant.LowerIntrinsics.diff
  188. lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff
  189. lower_intrinsics.forget.LowerIntrinsics.diff
  190. lower_intrinsics.non_const.LowerIntrinsics.diff
  191. lower_intrinsics.option_payload.LowerIntrinsics.diff
  192. lower_intrinsics.ptr_offset.LowerIntrinsics.diff
  193. lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff
  194. lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff
  195. lower_intrinsics.rs
  196. lower_intrinsics.size_of.LowerIntrinsics.diff
  197. lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff
  198. lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff
  199. lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff
  200. lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff
  201. lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff
  202. lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff
  203. lower_intrinsics.unreachable.LowerIntrinsics.diff
  204. lower_intrinsics.with_overflow.LowerIntrinsics.diff
  205. lower_intrinsics.wrapping.LowerIntrinsics.diff
  206. lower_intrinsics.write_via_move_string.LowerIntrinsics.diff
  207. lower_slice_len.bound.LowerSliceLenCalls.diff
  208. lower_slice_len.rs
  209. match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff
  210. match_arm_scopes.rs
  211. match_test.main.SimplifyCfg-initial.after.mir
  212. match_test.rs
  213. matches_reduce_branches.bar.MatchBranchSimplification.diff
  214. matches_reduce_branches.foo.MatchBranchSimplification.diff
  215. matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff
  216. matches_reduce_branches.rs
  217. matches_u8.exhaustive_match.MatchBranchSimplification.diff
  218. matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff
  219. matches_u8.rs
  220. multiple_return_terminators.rs
  221. multiple_return_terminators.test.MultipleReturnTerminators.diff
  222. no_drop_for_inactive_variant.rs
  223. no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir
  224. no_spurious_drop_after_call.main.ElaborateDrops.before.mir
  225. no_spurious_drop_after_call.rs
  226. not_equal_false.opt.InstSimplify.diff
  227. not_equal_false.rs
  228. nrvo_miscompile_111005.rs
  229. nrvo_miscompile_111005.wrong.RenameReturnPlace.diff
  230. nrvo_simple.nrvo.RenameReturnPlace.diff
  231. nrvo_simple.rs
  232. packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir
  233. packed_struct_drop_aligned.rs
  234. README.md
  235. reference_prop.debuginfo.ReferencePropagation.diff
  236. reference_prop.dominate_storage.ReferencePropagation.diff
  237. reference_prop.maybe_dead.ReferencePropagation.diff
  238. reference_prop.multiple_storage.ReferencePropagation.diff
  239. reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff
  240. reference_prop.read_through_raw.ReferencePropagation.diff
  241. reference_prop.reference_propagation.ReferencePropagation.diff
  242. reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff
  243. reference_prop.reference_propagation_mut.ReferencePropagation.diff
  244. reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff
  245. reference_prop.rs
  246. reference_prop.unique_with_copies.ReferencePropagation.diff
  247. remove_fake_borrows.match_guard.CleanupPostBorrowck.diff
  248. remove_fake_borrows.rs
  249. remove_never_const.no_codegen.PreCodegen.after.mir
  250. remove_never_const.rs
  251. remove_storage_markers.main.RemoveStorageMarkers.diff
  252. remove_storage_markers.rs
  253. remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff
  254. remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff
  255. remove_unneeded_drops.opt.RemoveUnneededDrops.diff
  256. remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff
  257. remove_unneeded_drops.rs
  258. remove_zsts.get_union.PreCodegen.after.mir
  259. remove_zsts.get_union.RemoveZsts.diff
  260. remove_zsts.rs
  261. retag.array_casts.SimplifyCfg-elaborate-drops.after.mir
  262. retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir
  263. retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir
  264. retag.main.SimplifyCfg-elaborate-drops.after.mir
  265. retag.rs
  266. retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.mir
  267. retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.mir
  268. return_an_array.rs
  269. separate_const_switch.identity.SeparateConstSwitch.diff
  270. separate_const_switch.rs
  271. separate_const_switch.too_complex.SeparateConstSwitch.diff
  272. simplify_arm.id_try.SimplifyArmIdentity.diff
  273. simplify_arm.id_try.SimplifyBranchSame.diff
  274. simplify_arm.rs
  275. simplify_arm_identity.rs
  276. simplify_cfg.main.SimplifyCfg-early-opt.diff
  277. simplify_cfg.main.SimplifyCfg-initial.diff
  278. simplify_cfg.rs
  279. simplify_duplicate_unreachable_blocks.assert_nonzero_nonmax.SimplifyCfg-after-uninhabited-enum-branching.diff
  280. simplify_duplicate_unreachable_blocks.rs
  281. simplify_if.main.SimplifyConstCondition-after-const-prop.diff
  282. simplify_if.rs
  283. simplify_locals.c.SimplifyLocals-before-const-prop.diff
  284. simplify_locals.d1.SimplifyLocals-before-const-prop.diff
  285. simplify_locals.d2.SimplifyLocals-before-const-prop.diff
  286. simplify_locals.expose_addr.SimplifyLocals-before-const-prop.diff
  287. simplify_locals.r.SimplifyLocals-before-const-prop.diff
  288. simplify_locals.rs
  289. simplify_locals.t1.SimplifyLocals-before-const-prop.diff
  290. simplify_locals.t2.SimplifyLocals-before-const-prop.diff
  291. simplify_locals.t3.SimplifyLocals-before-const-prop.diff
  292. simplify_locals.t4.SimplifyLocals-before-const-prop.diff
  293. simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff
  294. simplify_locals_fixedpoint.rs
  295. simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff
  296. simplify_locals_removes_unused_consts.rs
  297. simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff
  298. simplify_locals_removes_unused_discriminant_reads.rs
  299. simplify_match.main.ConstProp.diff
  300. simplify_match.rs
  301. simplify_try_if_let.rs
  302. simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff
  303. slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir
  304. slice_drop_shim.rs
  305. slice_filter.rs
  306. slice_filter.variant_a-{closure#0}.CopyProp.diff
  307. slice_filter.variant_a-{closure#0}.DestinationPropagation.diff
  308. slice_filter.variant_a-{closure#0}.ReferencePropagation.diff
  309. slice_filter.variant_b-{closure#0}.CopyProp.diff
  310. slice_filter.variant_b-{closure#0}.DestinationPropagation.diff
  311. slice_filter.variant_b-{closure#0}.ReferencePropagation.diff
  312. spanview_block.main.built.after.html
  313. spanview_block.rs
  314. spanview_statement.main.built.after.html
  315. spanview_statement.rs
  316. spanview_terminator.main.built.after.html
  317. spanview_terminator.rs
  318. storage_ranges.main.nll.0.mir
  319. storage_ranges.rs
  320. tls_access.main.PreCodegen.after.mir
  321. tls_access.rs
  322. uninhabited_enum.process_never.SimplifyLocals-final.after.mir
  323. uninhabited_enum.process_void.SimplifyLocals-final.after.mir
  324. uninhabited_enum.rs
  325. uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
  326. uninhabited_enum_branching.main.UninhabitedEnumBranching.diff
  327. uninhabited_enum_branching.rs
  328. uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
  329. uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff
  330. uninhabited_enum_branching2.rs
  331. uninhabited_fallthrough_elimination.eliminate_fallthrough.UninhabitedEnumBranching.diff
  332. uninhabited_fallthrough_elimination.keep_fallthrough.UninhabitedEnumBranching.diff
  333. uninhabited_fallthrough_elimination.rs
  334. unreachable.main.UnreachablePropagation.diff
  335. unreachable.rs
  336. unreachable_diverging.main.UnreachablePropagation.diff
  337. unreachable_diverging.rs
  338. unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir
  339. unusual_item_types.E-V-{constant#0}.built.after.mir
  340. unusual_item_types.rs
  341. unusual_item_types.Test-X-{constructor#0}.built.after.mir
  342. unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir
  343. while_storage.rs
  344. while_storage.while_loop.PreCodegen.after.mir
tests/mir-opt/README.md

This folder contains tests for MIR optimizations.

The mir-opt test format emits MIR to extra files that you can automatically update by specifying --bless on the command line (just like ui tests updating .stderr files).

--blessable test format

By default 32 bit and 64 bit targets use the same dump files, which can be problematic in the presence of pointers in constants or other bit width dependent things. In that case you can add

// EMIT_MIR_FOR_EACH_BIT_WIDTH

to your test, causing separate files to be generated for 32bit and 64bit systems.

Unit testing

If you are only testing the behavior of a particular mir-opt pass on some specific input (as is usually the case), you should add

// unit-test: PassName

to the top of the file. This makes sure that other passes don‘t run which means you’ll get the input you expected and your test won't break when other code changes.

Emit a diff of the mir for a specific optimization

This is what you want most often when you want to see how an optimization changes the MIR.

// EMIT_MIR $file_name_of_some_mir_dump.diff

Emit mir after a specific optimization

Use this if you are just interested in the final state after an optimization.

// EMIT_MIR $file_name_of_some_mir_dump.after.mir

Emit mir before a specific optimization

This exists mainly for completeness and is rarely useful.

// EMIT_MIR $file_name_of_some_mir_dump.before.mir