From 96a0b76b99507c50516f76b382322142f6ea11c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Lu=CC=88cke?= Date: Tue, 16 Jan 2024 11:19:27 +0100 Subject: [PATCH] Mark unsafe erasures as fail --- xdsl_pdl/analysis/pdl_analysis.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xdsl_pdl/analysis/pdl_analysis.py b/xdsl_pdl/analysis/pdl_analysis.py index e13900f..fce3b0c 100644 --- a/xdsl_pdl/analysis/pdl_analysis.py +++ b/xdsl_pdl/analysis/pdl_analysis.py @@ -46,6 +46,7 @@ class PDLAnalysisException(Exception): enable_prints = True allow_self_replacements = False +allow_unsafe_erasures = False warnings.simplefilter("ignore", category=PDLDebugWarning) @@ -571,6 +572,9 @@ def _analyze_rhs_op(self, rhs_op: Operation) -> AnalyzedPDLOperation | None: rhs_op, "pdl.Operation to be erased is not part of the matching DAG!", ) + if not allow_unsafe_erasures and analyzed_op not in self.generated_ops: + self._add_analysis_result_to_op(rhs_op, "unsafe erasure") + debug(f"unsafe erasure: {rhs_op}!") analyzed_op.erased_by = rhs_op else: raise PDLAnalysisException(rhs_op, f"Unsupported PDL op: {rhs_op.name}")