Skip to content

Commit

Permalink
py/nlr: Add "memory" to asm clobbers list in nlr_jump.
Browse files Browse the repository at this point in the history
Newer versions of gcc (14 and up) have more sophisticated dead-code
detection, and the asm clobbers list needs to contain "memory" to inform
the compiler that the asm code actually does something.

Tested that adding this "memory" line does not change the generated code on
ARM Thumb2, x86-64 and Xtensa targets (using gcc 13.2).

Fixes issue micropython#14115.

Signed-off-by: Damien George <[email protected]>

(cherry picked from commit 35f3f0a)
  • Loading branch information
dpgeorge authored and mmilata committed Nov 27, 2024
1 parent d2d9706 commit 0d53dd7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion py/nlraarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ NORETURN void nlr_jump(void *val) {
"ret \n"
:
: "r" (top)
:
: "memory"
);

MP_UNREACHABLE
Expand Down
2 changes: 1 addition & 1 deletion py/nlrthumb.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ NORETURN void nlr_jump(void *val) {
"bx lr \n" // return
: // output operands
: "r" (top) // input operands
: // clobbered registers
: "memory" // clobbered registers
);

MP_UNREACHABLE
Expand Down
2 changes: 1 addition & 1 deletion py/nlrx64.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ NORETURN void nlr_jump(void *val) {
"ret \n" // return
: // output operands
: "r" (top) // input operands
: // clobbered registers
: "memory" // clobbered registers
);

MP_UNREACHABLE
Expand Down
2 changes: 1 addition & 1 deletion py/nlrx86.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ NORETURN void nlr_jump(void *val) {
"ret \n" // return
: // output operands
: "r" (top) // input operands
: // clobbered registers
: "memory" // clobbered registers
);

MP_UNREACHABLE
Expand Down
2 changes: 1 addition & 1 deletion py/nlrxtensa.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ NORETURN void nlr_jump(void *val) {
"ret.n \n" // return
: // output operands
: "r" (top) // input operands
: // clobbered registers
: "memory" // clobbered registers
);

MP_UNREACHABLE
Expand Down

0 comments on commit 0d53dd7

Please sign in to comment.