[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Lightning] [BUG] [AMD64 ABI] %r12 not preserved and restored in trampol
From: |
Marc Nieper-Wißkirchen |
Subject: |
[Lightning] [BUG] [AMD64 ABI] %r12 not preserved and restored in trampoline function prolog/epilog |
Date: |
Thu, 12 Sep 2019 08:38:43 +0200 |
Hi Paulo,
when creating a function prolog and epilogue for a trampoline function
as this one
prolog
frame (...)
...
epilog
GNU lightning saves all callee-save registers in the prolog and
restores them in the epilog. On the Unix port of x86_64, however, it
fails to save and restore %r12, which is a callee-saved register.
(This error has led to subtle bugs when I compiled my code with "-O2"
and gcc began to use %r12 and expected it to be preserved over a call
into a GNU lightning trampoline.)
The error maybe related to the fact that on GNU lightning, %r12 is
mapped to JIT_R3, which appears as a caller-save register to the user.
See also this discussion here:
https://lists.gnu.org/archive/html/lightning/2017-09/msg00006.html
I'd suggest to apply the patch of this discussion so that %r12 is
treated like %13, %r14, %15 and will be automatically saved in the
prolog and restored in the epilog. The side effect will be that JIT_R3
goes away and JIT_V4 appears.
If you don't want this, the bug has to be fixed differently by
patching the _prolog and _epilog procedures.
In any case, a fix of this bug is urgent because it is a critical one
(as non-ABI-conforming code is produced).
Thanks,
Marc
- [Lightning] [BUG] [AMD64 ABI] %r12 not preserved and restored in trampoline function prolog/epilog,
Marc Nieper-Wißkirchen <=