[Git][ghc/ghc][master] CmmToC: emit __builtin_unreachable() after noreturn ccalls

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Mon Sep 19 13:07:57 UTC 2022



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00
CmmToC: emit __builtin_unreachable() after noreturn ccalls

Emit a __builtin_unreachable() call after a foreign call marked as
CmmNeverReturns. This is crucial to generate correctly typed code for
wasm; as for other archs, this is also beneficial for the C compiler
optimizations.

- - - - -


1 changed file:

- compiler/GHC/CmmToC.hs


Changes:

=====================================
compiler/GHC/CmmToC.hs
=====================================
@@ -251,7 +251,7 @@ pprStmt platform stmt =
                         -- can't add the @n suffix ourselves, because
                         -- it isn't valid C.
                 | CmmNeverReturns <- ret ->
-                    pprCall platform cast_fn cconv hresults hargs <> semi
+                    pprCall platform cast_fn cconv hresults hargs <> semi <> text "__builtin_unreachable();"
                 | not (isMathFun lbl) ->
                     pprForeignCall platform (pprCLabel platform CStyle lbl) cconv hresults hargs
               _ ->



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1e1ed8c5224a2a2d8ccf502da08a24ce71fd5ac6

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1e1ed8c5224a2a2d8ccf502da08a24ce71fd5ac6
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220919/e0702941/attachment-0001.html>


More information about the ghc-commits mailing list