]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Fix eh_return epilogue for normal returns.
authorYang Yujie <yangyujie@loongson.cn>
Fri, 8 Dec 2023 10:01:18 +0000 (18:01 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Tue, 30 Apr 2024 01:11:23 +0000 (09:11 +0800)
commit88f22217521564e1a956e14ac55456caa160e055
tree16b3852fb244998edadeffd44b2ca634f439c499
parenta44b37044dd66de6d4b32fc067b3053a352e421d
LoongArch: Fix eh_return epilogue for normal returns.

On LoongArch, the regitsters $r4 - $r7 (EH_RETURN_DATA_REGNO) will be saved
and restored in the function prologue and epilogue if the given function calls
__builtin_eh_return.  This causes the return value to be overwritten on normal
return paths and breaks a rare case of libgcc's _Unwind_RaiseException.

gcc/ChangeLog:

PR target/114848
* config/loongarch/loongarch.cc: Do not restore the saved eh_return
data registers ($r4-$r7) for a normal return of a function that calls
__builtin_eh_return elsewhere.
* config/loongarch/loongarch-protos.h: Same.
* config/loongarch/loongarch.md: Same.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/eh_return-normal-return.c: New test.

(cherry picked from commit 4b421728289e6f1caa0dfaa953a11698ab95d37d)
gcc/config/loongarch/loongarch-protos.h
gcc/config/loongarch/loongarch.cc
gcc/config/loongarch/loongarch.md
gcc/testsuite/gcc.target/loongarch/eh_return-normal-return.c [new file with mode: 0644]