Fix bugs found with various levels of optimisation while implementing

PIC support for GCC/arm.
This fix is untested on platforms other than the ARM and is only enabled
if GCC_27_ARM32_PIC_SUPPORT is defined.
These fixes are only required for GCC 2.7 and will not be needed in 2.8+
This commit is contained in:
mark 1997-10-19 19:05:51 +00:00
parent df179fd1e4
commit 9ad19504c3
4 changed files with 102 additions and 1 deletions

View File

@ -769,6 +769,18 @@ uses_reg_or_mem (x)
int i, j;
char *fmt;
#ifdef GCC_27_ARM32_PIC_SUPPORT
/*
* This is a patch for a bug found when implementing arm32 PIC support
* that has been fixed in 2.8
*/
if(code == IF_THEN_ELSE) {
if(!uses_reg_or_mem (XEXP (x, 1)) && !uses_reg_or_mem (XEXP (x, 2)))
return 0;
return 1;
}
#endif
if (code == REG
|| (code == MEM
&& ! (GET_CODE (XEXP (x, 0)) == SYMBOL_REF
@ -1608,11 +1620,26 @@ propagate_block (old, first, last, final, significant, bnum)
call-clobbered reg, and mark_set_regs has already had
a chance to handle it. */
#ifdef GCC_27_ARM32_PIC_SUPPORT
/*
* This is a patch for a bug found when implementing arm32 PIC support
* that has been fixed in 2.8
*/
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) {
if (call_used_regs[i] && ! global_regs[i]
#if defined (PIC_OFFSET_TABLE_REGNUM) && !defined (PIC_OFFSET_TABLE_REG_CALL_CLOBBERED)
&& (i != PIC_OFFSET_TABLE_REGNUM || !flag_pic)
#endif
)
dead[i / REGSET_ELT_BITS]
|= ((REGSET_ELT_TYPE) 1 << (i % REGSET_ELT_BITS));
}
#else
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
if (call_used_regs[i] && ! global_regs[i])
dead[i / REGSET_ELT_BITS]
|= ((REGSET_ELT_TYPE) 1 << (i % REGSET_ELT_BITS));
#endif
/* The stack ptr is used (honorarily) by a CALL insn. */
live[STACK_POINTER_REGNUM / REGSET_ELT_BITS]
|= ((REGSET_ELT_TYPE) 1

View File

@ -177,6 +177,21 @@ function_cannot_inline_p (fndecl)
if (current_function_has_nonlocal_goto)
return "function with nonlocal goto cannot be inline";
#ifdef GCC_27_ARM32_PIC_SUPPORT
/*
* This is a patch for a bug found when implementing arm32 PIC support
* that should be fixed in 2.8
*/
for (insn = get_insns ();
insn && ! (GET_CODE (insn) == NOTE
&& NOTE_LINE_NUMBER (insn) == NOTE_INSN_FUNCTION_BEG);
insn = NEXT_INSN (insn))
{
if((GET_CODE(insn) == CODE_LABEL)
&& (LABEL_PRESERVE_P(insn)))
return "looks like exception stuff";
}
#endif
return 0;
}

View File

@ -3601,7 +3601,20 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
{
int opno = recog_dup_num[i];
*recog_dup_loc[i] = *recog_operand_loc[opno];
#ifdef GCC_27_ARM32_PIC_SUPPORT
/*
* This is a patch for a bug found when implementing arm32 PIC support
* that should be fixed in 2.8
*/
/* is there is a label that is duplicated
* we cannot reload it
* - it appears that insn_n_operands - does not include labels
*/
if ((opno < insn_n_operands[insn_code_number])
&& (operand_reloadnum[opno] >= 0))
#else
if (operand_reloadnum[opno] >= 0)
#endif
push_replacement (recog_dup_loc[i], operand_reloadnum[opno],
insn_operand_mode[insn_code_number][opno]);
}
@ -4336,6 +4349,40 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels)
return 1;
}
#ifdef GCC_27_ARM32_PIC_SUPPORT
/*
* This is a patch for a bug found when implementing arm32 PIC support
* that has been fixed in 2.8
*/
else if (GET_CODE (ad) == MINUS && GET_CODE (XEXP (ad, 0)) == PLUS
&& GET_CODE (XEXP (XEXP (ad, 0), 1 )) == CONST_INT
&& (XEXP (XEXP (ad, 0), 0) == frame_pointer_rtx
#if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
|| XEXP (XEXP (ad, 0), 0) == hard_frame_pointer_rtx
#endif
#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
|| XEXP (XEXP (ad, 0), 0) == arg_pointer_rtx
#endif
|| XEXP (XEXP (ad, 0), 0) == stack_pointer_rtx)
&& ! memory_address_p (mode, ad))
{
rtx base = XEXP (XEXP (ad , 0) ,0);
rtx index = XEXP (ad , 1);
rtx disp = XEXP (XEXP (ad, 0) ,1);
// base + disp - index
// base - (index +disp)
*loc = ad = gen_rtx (MINUS, GET_MODE (ad),
base,
plus_constant (index, -INTVAL (disp)));
find_reloads_address_part (XEXP (ad, 1), &XEXP (ad, 1), BASE_REG_CLASS,
GET_MODE (ad), opnum, type, ind_levels);
find_reloads_address_1 (XEXP (ad, 0), 1, &XEXP (ad, 0), opnum, type, 0);
return 1;
}
#endif
else if (GET_CODE (ad) == PLUS && GET_CODE (XEXP (ad, 1)) == CONST_INT
&& GET_CODE (XEXP (ad, 0)) == PLUS

View File

@ -3799,7 +3799,19 @@ schedule_block (b, file)
for those mentioned in the call pattern which will be
made live again later. */
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
#ifdef GCC_27_ARM32_PIC_SUPPORT
/*
* This is a patch for a bug found when implementing arm32 PIC support
* that has been fixed in 2.8
*/
if (call_used_regs[i] && !global_regs[i]
#if defined (PIC_OFFSET_TABLE_REGNUM) && !defined (PIC_OFFSET_TABLE_REG_CALL_CLOBBERED)
&& (i != PIC_OFFSET_TABLE_REGNUM || !flag_pic)
#endif
)
#else
if (call_used_regs[i] || global_regs[i])
#endif
{
register int offset = i / REGSET_ELT_BITS;
register REGSET_ELT_TYPE bit