@@ -186,11 +186,30 @@ bool ci_lazy_methodst::operator()(
186
186
}
187
187
188
188
// Remove symbols for methods that were declared but never used:
189
- symbol_tablet keep_symbols;
189
+ symbol_tablet keep_symbols = filter_symbol_table (
190
+ symbol_table, method_bytecode, methods_already_populated);
191
+
190
192
// Manually keep @inflight_exception, as it is unused at this stage
191
193
// but will become used when the `remove_exceptions` pass is run:
192
194
keep_symbols.add (symbol_table.lookup_ref (INFLIGHT_EXCEPTION_VARIABLE_NAME));
193
195
196
+ debug () << " CI lazy methods: removed "
197
+ << symbol_table.symbols .size () - keep_symbols.symbols .size ()
198
+ << " unreachable methods and globals" << eom;
199
+
200
+ symbol_table.swap (keep_symbols);
201
+ return false ;
202
+ }
203
+
204
+ // / Only keep functions that have been converted and global variables that are
205
+ // / used in these functions.
206
+ // / \return new symbol table
207
+ symbol_tablet ci_lazy_methodst::filter_symbol_table (
208
+ const symbol_tablet &symbol_table,
209
+ const method_bytecodet &method_bytecode,
210
+ const std::unordered_set<irep_idt> &methods_already_populated)
211
+ {
212
+ symbol_tablet keep_symbols;
194
213
for (const auto &sym : symbol_table.symbols )
195
214
{
196
215
// Don't keep global variables (unless they're gathered below from a
@@ -213,14 +232,7 @@ bool ci_lazy_methodst::operator()(
213
232
}
214
233
keep_symbols.add (sym.second );
215
234
}
216
-
217
- debug () << " CI lazy methods: removed "
218
- << symbol_table.symbols .size () - keep_symbols.symbols .size ()
219
- << " unreachable methods and globals" << eom;
220
-
221
- symbol_table.swap (keep_symbols);
222
-
223
- return false ;
235
+ return keep_symbols;
224
236
}
225
237
226
238
// / Look for virtual callsites with no candidate targets. If we have
0 commit comments