diff mbox

genattrtab error reporting

Message ID BD0DA756-222B-4279-893D-2ABBE5187E58@comcast.net
State New
Headers show

Commit Message

Mike Stump May 7, 2014, 9:21 p.m. UTC
getattrtab looses track of which file the given rtl came from during error reporting.  A port that uses multiple .md files for the port will tend to list the last .md file processed instead of the correct md file.  We preserve the filename upon read, and during post processing, we reset the filename to the right context, as we process that context.

Ok?
2014-05-07  Mike Stump  <mikestump@comcast.net>

	* genattrtab.c (struct insn_def): Add filename.
	(convert_set_attr_alternative): Improve error message.
	(check_defs): Ensure read_md_filename is set appropriately.
	(gen_insn): Save read_md_filename.

Comments

H.J. Lu May 8, 2014, 12:22 a.m. UTC | #1
On Wed, May 7, 2014 at 2:21 PM, Mike Stump <mikestump@comcast.net> wrote:
> getattrtab looses track of which file the given rtl came from during error reporting.  A port that uses multiple .md files for the port will tend to list the last .md file processed instead of the correct md file.  We preserve the filename upon read, and during post processing, we reset the filename to the right context, as we process that context.
>

Does this fix

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31778
Mike Stump May 8, 2014, 12:31 a.m. UTC | #2
On May 7, 2014, at 5:22 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, May 7, 2014 at 2:21 PM, Mike Stump <mikestump@comcast.net> wrote:
>> getattrtab looses track of which file the given rtl came from during error reporting.  A port that uses multiple .md files for the port will tend to list the last .md file processed instead of the correct md file.  We preserve the filename upon read, and during post processing, we reset the filename to the right context, as we process that context.
>> 
> 
> Does this fix
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31778

Only if it is applied to the tree!  :-)  Yes.
Segher Boessenkool May 8, 2014, 1:12 a.m. UTC | #3
> > Does this fix
> > 
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31778
> 
> Only if it is applied to the tree!  :-)  Yes.

It also is PR57062.  Thanks for fixing it!


Segher
Mike Stump May 8, 2014, 2:28 a.m. UTC | #4
On May 7, 2014, at 6:12 PM, Segher Boessenkool <segher@kernel.crashing.org> wrote:
>>> Does this fix
>>> 
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31778
>> 
>> Only if it is applied to the tree!  :-)  Yes.
> 
> It also is PR57062.  Thanks for fixing it!

Thanks, marked as dup.
diff mbox

Patch

diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index 99b1b83..0f14b4d 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -139,6 +139,7 @@  struct insn_def
   rtx def;			/* The DEFINE_...  */
   int insn_code;		/* Instruction number.  */
   int insn_index;		/* Expression number in file, for errors.  */
+  const char *filename;		/* Filename.  */
   int lineno;			/* Line number.  */
   int num_alternatives;		/* Number of alternatives.  */
   int vec_idx;			/* Index of attribute vector in `def'.  */
@@ -1066,7 +1067,8 @@  convert_set_attr_alternative (rtx exp, struct insn_def *id)
   if (XVECLEN (exp, 1) != num_alt)
     {
       error_with_line (id->lineno,
-		       "bad number of entries in SET_ATTR_ALTERNATIVE");
+		       "bad number of entries in SET_ATTR_ALTERNATIVE, was %d expected %d",
+		       XVECLEN (exp, 1), num_alt);
       return NULL_RTX;
     }
 
@@ -1137,6 +1139,7 @@  check_defs (void)
       if (XVEC (id->def, id->vec_idx) == NULL)
 	continue;
 
+      read_md_filename = id->filename;
       for (i = 0; i < XVECLEN (id->def, id->vec_idx); i++)
 	{
 	  value = XVECEXP (id->def, id->vec_idx, i);
@@ -3280,6 +3283,7 @@  gen_insn (rtx exp, int lineno)
   id->next = defs;
   defs = id;
   id->def = exp;
+  id->filename = read_md_filename;
   id->lineno = lineno;
 
   switch (GET_CODE (exp))