Skip to content

Incorporate GCC9 fixes from upstream #2380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 12, 2019

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Dec 12, 2019

Thanks to @dpgeorge for the fixes upstream. Thanks to @jerryneedell for finding the issue and @dhalbert for finding the related topics upstream.

Fixes #2378

And use it to replace the same pattern at the end of nlrthumb.c:nlr_jump.
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.
These s16-s21 registers are used by gcc so need to be saved.  Future
versions of gcc (beyond v9.1.0), or other compilers, may eventually need
additional registers saved/restored.

See issue micropython#4844.
@tannewt tannewt added this to the 5.x.x - Bug Fixes milestone Dec 12, 2019
@tannewt tannewt requested a review from dhalbert December 12, 2019 19:13
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo! Fast bug to fix (big thanks to @dpgeorge).

@dhalbert dhalbert merged commit f140463 into adafruit:master Dec 12, 2019
@dpgeorge
Copy link

Yeah, this was a tricky one to track down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

beta.1 crashes after ctrl-d after exception in REPL
3 participants