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