Skip to content

Commit 1e28ecb

Browse files
longjmp avoid clobbering r1, tail merge
1 parent 349e874 commit 1e28ecb

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

libc/src/setjmp/arm/longjmp.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,30 @@ LLVM_LIBC_FUNCTION(void, longjmp, (__jmp_buf * buf, int val)) {
2020
# Reload r4, r5, r6, r7.
2121
ldmia r0!, {r4, r5, r6, r7}
2222
23-
# Reload r8, r9, r10. They cannot appear in register lists so load them
23+
# Reload r8, r9. They cannot appear in register lists so load them
2424
# into the lower registers, then move them into place.
25-
ldmia r0!, {r1, r2, r3}
26-
mov r8, r1
27-
mov r9, r2
28-
mov r10, r3
25+
ldmia r0!, {r2, r3}
26+
mov r8, r2
27+
mov r9, r3
2928
30-
# Reload r11, sp, lr. They cannot appear in register lists so load them
29+
# Reload r10, r11. They cannot appear in register lists so load them
3130
# into the lower registers, then move them into place.
32-
ldmia r0!, {r1, r2, r3}
33-
mov r11, r1
31+
ldmia r0!, {r2, r3}
32+
mov r10, r2
33+
mov r11, r3
34+
35+
# Reload sp, lr. They cannot appear in register lists so load them
36+
# into the lower registers, then move them into place.
37+
ldmia r0!, {r2, r3}
3438
mov sp, r2
3539
mov lr, r3
3640
3741
# return val ?: 1;
3842
movs r0, r1
39-
beq .Lret_one
40-
bx lr
41-
42-
.Lret_one:
43+
bne .Lret_val
4344
movs r0, #1
45+
46+
.Lret_val:
4447
bx lr)");
4548
}
4649

0 commit comments

Comments
 (0)