|
56 | 56 | shared_lib_name, |
57 | 57 | short_id_from_name, |
58 | 58 | ) |
| 59 | +from mypyc.crash import catch_errors |
59 | 60 | from mypyc.errors import Errors |
60 | 61 | from mypyc.ir.deps import ( |
61 | 62 | LIBRT_BASE64, |
@@ -259,29 +260,31 @@ def compile_scc_to_ir( |
259 | 260 | env_user_functions[cls.env_user_function] = cls |
260 | 261 |
|
261 | 262 | for module in modules.values(): |
| 263 | + module_path = result.graph[module.fullname].xpath |
262 | 264 | for fn in module.functions: |
263 | | - # Insert checks for uninitialized values. |
264 | | - insert_uninit_checks(fn, compiler_options.strict_traceback_checks) |
265 | | - # Insert exception handling. |
266 | | - insert_exception_handling(fn, compiler_options.strict_traceback_checks) |
267 | | - # Insert reference count handling. |
268 | | - insert_ref_count_opcodes(fn) |
269 | | - |
270 | | - if fn in env_user_functions: |
271 | | - insert_spills(fn, env_user_functions[fn]) |
272 | | - |
273 | | - if compiler_options.log_trace: |
274 | | - insert_event_trace_logging(fn, compiler_options) |
275 | | - |
276 | | - # Switch to lower abstraction level IR. |
277 | | - lower_ir(fn, compiler_options) |
278 | | - # Calculate implicit module dependencies (needed for librt) |
279 | | - deps = find_implicit_op_dependencies(fn) |
280 | | - if deps is not None: |
281 | | - module.dependencies.update(deps) |
282 | | - # Perform optimizations. |
283 | | - do_copy_propagation(fn, compiler_options) |
284 | | - do_flag_elimination(fn, compiler_options) |
| 265 | + with catch_errors(module_path, fn.line): |
| 266 | + # Insert checks for uninitialized values. |
| 267 | + insert_uninit_checks(fn, compiler_options.strict_traceback_checks) |
| 268 | + # Insert exception handling. |
| 269 | + insert_exception_handling(fn, compiler_options.strict_traceback_checks) |
| 270 | + # Insert reference count handling. |
| 271 | + insert_ref_count_opcodes(fn) |
| 272 | + |
| 273 | + if fn in env_user_functions: |
| 274 | + insert_spills(fn, env_user_functions[fn]) |
| 275 | + |
| 276 | + if compiler_options.log_trace: |
| 277 | + insert_event_trace_logging(fn, compiler_options) |
| 278 | + |
| 279 | + # Switch to lower abstraction level IR. |
| 280 | + lower_ir(fn, compiler_options) |
| 281 | + # Calculate implicit module dependencies (needed for librt) |
| 282 | + deps = find_implicit_op_dependencies(fn) |
| 283 | + if deps is not None: |
| 284 | + module.dependencies.update(deps) |
| 285 | + # Perform optimizations. |
| 286 | + do_copy_propagation(fn, compiler_options) |
| 287 | + do_flag_elimination(fn, compiler_options) |
285 | 288 |
|
286 | 289 | # Calculate implicit dependencies from class attribute types |
287 | 290 | for cl in module.classes: |
|
0 commit comments