Return to BSD News archive
Received: by minnie.vk1xwt.ampr.org with NNTP id AA958 ; Wed, 10 Feb 93 07:00:18 EST Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!dkuug!flshub!phk From: phk@data.fls.dk (P-HK/Poul-Henning Kamp) Newsgroups: comp.unix.bsd Subject: [386BSD] Patches for gcc-2.3.3: part 1 Message-ID: <1993Feb9.134938.1808@data.fls.dk> Date: 9 Feb 93 13:49:38 GMT Organization: FLS Data A/S, Valby, Copenhagen, Denmark. Lines: 305 # These are the patches I use to make gcc-2.3.3 compile and run in it self. # The bulk of this stuff is for adding basic-block-profiling. # You can do with only the 1st and last patch in this file. diff -r -C2 ../R/here/gcc-2.3.3/config/i386bsd.h here/gcc-2.3.3/config/i386bsd.h *** ../R/here/gcc-2.3.3/config/i386bsd.h Tue Dec 29 02:55:43 1992 --- here/gcc-2.3.3/config/i386bsd.h Wed Jan 20 18:50:57 1993 *************** *** 1,4 **** --- 1,6 ---- /* Configuration for an i386 running 386BSD as the target machine. */ + #define HANDLE_SYSV_PRAGMA + /* This is tested by i386gas.h. */ #define YES_UNDERSCORES *************** *** 47,50 **** --- 49,85 ---- } + #define BLOCK_PROFILER_REAL_FILENAME 1 + #define BLOCK_PROFILER_COUNT_PROLOGUE 1 + #define FUNCTION_BLOCK_PROFILER_BEFORE_PROLOGUE 1 + + /* If we want to use the BB-stuff in the kernel we have to be reentrant, + * which means that we have to link the BB-areas in one atomic instruction. + * The bts here will ensure that each file is only done once. + */ + + #define FUNCTION_BLOCK_PROFILER(FILE,LABELNO) { \ + fprintf (FILE, "\tbts $0,LPBX0\n"); \ + fprintf (FILE, "\tjc 1f\n"); \ + fprintf (FILE, "\tcall bb_link\n1:\n"); } + + /* In theory bb_link could be a C-proc, except that we have to ensure that + * the load and store into __bb_head is atomic, therefore we output a small + * bb_link in FILE_BLOCK_PROFILER which uses a xchgl to do that trick. + * If __bb_head was zero, call __bb_once in libgcc2.c + */ + #define FILE_BLOCK_PROFILER(FILE) { \ + fprintf (FILE, ".comm\t___bb_head,4\n"); \ + fprintf (FILE, "bb_link:\n\tmovl $LPBX0,%%eax\n"); \ + fprintf (FILE, "\txchgl %%eax,___bb_head\n"); \ + fprintf (FILE, "\tmovl %%eax,LPBX0+16\n"); \ + fprintf (FILE, "\torl %%eax,%%eax\n"); \ + fprintf (FILE, "\tjnz 1f\n"); \ + fprintf (FILE, "\tcall ___bb_once\n"); \ + fprintf (FILE, "1:\tret \n"); } + + /* This is far to long for my taste: 6 bytes. */ + #define BLOCK_PROFILER(FILE,BLOCKNO) \ + fprintf (FILE, "\tincl (LPBX2+%d)\n", 4*(BLOCKNO)); + /* There are conflicting reports about whether this system uses a different assembler syntax. wilson@cygnus.com says # is right. */ *************** *** 146,147 **** --- 181,189 ---- #define JUMP_TABLES_IN_TEXT_SECTION + + #ifndef GPLUSPLUS_INCLUDE_DIR + #define GPLUSPLUS_INCLUDE_DIR "/usr/g++-include" + #endif + #ifndef GCC_INCLUDE_DIR + #define GCC_INCLUDE_DIR "/usr/include" + #endif Only in here/gcc-2.3.3/config: i386bsd.h.orig diff -r -C2 ../R/here/gcc-2.3.3/final.c here/gcc-2.3.3/final.c *** ../R/here/gcc-2.3.3/final.c Tue Dec 29 02:53:27 1992 --- here/gcc-2.3.3/final.c Wed Jan 20 18:50:58 1993 *************** *** 262,269 **** int i; ! if (profile_block_flag) { char name[12]; data_section (); --- 262,275 ---- int i; ! if (profile_block_flag && count_basic_blocks) { char name[12]; + #ifdef FILE_BLOCK_PROFILER + text_section (); + ASM_OUTPUT_ALIGN (asm_out_file, + exact_log2 (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); + FILE_BLOCK_PROFILER(asm_out_file); + #endif /* FILE_BLOCK_PROFILER */ data_section (); *************** *** 274,277 **** --- 280,284 ---- 4: number of counts in the table. 5: always 0, for compatibility with Sun. + can be used to link the blocks together on other arch's. 6: extra word added by GNU: address of address table which contains addresses of basic blocks, *************** *** 297,302 **** --- 304,311 ---- char *data_file = (char *) alloca (len + 3); strcpy (data_file, filename); + #ifndef BLOCK_PROFILER_REAL_FILENAME strip_off_ending (data_file, len); strcat (data_file, ".d"); + #endif /* BLOCK_PROFILER_REAL_FILENAME */ assemble_string (data_file, strlen (data_file) + 1); } *************** *** 717,720 **** --- 726,750 ---- #endif + #ifdef FUNCTION_BLOCK_PROFILER + #ifdef FUNCTION_BLOCK_PROFILER_BEFORE_PROLOGUE + if (profile_block_flag) + { + FUNCTION_BLOCK_PROFILER (file, profile_label_no); + } + #endif /* FUNCTION_BLOCK_PROFILER_BEFORE_PROLOGUE */ + #endif /* FUNCTION_BLOCK_PROFILER */ + + #ifdef BLOCK_PROFILER + #ifdef BLOCK_PROFILER_COUNT_PROLOGUE + if (profile_block_flag) + { + ASM_OUTPUT_INTERNAL_LABEL (file, "LPB", count_basic_blocks); + BLOCK_PROFILER (file, count_basic_blocks); + CC_STATUS_INIT; + count_basic_blocks++; + } + #endif /* BLOCK_PROFILER_COUNT_PROLOGUE */ + #endif /* BLOCK_PROFILER */ + /* The Sun386i and perhaps other machines don't work right if the profiling code comes after the prologue. */ *************** *** 749,752 **** --- 779,783 ---- { #ifdef FUNCTION_BLOCK_PROFILER + #ifndef FUNCTION_BLOCK_PROFILER_BEFORE_PROLOGUE if (profile_block_flag) { *************** *** 753,756 **** --- 784,788 ---- FUNCTION_BLOCK_PROFILER (file, profile_label_no); } + #endif /* FUNCTION_BLOCK_PROFILER_BEFORE_PROLOGUE */ #endif /* FUNCTION_BLOCK_PROFILER */ *************** *** 874,877 **** --- 906,917 ---- xcoffout_end_epilogue (file); #endif + + if (profile_block_flag) + { + /* Add a BB-point after each function, this allows us to determine the + exact contents of each BB */ + ASM_OUTPUT_INTERNAL_LABEL (file, "LPB", count_basic_blocks); + count_basic_blocks++; + } /* If FUNCTION_EPILOGUE is not defined, then the function body Only in here/gcc-2.3.3: final.c.orig diff -r -C2 ../R/here/gcc-2.3.3/libgcc2.c here/gcc-2.3.3/libgcc2.c *** ../R/here/gcc-2.3.3/libgcc2.c Tue Dec 29 02:53:43 1992 --- here/gcc-2.3.3/libgcc2.c Wed Jan 20 18:50:59 1993 *************** *** 1171,1180 **** #ifdef L_bb - /* Avoid warning from ranlib about empty object file. */ - void - __bb_avoid_warning () - {} - #if defined (__sun__) && defined (__mc68000__) struct bb { --- 1171,1175 ---- *************** *** 1183,1189 **** int *counts; int ncounts; ! int zero_word; int *addresses; }; extern int ___tcov_init; --- 1178,1241 ---- int *counts; int ncounts; ! struct bb *next; int *addresses; }; + + /* Avoid warning from ranlib about empty object file. */ + void + __bb_avoid_warning () + {} + + extern struct bb *__bb_head; + char *__bb_file = "BB.%05d.%08x"; + + void + __bb_final() + { + char buf[1024]; + int i,j,f; + long l; + struct bb *pb = __bb_head; + + /* + if(!__bb_file) + */ + __bb_file = "BB.%05d.%08x"; + time(&l); + sprintf(buf,__bb_file,getpid(),l); + f=open(buf,0x601,0666); /* 0x601 = WRONLY|CREAT|WRONLY */ + if(f<0) return; + + while(pb) + { + sprintf(buf,"%08x * %s\n",pb->addresses[0],pb->filename); + j = strlen(buf); + if(j != write(f,buf,j)) { close(f); return; } + + for(i=0;i<pb->ncounts;i++) + { + if(pb->counts[i]) + { + sprintf(buf,"%08x | %08x %08x\n", + pb->addresses[i],pb->counts[i], + pb->addresses[i+1]-pb->addresses[i]); + j = strlen(buf); + if(j != write(f,buf,j)) { close(f); return; } + } + } + pb=pb->next; + } + close(f); + } + + void + __bb_once() + { + #ifdef HAVE_ATEXIT + atexit(__bb_final); + #endif + } + + #if defined (__sun__) && defined (__mc68000__) extern int ___tcov_init; Only in here/gcc-2.3.3: libgcc2.c.orig *** /gandalf/D/here/gcc-2.3.3/toplev.c Tue Dec 29 11:54:01 1992 --- here/gcc-2.3.3/toplev.c Sun Jan 24 12:49:44 1993 *************** *** 3295,3298 **** --- 3295,3299 ---- fflush (stderr); + #ifndef __386BSD__ #ifdef USG system ("ps -l 1>&2"); *************** *** 3300,3303 **** --- 3301,3305 ---- system ("ps v"); #endif /* not USG */ + #endif /* __386BSD__ */ } #endif /* not VMS */ *** /gandalf/D/here/gcc-2.3.3/config/i386bsd.h Sat Jan 23 10:02:46 1993 --- here/gcc-2.3.3/config/i386bsd.h Sat Jan 30 16:52:18 1993 *************** *** 12,16 **** /* Like the default, except no -lg. */ ! #define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}" #undef SIZE_TYPE --- 12,16 ---- /* Like the default, except no -lg. */ ! #define LIB_SPEC "%{!p:%{!pg:-lc -lgcc -lc}}%{p:-lc_p -lgcc -lc_p}%{pg:-lc_p -lgcc -lc_p}" #undef SIZE_TYPE -- phk@data.fls.dk || The seven hazards of computing: Poul-Henning Kamp || The hardware, the software, the supplier FLS DATA A/S, Denmark || the application, the user, the operator Phone: (+45) 36 18 12 35 || and the data. Stan Kelly-Bootle