This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Add current_fde to dwarf2out.c


On Tue, May 27, 2008 at 10:59 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, May 27, 2008 at 8:48 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>
>>>
>>> Is that all uses of this kind?  I guess the assert could go in the
>>> accessor function instead.  See also the reply to Joey, basically
>>> such patch is ok and pre-approved if it works.
>>>
>>
>> There is
>>
>>  if (fde_table_in_use)
>>    {
>>      dw_fde_ref fde = &fde_table[fde_table_in_use - 1];
>>      for (cfi = fde->dw_fde_cfi; cfi; cfi = cfi->dw_cfi_next)
>>        lookup_cfa_1 (cfi, loc);
>>    }
>>
>> and there are many more like this on stack branch. If current_fde returns NULL
>> when fde_table_in_use is 0, we can do
>>
>>  fde = current_fde ();
>>  if (fde && ...)
>>
>> instead of
>>
>>  if (fde_table_in_use)
>>  {
>>    fde = current_fde ();
>>    ...
>>  }
>>
>> But I can go either way.
>>
>
> I think
>
> if (fde_table_in_use)
>  {
>   fde = current_fde ();
>   ...
>  }
>
> defeats the purpose of access function. I am checking in my patch.
>
> Thanks.
>

It turns out that on stack branch, current_fde is used earlier in the
file.  This patch moves it to the front of file, together with fde_table.
It will be easier to update if we decide to change data structure in
the future.  There is

typedef struct dw_fde_struct *dw_fde_ref;

I also replaced "struct dw_fde_struct *" with dw_fde_ref. I am checking
it in as an obvious fix.

Thanks.


H.J.
---
2008-05-27  H.J. Lu  <hongjiu.lu@intel.com>

        * dwarf2out.c (current_fde): Change return type to dw_fde_ref.
        Moved to the front of file.

--- dwarf2out.c.foo     2008-05-27 11:06:51.000000000 -0700
+++ dwarf2out.c 2008-05-27 11:29:39.000000000 -0700
@@ -315,6 +315,14 @@ static GTY(()) unsigned fde_table_in_use
    fde_table.  */
 #define FDE_TABLE_INCREMENT 256

+/* Get the current fde_table entry we should use.  */
+
+static inline dw_fde_ref
+current_fde (void)
+{
+  return fde_table_in_use ? &fde_table[fde_table_in_use - 1] : NULL;
+}
+
 /* A list of call frame insns for the CIE.  */
 static GTY(()) dw_cfi_ref cie_cfi_head;

@@ -633,14 +641,6 @@ dwarf2out_cfi_label (void)
   return label;
 }

-/* Get the current fde_table entry we should use.  */
-
-static inline struct dw_fde_struct *
-current_fde (void)
-{
-  return fde_table_in_use ? &fde_table[fde_table_in_use - 1] : NULL;
-}
-
 /* Add CFI to the current fde at the PC value indicated by LABEL if specified,
    or to the CIE if LABEL is NULL.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]