- l@(G.LastJump {}) -> endblock $ with_out out l
- l@(G.LastReturn {}) -> endblock $ with_out out l
- l@(G.LastSwitch {}) -> endblock $ with_out out l
- l@(G.LastCall _ Nothing) -> endblock $ with_out out l
- l@(G.LastCall tgt (Just k))
- | Z.Block id' (Z.ZTail (G.CopyIn _ ress srt) t) : bs <- n,
- Just (conv, args) <- out,
- id' == k ->
- let call = CmmCall tgt' ress args (CmmSafe srt) CmmMayReturn
- tgt' = CmmCallee tgt (cconv_of_conv conv)
- ppcall = ppr call <+> parens (text "ret to" <+> ppr k)
- in if unique_pred k then
- tail id (ppcall : prev') Nothing t bs
- else
- endblock (ppcall)
- | Z.Block id' t : bs <- n, id' == k, unique_pred k,
- Just (conv, args) <- out,
- Just (ress, srt) <- findCopyIn t ->
- let call = CmmCall tgt' ress args (CmmSafe srt) CmmMayReturn
- tgt' = CmmCallee tgt (cconv_of_conv conv)
- delayed =
- ptext SLIT("// delayed CopyIn follows previous call")
- in tail id (delayed : ppr call : prev') Nothing t bs
- | otherwise -> endblock $ with_out out l
- findCopyIn (Z.ZTail (G.CopyIn _ ress srt) _) = Just (ress, srt)
- findCopyIn (Z.ZTail _ t) = findCopyIn t
- findCopyIn (Z.ZLast _) = Nothing
- exit id prev' out n = -- highly irregular (assertion violation?)