@@ -12,12 +12,10 @@ pub struct InstCombine;
1212
1313impl < ' tcx > MirPass < ' tcx > for InstCombine {
1414 fn run_pass ( & self , tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
15- let param_env = tcx. param_env ( body. source . def_id ( ) ) ;
1615 let ( basic_blocks, local_decls) = body. basic_blocks_and_local_decls_mut ( ) ;
17- let ctx = InstCombineContext { tcx, local_decls, param_env } ;
16+ let ctx = InstCombineContext { tcx, local_decls } ;
1817 for block in basic_blocks. iter_mut ( ) {
1918 for statement in block. statements . iter_mut ( ) {
20- ctx. combine_zst ( & statement. source_info , & mut statement. kind ) ;
2119 match statement. kind {
2220 StatementKind :: Assign ( box ( _place, ref mut rvalue) ) => {
2321 ctx. combine_bool_cmp ( & statement. source_info , rvalue) ;
@@ -34,7 +32,6 @@ impl<'tcx> MirPass<'tcx> for InstCombine {
3432struct InstCombineContext < ' tcx , ' a > {
3533 tcx : TyCtxt < ' tcx > ,
3634 local_decls : & ' a LocalDecls < ' tcx > ,
37- param_env : ty:: ParamEnv < ' tcx > ,
3835}
3936
4037impl < ' tcx , ' a > InstCombineContext < ' tcx , ' a > {
@@ -44,28 +41,6 @@ impl<'tcx, 'a> InstCombineContext<'tcx, 'a> {
4441 } )
4542 }
4643
47- /// Remove assignments to inhabited ZST places.
48- fn combine_zst ( & self , source_info : & SourceInfo , kind : & mut StatementKind < ' tcx > ) {
49- match kind {
50- StatementKind :: Assign ( box ( place, _) ) => {
51- let place_ty = place. ty ( self . local_decls , self . tcx ) . ty ;
52- if let Ok ( layout) = self . tcx . layout_of ( self . param_env . and ( place_ty) ) {
53- if layout. is_zst ( ) && !layout. abi . is_uninhabited ( ) {
54- if self . tcx . consider_optimizing ( || {
55- format ! (
56- "InstCombine ZST - Place: {:?} SourceInfo: {:?}" ,
57- place, source_info
58- )
59- } ) {
60- * kind = StatementKind :: Nop ;
61- }
62- }
63- }
64- }
65- _ => { }
66- }
67- }
68-
6944 /// Transform boolean comparisons into logical operations.
7045 fn combine_bool_cmp ( & self , source_info : & SourceInfo , rvalue : & mut Rvalue < ' tcx > ) {
7146 match rvalue {
0 commit comments