🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #50650

gcc-2.2.2 -a option

#50650
From: meissner
Date: Mon, 30 Aug 1993 21:44
307 lines
9280 bytes
| I'm using gcc-2.2.2 on Sun SPARC IPX running SunOS4.1.3.  When using option -a,
| I always get link error:
| ld: Undefined symbol
|     ___bb_init_func
| 
| I look into the libgcc2.c, there is some condition, "__sun__ & __mc68000__". Is
| it something wrong with this? Or I missed sth. here?

Evidently nobody has used basic block profiling since GCC was
developed on Sun3's.  Here are some patches I put together to provide
some support for basic block profiling (what will go into GCC 2.5 will
probably differ in details from these patches).  These patches are
against the current development version, but I doubt the code has
changed all that much.

*** final.c.orig	Tue Aug 24 10:58:28 1993
--- final.c	Mon Aug 30 17:34:51 1993
***************
*** 264,271 ****
  
    if (profile_block_flag)
      {
!       char name[12];
  
        data_section ();
  
        /* Output the main header, of 6 words:
--- 264,278 ----
  
    if (profile_block_flag)
      {
!       char name[20];
!       int align = exact_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT);
!       int size = (INT_TYPE_SIZE / BITS_PER_UNIT) * count_basic_blocks;
!       int rounded = size;
  
+       rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
+       rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
+ 		 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
+ 
        data_section ();
  
        /* Output the main header, of 6 words:
***************
*** 277,284 ****
  	 6:  extra word added by GNU: address of address table
  	      which contains addresses of basic blocks,
  	      in parallel with the table of counts.  */
!       ASM_OUTPUT_ALIGN (asm_out_file,
! 			exact_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  
        ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 0);
        assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
--- 284,291 ----
  	 6:  extra word added by GNU: address of address table
  	      which contains addresses of basic blocks,
  	      in parallel with the table of counts.  */
! 
!       ASM_OUTPUT_ALIGN (asm_out_file, align);
  
        ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 0);
        assemble_integer (const0_rtx, UNITS_PER_WORD, 1);
***************
*** 291,297 ****
        ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 3);
        assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
  
!       /* Output the file name.  */
        ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 1);
        {
  	int len = strlen (filename);
--- 298,305 ----
        ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 3);
        assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name), UNITS_PER_WORD, 1);
  
!       /* Output the file name changing the suffix to .d for Sun tcov
! 	 compatibility.  */
        ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 1);
        {
  	int len = strlen (filename);
***************
*** 302,325 ****
  	assemble_string (data_file, strlen (data_file) + 1);
        }
  
-       /* Realign data section.  */
-       ASM_OUTPUT_ALIGN (asm_out_file,
- 			exact_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
- 
        /* Make space for the table of counts.  */
!       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 2);
!       if (count_basic_blocks != 0)
! 	assemble_zeros (INT_TYPE_SIZE / BITS_PER_UNIT * count_basic_blocks);
  
        /* Output the table of addresses.  */
        readonly_data_section ();
        /* Realign in new section */
!       ASM_OUTPUT_ALIGN (asm_out_file,
! 			floor_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
        ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 3);
        for (i = 0; i < count_basic_blocks; i++)
  	{
- 	  char name[12];
  	  ASM_GENERATE_INTERNAL_LABEL (name, "LPB", i);
  	  assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name),
  			    UNITS_PER_WORD, 1);
--- 310,346 ----
  	assemble_string (data_file, strlen (data_file) + 1);
        }
  
        /* Make space for the table of counts.  */
!       if (flag_no_common || size == 0)
! 	{
! 	  /* Realign data section.  */
! 	  ASM_OUTPUT_ALIGN (asm_out_file, align);
! 	  ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 2);
! 	  if (size != 0)
! 	    assemble_zeros (size);
! 	}
!       else
! 	{
! 	  ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 2);
! #ifdef ASM_OUTPUT_SHARED_LOCAL
! 	  if (flag_shared_data)
! 	    ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
! 	  else
! #endif
! #ifdef ASM_OUTPUT_ALIGNED_LOCAL
! 	    ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, align);
! #else
! 	    ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
! #endif
! 	}
  
        /* Output the table of addresses.  */
        readonly_data_section ();
        /* Realign in new section */
