diff options
| author | Damien George <damien.p.george@gmail.com> | 2019-08-19 15:51:40 +1000 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2019-12-12 11:01:40 -0800 |
| commit | 1cf0ce094a4a1571b7404643e7a3b992592317a5 (patch) | |
| tree | 2197a11f6f2f99bed00812ba3cd65aa2ca837a54 /py | |
| parent | 63046d800d64081a4f7756476f5249179179ff5e (diff) | |
py/nlr: Use MP_UNREACHABLE at the end of arch-specific nlr_jump funcs.
Recent versions of gcc perform optimisations which can lead to the
following code from the MP_NLR_JUMP_HEAD macro being omitted:
top->ret_val = val; \
MP_NLR_RESTORE_PYSTACK(top); \
*_top_ptr = top->prev; \
This is noticeable (at least) in the unix coverage on x86-64 built with gcc
9.1.0. This is because the nlr_jump function is marked as no-return, so
gcc deduces that the above code has no effect.
Adding MP_UNREACHABLE tells the compiler that the asm code may branch
elsewhere, and so it cannot optimise away the code.
Diffstat (limited to 'py')
| -rw-r--r-- | py/nlrx64.c | 2 | ||||
| -rw-r--r-- | py/nlrx86.c | 2 | ||||
| -rw-r--r-- | py/nlrxtensa.c | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/py/nlrx64.c b/py/nlrx64.c index 9b2b22c22..569ad84fb 100644 --- a/py/nlrx64.c +++ b/py/nlrx64.c @@ -108,7 +108,7 @@ NORETURN void nlr_jump(void *val) { : // clobbered registers ); - for (;;); // needed to silence compiler warning + MP_UNREACHABLE } #endif // MICROPY_NLR_X64 diff --git a/py/nlrx86.c b/py/nlrx86.c index 4900a4c0d..6fbbe4432 100644 --- a/py/nlrx86.c +++ b/py/nlrx86.c @@ -100,7 +100,7 @@ NORETURN void nlr_jump(void *val) { : // clobbered registers ); - for (;;); // needed to silence compiler warning + MP_UNREACHABLE } #endif // MICROPY_NLR_X86 diff --git a/py/nlrxtensa.c b/py/nlrxtensa.c index d66c7a9a7..564035004 100644 --- a/py/nlrxtensa.c +++ b/py/nlrxtensa.c @@ -77,7 +77,7 @@ NORETURN void nlr_jump(void *val) { : // clobbered registers ); - for (;;); // needed to silence compiler warning + MP_UNREACHABLE } #endif // MICROPY_NLR_XTENSA |
