Skip to content
Snippets Groups Projects
user avatar
Fei Gao authored
This patch fixes a cfi issue introduced by
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=60524be1e3929d83e15fceac6e2aa053c8a6fb20

Test code:
char my_getchar();
float getf();
int test_f0()
{
  int s0 = my_getchar();
  float f0 = getf();
  int b = my_getchar();
  return f0+s0+b;
}

cflags: -g -Os -march=rv32imafc -mabi=ilp32f -msave-restore -mcmodel=medlow

before patch:
test_f0:
...
	.cfi_startproc
	call	t0,__riscv_save_1
	.cfi_offset 8, -8
	.cfi_offset 1, -4
	.cfi_def_cfa_offset 16
...
	addi	sp,sp,-16
	.cfi_def_cfa_offset 32

...

	addi	sp,sp,16
	.cfi_def_cfa_offset 0  // issue here
...
	tail	__riscv_restore_1
	.cfi_restore 8
	.cfi_restore 1
	.cfi_def_cfa_offset -16 // issue here
	.cfi_endproc

after patch:
test_f0:
...
	.cfi_startproc
	call	t0,__riscv_save_1
	.cfi_offset 8, -8
	.cfi_offset 1, -4
	.cfi_def_cfa_offset 16
...
	addi	sp,sp,-16
	.cfi_def_cfa_offset 32

...

	addi	sp,sp,16
	.cfi_def_cfa_offset 16  // corrected here
...
	tail	__riscv_restore_1
	.cfi_restore 8
	.cfi_restore 1
	.cfi_def_cfa_offset 0 // corrected here
	.cfi_endproc

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_expand_epilogue): fix cfi issue with
	correct offset.
56818720
History
Name Last commit Last update