[v2] LoongArch: gas: Adjust DWARF CIE alignment factors

Message ID 20240506092345.3855622-1-mengqinggang@loongson.cn
State New
Headers
Series [v2] LoongArch: gas: Adjust DWARF CIE alignment factors |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Testing passed

Commit Message

mengqinggang May 6, 2024, 9:23 a.m. UTC
  Set DWARF2_CIE_DATA_ALIGNMENT (data alignment factors) to -8.
It helps to save space.

Data Alignment Factor
A signed LEB128 encoded value that is factored out of all offset
instructions that are associated with this CIE or its FDEs. This value
shall be multiplied by the register offset argument of an offset
instruction to obtain the new offset value.
---
 gas/config/tc-loongarch.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
  

Comments

Jinyang He May 7, 2024, 1:46 a.m. UTC | #1
On 2024-05-06 17:23, mengqinggang wrote:

> Set DWARF2_CIE_DATA_ALIGNMENT (data alignment factors) to -8.
> It helps to save space.
>
> Data Alignment Factor
> A signed LEB128 encoded value that is factored out of all offset
> instructions that are associated with this CIE or its FDEs. This value
> shall be multiplied by the register offset argument of an offset
> instruction to obtain the new offset value.
> ---
>   gas/config/tc-loongarch.h | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/gas/config/tc-loongarch.h b/gas/config/tc-loongarch.h
> index e0d0962e5f0..8b6fee0ac23 100644
> --- a/gas/config/tc-loongarch.h
> +++ b/gas/config/tc-loongarch.h
> @@ -101,15 +101,19 @@ extern bool loongarch_frag_align_code (int, int);
>   
>   #define TC_FORCE_RELOCATION_LOCAL(FIX) 1
>   
> -/* Adjust debug_line after relaxation.  */
> -#define DWARF2_USE_FIXED_ADVANCE_PC 1
> -
>   /* Values passed to md_apply_fix don't include symbol values.  */
>   #define MD_APPLY_SYM_VALUE(FIX) 0
>   
>   #define TARGET_USE_CFIPOP 1
> -#define DWARF2_DEFAULT_RETURN_COLUMN 1 /* $ra.  */
> -#define DWARF2_CIE_DATA_ALIGNMENT -4
> +/* Adjust debug_line after relaxation.  */
> +#define DWARF2_USE_FIXED_ADVANCE_PC   1
> +
> +/* FDE Data Alignment Factor.
> +   FDE Code Alignment Factor (DWARF2_LINE_MIN_INSN_LENGTH) should be 1
> +   because DW_CFA_advance_loc need to be relocated in bytes
> +   when linker relaxation.  */
> +#define DWARF2_CIE_DATA_ALIGNMENT     (-8)

Should be (-4) for loongarch32?


> +#define DWARF2_DEFAULT_RETURN_COLUMN  1	    /* FDE Return Address Register.  */
>   
>   #define tc_cfi_frame_initial_instructions	\
>     loongarch_cfi_frame_initial_instructions
  
mengqinggang May 7, 2024, 2:14 a.m. UTC | #2
在 2024/5/7 上午9:46, Jinyang He 写道:
> On 2024-05-06 17:23, mengqinggang wrote:
>
>> Set DWARF2_CIE_DATA_ALIGNMENT (data alignment factors) to -8.
>> It helps to save space.
>>
>> Data Alignment Factor
>> A signed LEB128 encoded value that is factored out of all offset
>> instructions that are associated with this CIE or its FDEs. This value
>> shall be multiplied by the register offset argument of an offset
>> instruction to obtain the new offset value.
>> ---
>>   gas/config/tc-loongarch.h | 14 +++++++++-----
>>   1 file changed, 9 insertions(+), 5 deletions(-)
>>
>> diff --git a/gas/config/tc-loongarch.h b/gas/config/tc-loongarch.h
>> index e0d0962e5f0..8b6fee0ac23 100644
>> --- a/gas/config/tc-loongarch.h
>> +++ b/gas/config/tc-loongarch.h
>> @@ -101,15 +101,19 @@ extern bool loongarch_frag_align_code (int, int);
>>     #define TC_FORCE_RELOCATION_LOCAL(FIX) 1
>>   -/* Adjust debug_line after relaxation.  */
>> -#define DWARF2_USE_FIXED_ADVANCE_PC 1
>> -
>>   /* Values passed to md_apply_fix don't include symbol values. */
>>   #define MD_APPLY_SYM_VALUE(FIX) 0
>>     #define TARGET_USE_CFIPOP 1
>> -#define DWARF2_DEFAULT_RETURN_COLUMN 1 /* $ra.  */
>> -#define DWARF2_CIE_DATA_ALIGNMENT -4
>> +/* Adjust debug_line after relaxation.  */
>> +#define DWARF2_USE_FIXED_ADVANCE_PC   1
>> +
>> +/* FDE Data Alignment Factor.
>> +   FDE Code Alignment Factor (DWARF2_LINE_MIN_INSN_LENGTH) should be 1
>> +   because DW_CFA_advance_loc need to be relocated in bytes
>> +   when linker relaxation.  */
>> +#define DWARF2_CIE_DATA_ALIGNMENT     (-8)
>
> Should be (-4) for loongarch32?
>
Yeah.
>
>> +#define DWARF2_DEFAULT_RETURN_COLUMN 1        /* FDE Return Address 
>> Register.  */
>>     #define tc_cfi_frame_initial_instructions    \
>>     loongarch_cfi_frame_initial_instructions
  

Patch

diff --git a/gas/config/tc-loongarch.h b/gas/config/tc-loongarch.h
index e0d0962e5f0..8b6fee0ac23 100644
--- a/gas/config/tc-loongarch.h
+++ b/gas/config/tc-loongarch.h
@@ -101,15 +101,19 @@  extern bool loongarch_frag_align_code (int, int);
 
 #define TC_FORCE_RELOCATION_LOCAL(FIX) 1
 
-/* Adjust debug_line after relaxation.  */
-#define DWARF2_USE_FIXED_ADVANCE_PC 1
-
 /* Values passed to md_apply_fix don't include symbol values.  */
 #define MD_APPLY_SYM_VALUE(FIX) 0
 
 #define TARGET_USE_CFIPOP 1
-#define DWARF2_DEFAULT_RETURN_COLUMN 1 /* $ra.  */
-#define DWARF2_CIE_DATA_ALIGNMENT -4
+/* Adjust debug_line after relaxation.  */
+#define DWARF2_USE_FIXED_ADVANCE_PC   1
+
+/* FDE Data Alignment Factor.
+   FDE Code Alignment Factor (DWARF2_LINE_MIN_INSN_LENGTH) should be 1
+   because DW_CFA_advance_loc need to be relocated in bytes
+   when linker relaxation.  */
+#define DWARF2_CIE_DATA_ALIGNMENT     (-8)
+#define DWARF2_DEFAULT_RETURN_COLUMN  1	    /* FDE Return Address Register.  */
 
 #define tc_cfi_frame_initial_instructions	\
   loongarch_cfi_frame_initial_instructions