Patchwork [debug] Fix PR60655 partially.

login
register
mail settings
Submitter Ramana Radhakrishnan
Date March 27, 2014, 11:25 a.m.
Message ID <53340AB3.5030109@arm.com>
Download mbox | patch
Permalink /patch/334296/
State New
Headers show

Comments

Ramana Radhakrishnan - March 27, 2014, 11:25 a.m.
Hi,

    This is a partial fix for PR60655 where dwarf2out.c rejects NOT of a 
value in const_ok_for_output_1. There is still a problem with the 
testcase on armhf where we get operations of the form, const (minus 
(const_int) (symref)) without the -fdata-sections option which is just 
weird. I'm not yet sure where this is produced from and will not have 
the time to dig further today.

As Jakub said on IRC, const_ok_for_output_1 is called only with partial 
rtx's and therefore disabling minus (const_int) (symref) might not be 
the best thing to do especially if this were part of plus (symref) 
(minus (const int) (symref)) and both symrefs were in the same section. 
I will try and find sometime to investigate this further tomorrow.

Bootstrapped and regtested on armhf

Bootstrap and regression test running on x86_64.

Ok to commit ?

regards
Ramana

gcc/

<DATE>   Jakub Jelinek <jakub@redhat.com>
          Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

	* dwarf2out.c (const_ok_for_output_1): Reject expressions containing a NOT.

gcc/testsuite

<DATE>  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

	* gcc.c-torture/compile/pr60655-1.c: New test.
commit a0ccb2bce5e3179e7b3560ecd7eecea6289baf7b
Author: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
Date:   Thu Mar 27 10:47:50 2014 +0000

    [Patch debug] Fix PR60655 partially.
Ramana Radhakrishnan - April 4, 2014, 10:27 a.m.
On Thu, Mar 27, 2014 at 11:25 AM, Ramana Radhakrishnan <ramrad01@arm.com> wrote:
> Hi,
>
>    This is a partial fix for PR60655 where dwarf2out.c rejects NOT of a
> value in const_ok_for_output_1. There is still a problem with the testcase
> on armhf where we get operations of the form, const (minus (const_int)
> (symref)) without the -fdata-sections option which is just weird. I'm not
> yet sure where this is produced from and will not have the time to dig
> further today.
>
> As Jakub said on IRC, const_ok_for_output_1 is called only with partial
> rtx's and therefore disabling minus (const_int) (symref) might not be the
> best thing to do especially if this were part of plus (symref) (minus (const
> int) (symref)) and both symrefs were in the same section. I will try and
> find sometime to investigate this further tomorrow.
>
> Bootstrapped and regtested on armhf
>
> Bootstrap and regression test running on x86_64.
>
> Ok to commit ?

Ping ?

Ramana

>
> regards
> Ramana
>
> gcc/
>
> <DATE>   Jakub Jelinek <jakub@redhat.com>
>          Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
>
>         * dwarf2out.c (const_ok_for_output_1): Reject expressions containing
> a NOT.
>
> gcc/testsuite
>
> <DATE>  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
>
>         * gcc.c-torture/compile/pr60655-1.c: New test.
Richard Guenther - April 4, 2014, 10:48 a.m.
On Fri, Apr 4, 2014 at 12:27 PM, Ramana Radhakrishnan
<ramana.gcc@googlemail.com> wrote:
> On Thu, Mar 27, 2014 at 11:25 AM, Ramana Radhakrishnan <ramrad01@arm.com> wrote:
>> Hi,
>>
>>    This is a partial fix for PR60655 where dwarf2out.c rejects NOT of a
>> value in const_ok_for_output_1. There is still a problem with the testcase
>> on armhf where we get operations of the form, const (minus (const_int)
>> (symref)) without the -fdata-sections option which is just weird. I'm not
>> yet sure where this is produced from and will not have the time to dig
>> further today.
>>
>> As Jakub said on IRC, const_ok_for_output_1 is called only with partial
>> rtx's and therefore disabling minus (const_int) (symref) might not be the
>> best thing to do especially if this were part of plus (symref) (minus (const
>> int) (symref)) and both symrefs were in the same section. I will try and
>> find sometime to investigate this further tomorrow.
>>
>> Bootstrapped and regtested on armhf
>>
>> Bootstrap and regression test running on x86_64.
>>
>> Ok to commit ?
>
> Ping ?

Ok.

Thanks,
Richard.

> Ramana
>
>>
>> regards
>> Ramana
>>
>> gcc/
>>
>> <DATE>   Jakub Jelinek <jakub@redhat.com>
>>          Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
>>
>>         * dwarf2out.c (const_ok_for_output_1): Reject expressions containing
>> a NOT.
>>
>> gcc/testsuite
>>
>> <DATE>  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
>>
>>         * gcc.c-torture/compile/pr60655-1.c: New test.

Patch

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 2b584a5..67b37eb 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -11325,8 +11325,18 @@  const_ok_for_output_1 (rtx *rtlp, void *data ATTRIBUTE_UNUSED)
       return 1;
     }
 
+  /* FIXME: Refer to PR60655. It is possible for simplification
+     of rtl expressions in var tracking to produce such expressions.
+     We should really identify / validate expressions
+     enclosed in CONST that can be handled by assemblers on various
+     targets and only handle legitimate cases here.  */
   if (GET_CODE (rtl) != SYMBOL_REF)
-    return 0;
+    {
+      if (GET_CODE (rtl) == NOT)
+	  return 1;
+
+      return 0;
+    }
 
   if (CONSTANT_POOL_ADDRESS_P (rtl))
     {
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr60655-1.c b/gcc/testsuite/gcc.c-torture/compile/pr60655-1.c
new file mode 100644
index 0000000..5f38701
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr60655-1.c
@@ -0,0 +1,31 @@ 
+/* { dg-options "-fdata-sections" } */
+
+typedef unsigned char unit;
+typedef unit *unitptr;
+extern short global_precision;
+typedef unsigned int size_t;
+extern void *memcpy (void *dest, const void *src, size_t n);
+
+short mp_compare(const unit* r1, const unit* r2)
+{
+  register short precision;
+  precision = global_precision;
+  (r1) = ((r1)+(precision)-1);
+  (r2) = ((r2)+(precision)-1);
+  do
+    { if (*r1 < *r2)
+	return(-1);
+      if (*((r1)--) > *((r2)--))
+	return(1);
+    } while (--precision);
+}
+
+static unit modulus[((1280+(2*8))/8)];
+static unit d_data[((1280+(2*8))/8)*2];
+
+int upton_modmult (unitptr prod, unitptr multiplicand, unitptr multiplier)
+{
+ unitptr d = d_data;
+ while (mp_compare(d,modulus) > 0)
+   memcpy((void*)(prod), (const void*)(d), (global_precision));
+}