Skip to content

Commit 336bbc8

Browse files
committed
Fix type derivation of CATCHI
1 parent ba3729a commit 336bbc8

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

BIR-transformations/meta-evaluate.lisp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,29 @@
176176
;;; definitions, instead of narrowing the types conservatively.
177177
(defun compute-phi-type (phi system)
178178
(let ((type (ctype:values-bottom system)))
179-
(set:doset (inp (bir:phi-inputs phi) type)
180-
(setq type (ctype:values-disjoin system type (bir:ctype inp))))))
179+
(set:doset (def (bir:definitions phi) type)
180+
(etypecase def
181+
((or bir:jump bir:unwind)
182+
(let* ((pos (position phi (bir:outputs def)))
183+
(inp (nth pos (bir:inputs def))))
184+
(setq type (ctype:values-disjoin system type (bir:ctype inp)))))
185+
(bir:catchi ; could be anything.
186+
(return-from compute-phi-type (ctype:values-top system)))))))
181187

182188
(defun derive-iblock-input-types (iblock system)
183189
(dolist (phi (bir:inputs iblock))
184190
(setf (bir:derived-type phi) (compute-phi-type phi system))))
185191

186192
(defun compute-phi-attributes (phi)
187193
(let ((attr t))
188-
(set:doset (inp (bir:phi-inputs phi) attr)
189-
(setq attr (attributes:meet-attributes attr (bir:attributes inp))))))
194+
(set:doset (def (bir:definitions phi) attr)
195+
(etypecase def
196+
((or bir:jump bir:unwind)
197+
(let* ((pos (position phi (bir:outputs def)))
198+
(inp (nth pos (bir:inputs def))))
199+
(setq attr (attributes:meet-attributes attr (bir:attributes inp)))))
200+
(bir:catchi
201+
(return-from compute-phi-attributes (attributes:default-attributes)))))))
190202

191203
(defun derive-iblock-input-attributes (iblock)
192204
(dolist (phi (bir:inputs iblock))

0 commit comments

Comments
 (0)