new ASM_OUTPUT_DEBUG_LABEL macro for VLIW targets, use in IA-64 port

Jim Wilson wilson@cygnus.com
Tue Oct 31 16:36:00 GMT 2000


The IA-64 port gets spurious dependency violation warnings from the assembler.
The problem is that debug info labels are confusing the assembler.  The
assembler has special checking code for dependency violations (i.e. hazards),
and this code needs to deal with branch target labels.  Unfortunately, there
is no way to tell the difference between debug info labels and branch target
labels in the assembler.

There are also another problems here.  Branch target labels can only
appear at the start of an instruction bundle.  Debug info labels can appear
anywhere.  If we emit normal labels for debug info, then we get different
less efficient code when -g is used.  For a VLIW/EPIC target, debug info
labels and branch target labels need to be handled differently.  

The IA-64 assembler syntax has a solution for this.  It defines "tags", which
are like labels, except that they can appear in the middle of instruction
bundles.  tags can not be used as branch targets.  Thus we can use tags for
debug info labels, and normal labels for branch targets, and this solves both
problems above.

The following patch adds a new macro ASM_OUTPUT_DEBUG_LABEL which defaults
to ASM_OUTPUT_INTERNAL_LABEL.  The IA-64 port defines this to emit a tag
instead of a normal label.  For everyplace that emits a dwarf2 debug info
label, I've changed the code to use ASM_OUTPUT_DEBUG_LABEL instead of
ASM_OUTPUT_INTERNAL_LABEL.  I've made no attempt to fix other debug info
formats because I have no way to test those changes.  I am not aware of any
other target with a special assembler syntax that can be used for debug info
labels.

This was tested with an ia64-linux kernel, glibc, and toolchain build.

2000-10-31  Jim Wilson  <wilson@redhat.com>

	* defaults.h (ASM_OUTPUT_DEBUG_LABEL): New.
	* tm.texi (ASM_OUTPUT_DEBUG_LABEL): Document.
	* dwarf2out.c (dwarf2out_begin_block): Use ASM_OUTPUT_DEBUG_LABEL
	instead of ASM_OUTPUT_INTERNAL_LABEL.
	(dwarf2out_end_block, dwarf2out_label): Likewise.
	* final.c (final_scan_insn, case NOTE_INSN_DELETED_LABEL): Likewise
	* config/ia64/ia64.h (ASM_OUTPUT_DEBUG_LABEL): Define.
	
Index: defaults.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/defaults.h,v
retrieving revision 1.24
diff -p -r1.24 defaults.h
*** defaults.h	2000/09/25 11:23:43	1.24
--- defaults.h	2000/11/01 00:10:41
*************** do { ASM_OUTPUT_LABEL(FILE,LABEL_ALTERNA
*** 133,138 ****
--- 133,147 ----
  #define ASM_OUTPUT_LABELREF(FILE,NAME)  asm_fprintf ((FILE), "%U%s", (NAME))
  #endif
  
+ /* Allow target to print debug info labels specially.  This is useful for
+    VLIW targets, since debug info labels should go into the middle of
+    instruction bundles instead of breaking them.  */
+ 
+ #ifndef ASM_OUTPUT_DEBUG_LABEL
+ #define ASM_OUTPUT_DEBUG_LABEL(FILE, PREFIX, NUM) \
+   ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM)
+ #endif
+ 
  /* This determines whether or not we support weak symbols.  */
  #ifndef SUPPORTS_WEAK
  #ifdef ASM_WEAKEN_LABEL
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/dwarf2out.c,v
retrieving revision 1.212
diff -p -r1.212 dwarf2out.c
*** dwarf2out.c	2000/10/20 17:35:18	1.212
--- dwarf2out.c	2000/11/01 00:10:41
*************** dwarf2out_begin_block (blocknum)
*** 10560,10566 ****
       register unsigned blocknum;
  {
    function_section (current_function_decl);
!   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BLOCK_BEGIN_LABEL, blocknum);
  }
  
  /* Output a marker (i.e. a label) for the end of the generated code for a
--- 10560,10566 ----
       register unsigned blocknum;
  {
    function_section (current_function_decl);
!   ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_BEGIN_LABEL, blocknum);
  }
  
  /* Output a marker (i.e. a label) for the end of the generated code for a
*************** dwarf2out_end_block (blocknum)
*** 10571,10577 ****
       register unsigned blocknum;
  {
    function_section (current_function_decl);
!   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BLOCK_END_LABEL, blocknum);
  }
  
  /* Returns nonzero if it is appropriate not to emit any debugging
--- 10571,10577 ----
       register unsigned blocknum;
  {
    function_section (current_function_decl);
!   ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_END_LABEL, blocknum);
  }
  
  /* Returns nonzero if it is appropriate not to emit any debugging
*************** dwarf2out_label (insn)
*** 10606,10612 ****
      {
        function_section (current_function_decl);
        sprintf (label, INSN_LABEL_FMT, current_funcdef_number);
!       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, label,
  				 (unsigned) INSN_UID (insn));
      }
  }
--- 10606,10612 ----
      {
        function_section (current_function_decl);
        sprintf (label, INSN_LABEL_FMT, current_funcdef_number);
!       ASM_OUTPUT_DEBUG_LABEL (asm_out_file, label,
  				 (unsigned) INSN_UID (insn));
      }
  }
Index: final.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/final.c,v
retrieving revision 1.145
diff -p -r1.145 final.c
*** final.c	2000/09/29 11:40:24	1.145
--- final.c	2000/11/01 00:10:41
*************** final_scan_insn (insn, file, optimize, p
*** 2270,2276 ****
  	     referenced (in the form of having its address taken.  */
  	  /* ??? Figure out how not to do this unconditionally.  This
  	     interferes with bundling on LIW targets.  */
