Skip to content

Commit

Permalink
[PR99680] Check empty constraint before using CONSTRAINT_LEN.
Browse files Browse the repository at this point in the history
It seems CONSTRAINT_LEN treats constraint '\0' as one having length 1.  Therefore we
read after the constraint string.  The patch fixes it.

gcc/ChangeLog:

	PR rtl-optimization/99680
	* lra-constraints.c (skip_contraint_modifiers): Rename to skip_constraint_modifiers.
	(process_address_1): Check empty constraint before using
	CONSTRAINT_LEN.
  • Loading branch information
vnmakarov committed Mar 20, 2021
1 parent 5f256a7 commit 8bf983c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions gcc/lra-constraints.c
Original file line number Diff line number Diff line change
Expand Up @@ -3395,12 +3395,12 @@ equiv_address_substitution (struct address_info *ad)
/* Skip all modifiers and whitespaces in constraint STR and return the
result. */
static const char *
skip_contraint_modifiers (const char *str)
skip_constraint_modifiers (const char *str)
{
for (;;str++)
switch (*str)
{
case '+' : case '&' : case '=': case '*': case ' ': case '\t':
case '+': case '&' : case '=': case '*': case ' ': case '\t':
case '$': case '^' : case '%': case '?': case '!':
break;
default: return str;
Expand Down Expand Up @@ -3451,24 +3451,24 @@ process_address_1 (int nop, bool check_only_p,
return false;

constraint
= skip_contraint_modifiers (curr_static_id->operand[nop].constraint);
= skip_constraint_modifiers (curr_static_id->operand[nop].constraint);
if (IN_RANGE (constraint[0], '0', '9'))
{
char *end;
unsigned long dup = strtoul (constraint, &end, 10);
constraint
= skip_contraint_modifiers (curr_static_id->operand[dup].constraint);
= skip_constraint_modifiers (curr_static_id->operand[dup].constraint);
}
cn = lookup_constraint (*constraint == '\0' ? "X" : constraint);
/* If we have several alternatives or/and several constraints in an
alternative and we can not say at this stage what constraint will be used,
use unknown constraint. The exception is an address constraint. If
operand has one address constraint, probably all others constraints are
address ones. */
if (get_constraint_type (cn) != CT_ADDRESS
&& *skip_contraint_modifiers (constraint
+ CONSTRAINT_LEN (constraint[0],
constraint)) != '\0')
if (constraint[0] != '\0' && get_constraint_type (cn) != CT_ADDRESS
&& *skip_constraint_modifiers (constraint
+ CONSTRAINT_LEN (constraint[0],
constraint)) != '\0')
cn = CONSTRAINT__UNKNOWN;
if (insn_extra_address_constraint (cn)
/* When we find an asm operand with an address constraint that
Expand Down

0 comments on commit 8bf983c

Please sign in to comment.