aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Lång <[email protected]>2018-01-19 16:05:52 +0100
committerMagnus Lång <[email protected]>2018-01-19 16:05:52 +0100
commit970261b5384bd55abdcbf55bd4a75a3c26a0bda8 (patch)
tree5e0f8231e24683d2c640fc369805e6bd4d921496
parent69de63049417cf7e047f035b5e086caad9dc7932 (diff)
downloadotp-970261b5384bd55abdcbf55bd4a75a3c26a0bda8.tar.gz
otp-970261b5384bd55abdcbf55bd4a75a3c26a0bda8.tar.bz2
otp-970261b5384bd55abdcbf55bd4a75a3c26a0bda8.zip
ErLLVM: Preserve precise BEAM tailcall semantics
The BEAM compiler chooses not to perform tailcall optimisations for some calls in tail position, for example to some built-in functions. However, when the ErLLVM HiPE backend is used, LLVM may choose to perform tailcall optimisation on these calls, breaking the expected semantics. To preserve the precise semantics exhibited by BEAM, the 'notail' marker, present in LLVM since version 3.8, is added to call instructions that BEAM has not turned into tail calls, which inhibits LLVM from performing tail-call optimisation in turn.
-rw-r--r--lib/hipe/llvm/hipe_llvm.erl2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/hipe/llvm/hipe_llvm.erl b/lib/hipe/llvm/hipe_llvm.erl
index 641d3fda0a..e04b171194 100644
--- a/lib/hipe/llvm/hipe_llvm.erl
+++ b/lib/hipe/llvm/hipe_llvm.erl
@@ -934,7 +934,7 @@ pp_ins(Dev, Ver, I) ->
end,
case call_is_tail(I) of
true -> write(Dev, "tail ");
- false -> ok
+ false -> write(Dev, "notail ")
end,
write(Dev, ["call ", call_cconv(I), " "]),
pp_options(Dev, call_ret_attrs(I)),