@@ -12,12 +12,10 @@ pub struct InstCombine;
12
12
13
13
impl < ' tcx > MirPass < ' tcx > for InstCombine {
14
14
fn run_pass ( & self , tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
15
- let param_env = tcx. param_env ( body. source . def_id ( ) ) ;
16
15
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 } ;
18
17
for block in basic_blocks. iter_mut ( ) {
19
18
for statement in block. statements . iter_mut ( ) {
20
- ctx. combine_zst ( & statement. source_info , & mut statement. kind ) ;
21
19
match statement. kind {
22
20
StatementKind :: Assign ( box ( _place, ref mut rvalue) ) => {
23
21
ctx. combine_bool_cmp ( & statement. source_info , rvalue) ;
@@ -34,7 +32,6 @@ impl<'tcx> MirPass<'tcx> for InstCombine {
34
32
struct InstCombineContext < ' tcx , ' a > {
35
33
tcx : TyCtxt < ' tcx > ,
36
34
local_decls : & ' a LocalDecls < ' tcx > ,
37
- param_env : ty:: ParamEnv < ' tcx > ,
38
35
}
39
36
40
37
impl < ' tcx , ' a > InstCombineContext < ' tcx , ' a > {
@@ -44,28 +41,6 @@ impl<'tcx, 'a> InstCombineContext<'tcx, 'a> {
44
41
} )
45
42
}
46
43
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
-
69
44
/// Transform boolean comparisons into logical operations.
70
45
fn combine_bool_cmp ( & self , source_info : & SourceInfo , rvalue : & mut Rvalue < ' tcx > ) {
71
46
match rvalue {
0 commit comments