! 	  ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
  
  	  if (debug_info_level == DINFO_LEVEL_NORMAL
  	      || debug_info_level == DINFO_LEVEL_VERBOSE)
--- 2270,2276 ----
  	     referenced (in the form of having its address taken.  */
  	  /* ??? Figure out how not to do this unconditionally.  This
  	     interferes with bundling on LIW targets.  */
! 	  ASM_OUTPUT_DEBUG_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
  
  	  if (debug_info_level == DINFO_LEVEL_NORMAL
  	      || debug_info_level == DINFO_LEVEL_VERBOSE)
Index: tm.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tm.texi,v
retrieving revision 1.149
diff -p -r1.149 tm.texi
*** tm.texi	2000/10/18 17:51:54	1.149
--- tm.texi	2000/11/01 00:10:42
*************** The usual definition of this macro is as
*** 5945,5950 ****
--- 5945,5963 ----
  fprintf (@var{stream}, "L%s%d:\n", @var{prefix}, @var{num})
  @end example
  
+ @findex ASM_OUTPUT_DEBUG_LABEL
+ @item ASM_OUTPUT_DEBUG_LABEL (@var{stream}, @var{prefix}, @var{num})
+ A C statement to output to the stdio stream @var{stream} a debug info
+ label whose name is made from the string @var{prefix} and the number
+ @var{num}.  This is useful for VLIW targets, where debug info labels
+ may need to be treated differently than branch target labels.  On some
+ systems, branch target labels must be at the beginning of instruction
+ bundles, but debug info labels can occur in the middle of instruction
+ bundles.
+ 
+ If this macro is not defined, then @code{ASM_OUTPUT_INTERNAL_LABEL} will be
+ used.
+ 
  @findex ASM_OUTPUT_ALTERNATE_LABEL_NAME
  @item ASM_OUTPUT_ALTERNATE_LABEL_NAME (@var{stream}, @var{string})
  A C statement to output to the stdio stream @var{stream} the string
Index: config/ia64/ia64.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/ia64/ia64.h,v
retrieving revision 1.52
diff -p -r1.52 ia64.h
*** ia64.h	2000/10/28 19:39:58	1.52
--- ia64.h	2000/11/01 00:10:42
*************** do {									\
*** 2637,2642 ****
--- 2637,2654 ----
  
  #define DWARF2_ASM_LINE_DEBUG_INFO (TARGET_DWARF2_ASM)
  
+ /* Use tags for debug info labels, so that they don't break instruction
+    bundles.  This also avoids getting spurious DV warnings from the
+    assembler.  This is similar to ASM_OUTPUT_INTERNAL_LABEL, except that we
+    add brackets around the label.  */
+ 
+ #define ASM_OUTPUT_DEBUG_LABEL(FILE, PREFIX, NUM) \
+   do							\
+     {							\
+       fprintf (FILE, "[.%s%d:]\n", PREFIX, NUM);	\
+     }							\
+   while (0)
+ 
  
  /* Cross Compilation and Floating Point.  */
  


More information about the Gcc-patches mailing list