Skip to content
Snippets Groups Projects
Commit 11ecdf2e authored by Damien George's avatar Damien George
Browse files

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.
parent 0c80cb39
No related branches found
No related tags found
No related merge requests found
...@@ -108,7 +108,7 @@ NORETURN void nlr_jump(void *val) { ...@@ -108,7 +108,7 @@ NORETURN void nlr_jump(void *val) {
: // clobbered registers : // clobbered registers
); );
for (;;); // needed to silence compiler warning MP_UNREACHABLE
} }
#endif // MICROPY_NLR_X64 #endif // MICROPY_NLR_X64
...@@ -100,7 +100,7 @@ NORETURN void nlr_jump(void *val) { ...@@ -100,7 +100,7 @@ NORETURN void nlr_jump(void *val) {
: // clobbered registers : // clobbered registers
); );
for (;;); // needed to silence compiler warning MP_UNREACHABLE
} }
#endif // MICROPY_NLR_X86 #endif // MICROPY_NLR_X86
...@@ -77,7 +77,7 @@ NORETURN void nlr_jump(void *val) { ...@@ -77,7 +77,7 @@ NORETURN void nlr_jump(void *val) {
: // clobbered registers : // clobbered registers
); );
for (;;); // needed to silence compiler warning MP_UNREACHABLE
} }
#endif // MICROPY_NLR_XTENSA #endif // MICROPY_NLR_XTENSA
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment