@@ -7,6 +7,7 @@ use rustc_middle::mir::{traversal, UnwindTerminateReason};
7
7
use rustc_middle:: ty:: layout:: { FnAbiOf , HasTyCtxt , TyAndLayout } ;
8
8
use rustc_middle:: ty:: { self , Instance , Ty , TypeVisitableExt } ;
9
9
use rustc_middle:: { bug, mir, span_bug} ;
10
+ use rustc_mir_transform:: { add_call_guards, dump_mir, pass_manager} ;
10
11
use rustc_target:: abi:: call:: { FnAbi , PassMode } ;
11
12
use tracing:: { debug, instrument} ;
12
13
@@ -152,11 +153,23 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
152
153
153
154
let llfn = cx. get_fn ( instance) ;
154
155
155
- let mir = & instance. instantiate_mir_and_normalize_erasing_regions (
156
+ let mut mir = instance. instantiate_mir_and_normalize_erasing_regions (
156
157
cx. tcx ( ) ,
157
158
ty:: ParamEnv :: reveal_all ( ) ,
158
159
ty:: EarlyBinder :: bind ( cx. tcx ( ) . instance_mir ( instance. def ) . clone ( ) ) ,
159
160
) ;
161
+ pass_manager:: run_passes (
162
+ cx. tcx ( ) ,
163
+ & mut mir,
164
+ & [
165
+ // Some cleanup necessary at least for LLVM and potentially other codegen backends.
166
+ & add_call_guards:: CriticalCallEdges ,
167
+ // Dump the end result for testing and debugging purposes.
168
+ & dump_mir:: Marker ( "Monomorphic" ) ,
169
+ ] ,
170
+ Some ( mir:: MirPhase :: Runtime ( mir:: RuntimePhase :: Monomorphic ) ) ,
171
+ ) ;
172
+ let mir = & mir;
160
173
161
174
let fn_abi = cx. fn_abi_of_instance ( instance, ty:: List :: empty ( ) ) ;
162
175
debug ! ( "fn_abi: {:?}" , fn_abi) ;
0 commit comments