!       ASM_OUTPUT_ALIGN (asm_out_file, align);
        ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LPBX", 3);
        for (i = 0; i < count_basic_blocks; i++)
  	{
  	  ASM_GENERATE_INTERNAL_LABEL (name, "LPB", i);
  	  assemble_integer (gen_rtx (SYMBOL_REF, Pmode, name),
  			    UNITS_PER_WORD, 1);
*** libgcc2.c.orig	Tue Aug 24 13:30:25 1993
--- libgcc2.c	Tue Aug 24 16:19:53 1993
***************
*** 1285,1306 ****
  #endif
  
  #ifdef L_bb
  /* Avoid warning from ranlib about empty object file.  */
  void
  __bb_avoid_warning ()
  {}
  
- #if defined (__sun__) && defined (__mc68000__)
  struct bb
  {
!   int initialized;
    char *filename;
!   int *counts;
!   int ncounts;
!   int zero_word;
!   int *addresses;
  };
  
  extern int ___tcov_init;
  
  __bb_init_func (blocks)
--- 1285,1312 ----
  #endif
  
  #ifdef L_bb
+ 
+ #ifdef BLOCK_PROFILER_CODE
+ BLOCK_PROFILER_CODE
+ #else
+ 
  /* Avoid warning from ranlib about empty object file.  */
  void
  __bb_avoid_warning ()
  {}
  
  struct bb
  {
!   long zero_word;
    char *filename;
!   long *counts;
!   long ncounts;
!   struct bb *next;
!   long *addresses;
  };
  
+ #if defined (__sun__) && defined (__mc68000__)
+ 
  extern int ___tcov_init;
  
  __bb_init_func (blocks)
***************
*** 1312,1319 ****
--- 1318,1400 ----
    ___bb_link (blocks->filename, blocks->counts, blocks->ncounts);
  }
  
+ #else	/* !68k sun */
+ 
+ /* Simple minded basic block profiling output dumper for
+    systems that don't provde tcov support.  At present,
+    it requires atexit and stdio.  */
+ 
+ #include <stdio.h>
+ 
+ #ifdef HAVE_ATEXIT
+ extern void atexit (void (*) (void));
+ #define ON_EXIT(FUNC,ARG) atexit ((FUNC))
+ #else
+ #ifdef sun
+ extern void on_exit (void*, void*);
+ #define ON_EXIT(FUNC,ARG) on_exit ((FUNC), (ARG))
  #endif
  #endif
+ 
+ static struct bb *bb_head = (struct bb *)0;
+ 
+ void
+ __bb_exit_func (void)
+ {
+   FILE *file = fopen ("bb.out", "w");
+ 
+   if (!file)
+     perror ("bb.out");
+ 
+   else
+     {
+       struct bb *ptr;
+ 
+       for (ptr = bb_head; ptr != (struct bb *)0; ptr = ptr->next)
+ 	{
+ 	  int ncounts = ptr->ncounts;
+ 	  int i;
+ 
+ 	  fprintf (file, "File %s, %d basic blocks \n\n",
+ 		   ptr->filename, ncounts);
+ 
+ 	  for (i = 0; i < ncounts; i++)
+ 	    fprintf (file,
+ 		     "\tBasic block # %5d: %11ld call(s), address 0x%.8lx\n",
+ 		     i, ptr->counts[i], ptr->addresses[i]);
+ 
+ 	  fprintf (file, "\n");
+ 	  fflush (file);
+ 	}
+ 
+       fclose (file);
+     }
+ }
+ 
+ void
+ __bb_init_func (struct bb *blocks)
+ {
+   /* User is supposed to check whether the first word is non-0,
+      but just in case.... */
+ 
+   if (blocks->zero_word)
+     return;
+ 
+ #ifdef ON_EXIT
+   /* Initialize destructor.  */
+   if (!bb_head)
+     ON_EXIT (__bb_exit_func, 0);
+ #endif
+ 
+   /* Set up linked list.  */
+   blocks->zero_word = 1;
+   blocks->next = bb_head;
+   bb_head = blocks;
+ }
+ 
+ #endif	/* !68k sun */
+ #endif	/* !BLOCK_PROFILER_CODE */
+ #endif	/* L_bb */
  
  /* frills for C++ */
  
*** tm.texi.orig	Tue Aug 24 13:32:08 1993
--- tm.texi	Tue Aug 24 15:56:01 1993
***************
*** 2889,2894 ****
--- 2889,2899 ----
  @code{ASM_GENERATE_INTERNAL_LABEL} as well as that of this macro, you
  can take a short cut in the definition of this macro and use the name
  that you know will result.
+ 
+ @findex BLOCK_PROFILER_CODE
+ @item BLOCK_PROFILER_CODE
+ A C function or functions which are needed in the library to
+ support block profiling.
  @end table
  
  @node Varargs

--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Old hackers never die, their bugs just increase.
Technical Details
Message-ID: <9308302140.AA16138@pasta.osf.org>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!sol.ctr.columbia.edu!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!osf.ORG!meissner
References: meissner@osf.ORG

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,763f561af34bc496
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-08-30 14:56:54 PST
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!sol.ctr.columbia.edu!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!osf.ORG!meissner
From: meissner@osf.ORG
Newsgroups: gnu.gcc.help
Subject: gcc-2.2.2 -a option
Date: 30 Aug 1993 17:44:47 -0400
Organization: GNUs Not Usenet
Lines: 307
Sender: daemon@cis.ohio-state.edu
Distribution: gnu
Message-ID: <9308302140.AA16138@pasta.osf.org>
References: meissner@osf.ORG