]> 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:09:12 +0000 (09:09 +0800)
commitbb78099d2624b52c781ed6e5d85e43d54c3cda1a
tree98d030033472cf547daf888a955f13ee3a4f1a39
parent7c524300df9956a64c2916b6d5d2ab4e56e6a538
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]