@@ -145,12 +145,22 @@ impl Print {
145
145
}
146
146
}
147
147
148
- fn should_print ( & self , pass : & dyn OperationPass ) -> bool {
148
+ fn pass_filter ( & self , pass : & dyn OperationPass ) -> bool {
149
149
match & self . pass_filter {
150
150
PassFilter :: All => true ,
151
151
PassFilter :: Certain ( passes) => passes. iter ( ) . any ( |p| p == pass. name ( ) ) ,
152
152
}
153
153
}
154
+
155
+ fn should_print ( & self , pass : & dyn OperationPass , ir_changed : IRAfterPass ) -> bool {
156
+ let pass_filter = self . pass_filter ( pass) ;
157
+
158
+ // Always print, unless "only_when_modified" has been set and there have not been changes.
159
+ let modification_filter =
160
+ !matches ! ( ( ir_changed, self . only_when_modified) , ( IRAfterPass :: Unchanged , true ) ) ;
161
+
162
+ pass_filter && modification_filter
163
+ }
154
164
}
155
165
156
166
impl PassInstrumentation for Print {
@@ -160,20 +170,14 @@ impl PassInstrumentation for Print {
160
170
op : & OperationRef ,
161
171
changed : IRAfterPass ,
162
172
) {
163
- // Always print, unless "only_when_modified" has been set and there have not been changes.
164
- let print_when_changed = if self . only_when_modified && changed == IRAfterPass :: Unchanged {
165
- false
166
- } else {
167
- true
168
- } ;
169
- if self . should_print ( pass) && print_when_changed {
173
+ if self . should_print ( pass, changed) {
170
174
let op = op. borrow ( ) ;
171
175
self . print_ir ( op) ;
172
176
}
173
177
}
174
178
175
179
fn run_before_pass ( & mut self , pass : & dyn OperationPass , op : & OperationRef ) {
176
- if self . should_print ( pass) {
180
+ if self . pass_filter ( pass) {
177
181
let op = op. borrow ( ) ;
178
182
self . print_ir ( op) ;
179
183
}
0 commit comments