]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Fix bug in loongarch_emit_stack_tie [PR110484].
authorLulu Cheng <chenglulu@loongson.cn>
Thu, 29 Jun 2023 11:30:59 +0000 (19:30 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Fri, 1 Sep 2023 02:04:21 +0000 (10:04 +0800)
Which may result in implicit references to $fp when frame_pointer_needed is false,
causing regs_ever_live[$fp] to be true when $fp is not explicitly used,
resulting in $fp being used as the target replacement register in the rnreg pass.

The bug originates from SPEC2017 541.leela_r(-flto).

gcc/ChangeLog:

PR target/110484
* config/loongarch/loongarch.cc (loongarch_emit_stack_tie): Use the
frame_pointer_needed to determine whether to use the $fp register.

Co-authored-by: Guo Jie <guojie@loongson.cn>
gcc/config/loongarch/loongarch.cc

index 1905599b9e8bacd15d45ab3f2fc6fdfeabd3db87..c72229cad87cc9cc0b6c5a195e3b20847f59661c 100644 (file)
@@ -1112,7 +1112,9 @@ loongarch_first_stack_step (struct loongarch_frame_info *frame)
 static void
 loongarch_emit_stack_tie (void)
 {
-  emit_insn (gen_stack_tie (Pmode, stack_pointer_rtx, hard_frame_pointer_rtx));
+  emit_insn (gen_stack_tie (Pmode, stack_pointer_rtx,
+                           frame_pointer_needed ? hard_frame_pointer_rtx
+                           : stack_pointer_rtx));
 }
 
 #define PROBE_INTERVAL (1 << STACK_CHECK_PROBE_INTERVAL_EXP)