From f35e59d631679a6253406863bb7604b80c728553 Mon Sep 17 00:00:00 2001 From: Gerard Gorman Date: Thu, 4 Jun 2026 10:48:47 +0100 Subject: [PATCH] compiler: Guard cond_mapper lookup in halo hoisting _hoist_redundant_from_conditionals iterated every halo_spot from _filter_iter_mapper and did an unguarded cond_mapper[hs0], which raised KeyError for a nested HaloSpot (one whose subtree contains another HaloSpot), since _make_cond_mapper does not register nested HaloSpots as keys. Use the defensive cond_mapper.get(hs0) (as already done in _merge_halospots); the existing 'if not conditions: continue' handles the absent-key case. Fixes #2943. --- devito/passes/iet/mpi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devito/passes/iet/mpi.py b/devito/passes/iet/mpi.py index 2de99ee002..a653d154b6 100644 --- a/devito/passes/iet/mpi.py +++ b/devito/passes/iet/mpi.py @@ -88,7 +88,7 @@ def _hoist_redundant_from_conditionals(iet): scope = Scope(e.expr for e in FindNodes(Expression).visit(it)) for hs0 in halo_spots: - conditions = cond_mapper[hs0] + conditions = cond_mapper.get(hs0) if not conditions: continue condition = conditions[-1] # Take the innermost Conditional