Skip to content

Commit 7bee370

Browse files
author
Richard Earnshaw
committed
arm: fix ICE due to fix for POP {PC} change
My earlier change for making the compiler prefer POP {PC} over LDR PC, [SP], #4 had a slightly unexpected consequence in that we now also call arm_emit_multi_reg_pop to handle single register pops when the register is not PC. This exposed a latent bug in this function where the dwarf unwinding notes on the single-register POP were not being set correctly. gcc/ PR target/118089 * config/arm/arm.cc (arm_emit_multi_reg_pop): Add a CFA adjust note to single-register POP instructions.
1 parent 3889101 commit 7bee370

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

gcc/config/arm/arm.cc

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22563,19 +22563,20 @@ arm_emit_multi_reg_pop (unsigned long saved_regs_mask)
2256322563

2256422564
/* The parallel needs to hold num_regs SETs
2256522565
and one SET for the stack update. */
22566-
par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (num_regs + emit_update + offset_adj));
22566+
par = gen_rtx_PARALLEL (VOIDmode,
22567+
rtvec_alloc (num_regs + emit_update + offset_adj));
2256722568

2256822569
if (return_in_pc)
2256922570
XVECEXP (par, 0, 0) = ret_rtx;
2257022571

2257122572
if (emit_update)
2257222573
{
2257322574
/* Increment the stack pointer, based on there being
22574-
num_regs 4-byte registers to restore. */
22575+
num_regs 4-byte registers to restore. */
2257522576
tmp = gen_rtx_SET (stack_pointer_rtx,
22576-
plus_constant (Pmode,
22577-
stack_pointer_rtx,
22578-
4 * num_regs));
22577+
plus_constant (Pmode,
22578+
stack_pointer_rtx,
22579+
4 * num_regs));
2257922580
RTX_FRAME_RELATED_P (tmp) = 1;
2258022581
XVECEXP (par, 0, offset_adj) = tmp;
2258122582
}
@@ -22587,31 +22588,33 @@ arm_emit_multi_reg_pop (unsigned long saved_regs_mask)
2258722588
rtx dwarf_reg = reg = gen_rtx_REG (SImode, i);
2258822589
if (arm_current_function_pac_enabled_p () && i == IP_REGNUM)
2258922590
dwarf_reg = gen_rtx_REG (SImode, RA_AUTH_CODE);
22590-
if ((num_regs == 1) && emit_update && !return_in_pc)
22591-
{
22592-
/* Emit single load with writeback. */
22593-
tmp = gen_frame_mem (SImode,
22594-
gen_rtx_POST_INC (Pmode,
22595-
stack_pointer_rtx));
22596-
tmp = emit_insn (gen_rtx_SET (reg, tmp));
22591+
if ((num_regs == 1) && emit_update && !return_in_pc)
22592+
{
22593+
/* Emit single load with writeback. */
22594+
tmp = gen_frame_mem (SImode,
22595+
gen_rtx_POST_INC (Pmode,
22596+
stack_pointer_rtx));
22597+
tmp = emit_insn (gen_rtx_SET (reg, tmp));
2259722598
REG_NOTES (tmp) = alloc_reg_note (REG_CFA_RESTORE, dwarf_reg,
2259822599
dwarf);
22599-
return;
22600-
}
22600+
arm_add_cfa_adjust_cfa_note (tmp, UNITS_PER_WORD,
22601+
stack_pointer_rtx, stack_pointer_rtx);
22602+
return;
22603+
}
2260122604

22602-
tmp = gen_rtx_SET (reg,
22603-
gen_frame_mem
22604-
(SImode,
22605-
plus_constant (Pmode, stack_pointer_rtx, 4 * j)));
22606-
RTX_FRAME_RELATED_P (tmp) = 1;
22607-
XVECEXP (par, 0, j + emit_update + offset_adj) = tmp;
22605+
tmp = gen_rtx_SET (reg,
22606+
gen_frame_mem
22607+
(SImode,
22608+
plus_constant (Pmode, stack_pointer_rtx, 4 * j)));
22609+
RTX_FRAME_RELATED_P (tmp) = 1;
22610+
XVECEXP (par, 0, j + emit_update + offset_adj) = tmp;
2260822611

22609-
/* We need to maintain a sequence for DWARF info too. As dwarf info
22610-
should not have PC, skip PC. */
22611-
if (i != PC_REGNUM)
22612+
/* We need to maintain a sequence for DWARF info too. As dwarf info
22613+
should not have PC, skip PC. */
22614+
if (i != PC_REGNUM)
2261222615
dwarf = alloc_reg_note (REG_CFA_RESTORE, dwarf_reg, dwarf);
2261322616

22614-
j++;
22617+
j++;
2261522618
}
2261622619

2261722620
if (return_in_pc)

0 commit comments

Comments
 (0)