[libc-commits] [PATCH] D145584: [libc] Add support for setjmp and longjmp in riscv
Mikhail Ramalho via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Mar 16 03:43:18 PDT 2023
mikhail.ramalho added a comment.
Thanks for the review, Siva, I think I've managed to address all your comments thanks to your code snippet (tests are running now, I'll update here if they pass).
The fix was actually not declaring the register variables and using them directly in the asm (+ adding -fomit-frame-pointer), now clang/gcc doesn't generate the function prologue/epilogue anymore.
The code generated by clang is still not great, but I'd say it's not that bad either, just a bunch of unnecessary adds:
0000000000000000 <_ZN11__llvm_libc7longjmpEP9__jmp_bufi>:
0: 00053083 ld ra,0(a0)
4: 00850613 add a2,a0,8
8: 6200 ld s0,0(a2)
a: 01050613 add a2,a0,16
e: 6204 ld s1,0(a2)
10: 01850613 add a2,a0,24
14: 00063903 ld s2,0(a2)
18: 02050613 add a2,a0,32
1c: 00063983 ld s3,0(a2)
20: 02850613 add a2,a0,40
24: 00063a03 ld s4,0(a2)
28: 03050613 add a2,a0,48
2c: 00063a83 ld s5,0(a2)
30: 03850613 add a2,a0,56
34: 00063b03 ld s6,0(a2)
38: 04050613 add a2,a0,64
3c: 00063b83 ld s7,0(a2)
40: 04850613 add a2,a0,72
44: 00063c03 ld s8,0(a2)
48: 05050613 add a2,a0,80
4c: 00063c83 ld s9,0(a2)
50: 05850613 add a2,a0,88
54: 00063d03 ld s10,0(a2)
58: 06050613 add a2,a0,96
5c: 00063d83 ld s11,0(a2)
60: 06850613 add a2,a0,104
64: 00063103 ld sp,0(a2)
68: 07050613 add a2,a0,112
6c: 2200 fld fs0,0(a2)
6e: 07850613 add a2,a0,120
72: 2204 fld fs1,0(a2)
74: 08050613 add a2,a0,128
78: 00063907 fld fs2,0(a2)
7c: 08850613 add a2,a0,136
80: 00063987 fld fs3,0(a2)
84: 09050613 add a2,a0,144
88: 00063a07 fld fs4,0(a2)
8c: 09850613 add a2,a0,152
90: 00063a87 fld fs5,0(a2)
94: 0a050613 add a2,a0,160
98: 00063b07 fld fs6,0(a2)
9c: 0a850613 add a2,a0,168
a0: 00063b87 fld fs7,0(a2)
a4: 0b050613 add a2,a0,176
a8: 00063c07 fld fs8,0(a2)
ac: 0b850613 add a2,a0,184
b0: 00063c87 fld fs9,0(a2)
b4: 0c050613 add a2,a0,192
b8: 00063d07 fld fs10,0(a2)
bc: 0c850613 add a2,a0,200
c0: 00063d87 fld fs11,0(a2)
c4: 0015b513 seqz a0,a1
c8: 952e add a0,a0,a1
ca: 8082 ret
0000000000000000 <_ZN11__llvm_libc6setjmpEP9__jmp_buf>:
0: 00153023 sd ra,0(a0)
4: 00850593 add a1,a0,8
8: e180 sd s0,0(a1)
a: 01050593 add a1,a0,16
e: e184 sd s1,0(a1)
10: 01850593 add a1,a0,24
14: 0125b023 sd s2,0(a1)
18: 02050593 add a1,a0,32
1c: 0135b023 sd s3,0(a1)
20: 02850593 add a1,a0,40
24: 0145b023 sd s4,0(a1)
28: 03050593 add a1,a0,48
2c: 0155b023 sd s5,0(a1)
30: 03850593 add a1,a0,56
34: 0165b023 sd s6,0(a1)
38: 04050593 add a1,a0,64
3c: 0175b023 sd s7,0(a1)
40: 04850593 add a1,a0,72
44: 0185b023 sd s8,0(a1)
48: 05050593 add a1,a0,80
4c: 0195b023 sd s9,0(a1)
50: 05850593 add a1,a0,88
54: 01a5b023 sd s10,0(a1)
58: 06050593 add a1,a0,96
5c: 01b5b023 sd s11,0(a1)
60: 06850593 add a1,a0,104
64: 0025b023 sd sp,0(a1)
68: 07050593 add a1,a0,112
6c: a180 fsd fs0,0(a1)
6e: 07850593 add a1,a0,120
72: a184 fsd fs1,0(a1)
74: 08050593 add a1,a0,128
78: 0125b027 fsd fs2,0(a1)
7c: 08850593 add a1,a0,136
80: 0135b027 fsd fs3,0(a1)
84: 09050593 add a1,a0,144
88: 0145b027 fsd fs4,0(a1)
8c: 09850593 add a1,a0,152
90: 0155b027 fsd fs5,0(a1)
94: 0a050593 add a1,a0,160
98: 0165b027 fsd fs6,0(a1)
9c: 0a850593 add a1,a0,168
a0: 0175b027 fsd fs7,0(a1)
a4: 0b050593 add a1,a0,176
a8: 0185b027 fsd fs8,0(a1)
ac: 0b850593 add a1,a0,184
b0: 0195b027 fsd fs9,0(a1)
b4: 0c050593 add a1,a0,192
b8: 01a5b027 fsd fs10,0(a1)
bc: 0c850593 add a1,a0,200
c0: 01b5b027 fsd fs11,0(a1)
c4: 4501 li a0,0
c6: 8082 ret
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145584/new/
https://reviews.llvm.org/D145584
More information about the libc-commits
mailing list