@@ -7,7 +7,10 @@ use rustc_middle::mir::{Body, Local, UnwindTerminateReason, traversal};
77use rustc_middle:: ty:: layout:: { FnAbiOf , HasTyCtxt , HasTypingEnv , TyAndLayout } ;
88use rustc_middle:: ty:: { self , Instance , Ty , TyCtxt , TypeVisitableExt } ;
99use rustc_middle:: { bug, mir, span_bug} ;
10- use rustc_mir_transform:: { add_call_guards, dump_mir, pass_manager} ;
10+ use rustc_mir_transform:: {
11+ add_call_guards, dump_mir, pass_manager, remove_noop_landing_pads, remove_unneeded_drops,
12+ remove_zsts, simplify, simplify_branches, unreachable_enum_branching, unreachable_prop,
13+ } ;
1114use rustc_target:: callconv:: { FnAbi , PassMode } ;
1215use tracing:: { debug, instrument} ;
1316
@@ -172,6 +175,15 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
172175 cx. tcx ( ) ,
173176 & mut mir,
174177 & [
178+ // Monomorphization may introduce ZST, non-drop and uninhabited types.
179+ & remove_zsts:: RemoveZsts ,
180+ & remove_unneeded_drops:: RemoveUnneededDrops ,
181+ & unreachable_enum_branching:: UnreachableEnumBranching ,
182+ & unreachable_prop:: UnreachablePropagation ,
183+ & remove_noop_landing_pads:: RemoveNoopLandingPads ,
184+ & simplify_branches:: SimplifyConstCondition :: Monomorphic ,
185+ & simplify:: SimplifyCfg :: Monomorphic ,
186+ & simplify:: SimplifyLocals :: Monomorphic ,
175187 // Some cleanup necessary at least for LLVM and potentially other codegen backends.
176188 & add_call_guards:: CriticalCallEdges ,
177189 // Dump the end result for testing and debugging purposes.
0 commit comments