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]>
  • Loading branch information
dpgeorge committed Mar 25, 2024
1 parent 35b2edf commit 35f3f0a
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion py/nlraarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ NORETURN void nlr_jump(void *val) {
"ret \n"
:
: "r" (top)
:
: "memory"
);

MP_UNREACHABLE
Expand Down
2 changes: 1 addition & 1 deletion py/nlrmips.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ NORETURN void nlr_jump(void *val) {
"nop \n"
:
: "r" (top)
:
: "memory"
);
MP_UNREACHABLE
}
Expand Down
4 changes: 2 additions & 2 deletions py/nlrpowerpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ NORETURN void nlr_jump(void *val) {
"blr ;"
:
: "r" (&top->regs)
:
: "memory"
);

MP_UNREACHABLE;
Expand Down Expand Up @@ -203,7 +203,7 @@ NORETURN void nlr_jump(void *val) {
"blr ;"
:
: "r" (&top->regs)
:
: "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 @@ -123,7 +123,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 35f3f0a

Please sign in to comment.