Commit a0d6a84f authored by Sven-Bodo Scholz's avatar Sven-Bodo Scholz
Browse files

changed profiling and made it work. Not thoroughly tested though....

parent c82fddd6
......@@ -239,6 +239,30 @@ PrintProfileData ()
fprintf (global.outfile, "\n");
fprintf (global.outfile, "#define SAC_SET_FUN_PARENTS \\\n");
fprintf (global.outfile, " { \\\n");
fprintf (global.outfile, " { \\\n");
fprintf (global.outfile, " %d", global.profile_parentfunno[0][0]);
for (j = 1; j < global.profile_funapcntr[0]; j++) {
fprintf (global.outfile, ", %d", global.profile_parentfunno[0][j]);
}
fprintf (global.outfile, " \\\n"
" }");
for (i = 1; i < global.profile_funcntr; i++) {
fprintf (global.outfile, ", \\\n"
" { \\\n");
fprintf (global.outfile, " %d", global.profile_parentfunno[i][0]);
for (j = 1; j < global.profile_funapcntr[i]; j++) {
fprintf (global.outfile, ", %d", global.profile_parentfunno[i][j]);
}
fprintf (global.outfile, " \\\n"
" }");
}
fprintf (global.outfile, " \\\n"
" }");
fprintf (global.outfile, "\n");
DBUG_VOID_RETURN;
}
......
......@@ -574,8 +574,11 @@ TransformIntoDoLoop (node *fundef)
*/
int_call = BLOCK_INSTR (COND_THEN (cond));
DBUG_ASSERT ((IsRecursiveCall (int_call, fundef)
&& (ASSIGN_NEXT (int_call) == NULL)),
while ((int_call != NULL)
&& (NODE_TYPE (ASSIGN_INSTR (int_call)) == N_annotate)) {
int_call = ASSIGN_NEXT (int_call);
}
DBUG_ASSERT ((IsRecursiveCall (int_call, fundef)),
"recursive call of do-loop function must be the only"
" assignment in the conditional");
......
......@@ -424,6 +424,7 @@ GLOBAL (int, profile_funcntr, 0)
GLOBAL (char **, profile_funnme, (char **)ILIBmalloc (PF_MAXFUN * sizeof (char *)))
GLOBAL (int *, profile_funapcntr, (int *)ILIBmalloc (PF_MAXFUN * sizeof (int)))
GLOBAL (int **, profile_funapline, BuildFunApLine (PF_MAXFUN, PF_MAXFUNAP))
GLOBAL (int **, profile_parentfunno, BuildFunApLine (PF_MAXFUN, PF_MAXFUNAP))
GLOBAL (int, profile_funapmax, 1)
/*
......
......@@ -216,11 +216,7 @@ main (int argc, char *argv[])
syntax_tree = PHrunCompilerSubPhase (SUBPH_swr, syntax_tree);
PHASE_DONE_EPILOG;
#if 1
if (global.doprofile) {
syntax_tree = PFdoProfileFunCalls (syntax_tree); /* profile_tab */
}
#endif
PHASE_EPILOG;
if (global.break_after == PH_typecheck)
......@@ -281,6 +277,10 @@ main (int argc, char *argv[])
syntax_tree = PHrunCompilerPhase (PH_sacopt, syntax_tree);
syntax_tree = TSdoPrintTypeStatistics (syntax_tree);
if (global.doprofile) {
syntax_tree = PFdoProfileFunCalls (syntax_tree); /* profile_tab */
}
/*
* WLtransform
*/
......
/*
*
* $Log$
* Revision 3.2 2001/06/28 09:42:43 sbs
* concat in definition of __PF_TIMER and __PF_TIMER_PERCENTAGE
* eliminated.
*
* Revision 3.1 2000/11/20 18:02:46 sacbase
* new release made
*
* Revision 2.2 1999/07/08 12:30:19 cg
* File moved to new directory src/libsac.
*
*
*/
/*
*
* Revision 2.1 1999/02/23 12:43:41 sacbase
* new release made
*
* Revision 1.4 1998/06/29 08:50:14 cg
* added '#define _POSIX_C_SOURCE 199506L' for multi-threaded execution.
*
* Revision 1.3 1998/05/07 08:13:24 cg
* SAC runtime library implementation converted to new naming conventions.
*
* Revision 1.2 1998/03/24 13:51:45 cg
* First working revision
*
* Revision 1.1 1998/03/19 16:36:14 cg
* Initial revision
*
* $Id$
*
*/
......@@ -97,13 +67,32 @@ struct rusage SAC_PF_stop_timer;
void
SAC_PF_PrintHeader (char *title)
{
fprintf (stderr, "****************************************"
fprintf (stderr, "\n****************************************"
"****************************************\n");
fprintf (stderr, "*** %-72s ***\n", title);
fprintf (stderr, "****************************************"
"****************************************\n");
}
/******************************************************************************
*
* function:
* void SAC_PF_PrintSubHeader( char * title, int lineno)
*
* description:
*
* This function prints some header lines for presenting profiling
* information.
*
*
******************************************************************************/
void
SAC_PF_PrintSubHeader (char *title, int lineno)
{
fprintf (stderr, "call to %s in line #%d:\n", title, lineno);
}
/******************************************************************************
*
* function:
......
......@@ -734,6 +734,10 @@ GetRecursiveCallAssignment (node *dofun)
ass = COND_THENINSTR (ASSIGN_INSTR (ass));
while ((ass != NULL) && (NODE_TYPE (ASSIGN_INSTR (ass)) == N_annotate)) {
ass = ASSIGN_NEXT (ass);
}
DBUG_ASSERT ((ass != NULL) && (NODE_TYPE (ass) == N_assign)
&& (NODE_TYPE (ASSIGN_INSTR (ass)) == N_let)
&& (NODE_TYPE (ASSIGN_RHS (ass)) == N_ap)
......
......@@ -258,8 +258,12 @@ SSALURGetDoLoopUnrolling (node *fundef, node *ext_assign)
DBUG_RETURN (UNR_NONE);
}
/* extract recursive call behind cond */
/* extract recursive call behind cond */
then_instr = COND_THENINSTR (ASSIGN_INSTR (cond_assign));
while ((then_instr != NULL)
&& (NODE_TYPE (ASSIGN_INSTR (then_instr)) == N_annotate)) {
then_instr = ASSIGN_NEXT (then_instr);
}
DBUG_ASSERT ((NODE_TYPE (then_instr) == N_assign),
"cond of loop fun w/o N_assign in then body");
DBUG_ASSERT ((NODE_TYPE (ASSIGN_INSTR (then_instr)) == N_let),
......
......@@ -518,6 +518,25 @@ DCRassign (node *arg_node, info *arg_info)
DBUG_RETURN (arg_node);
}
/******************************************************************************
*
* function:
* node *DCRannotate(node *arg_node , info *arg_info)
*
* description:
* mark this RHS to be kept!
*
*****************************************************************************/
node *
DCRannotate (node *arg_node, info *arg_info)
{
DBUG_ENTER ("DCRannotate");
INFO_REMASSIGN (arg_info) = FALSE;
DBUG_RETURN (arg_node);
}
/******************************************************************************
*
* function:
......
......@@ -31,6 +31,7 @@ extern node *DCRret (node *arg_node, info *arg_info);
extern node *DCRblock (node *arg_node, info *arg_info);
extern node *DCRvardec (node *arg_node, info *arg_info);
extern node *DCRassign (node *arg_node, info *arg_info);
extern node *DCRannotate (node *arg_node, info *arg_info);
extern node *DCRlet (node *arg_node, info *arg_info);
extern node *DCRids (node *arg_node, info *arg_info);
extern node *DCRcond (node *arg_node, info *arg_info);
......
......@@ -1555,6 +1555,7 @@ node *
PRTannotate (node *arg_node, info *arg_info)
{
static char strbuffer1[256];
static char strbuffer2[512];
DBUG_ENTER ("PRTannotate");
......@@ -1576,20 +1577,21 @@ PRTannotate (node *arg_node, info *arg_info)
}
}
#if 0 /**** TODO ****/
if (ANNOTATE_TAG (arg_node) & INL_FUN) {
sprintf (strbuffer2, "PROFILE_INLINE( %s)", strbuffer1);
} else {
strcpy (strbuffer2, strbuffer1);
}
if (ANNOTATE_TAG (arg_node) & LIB_FUN) {
sprintf (strbuffer1, "PROFILE_LIBRARY( %s)", strbuffer2);
} else {
strcpy (strbuffer1, strbuffer2);
}
#endif
if (ANNOTATE_TAG (arg_node) & INL_FUN) {
sprintf (strbuffer2, "PROFILE_INLINE( %s)", strbuffer1);
if (ANNOTATE_TAG (arg_node) & LIB_FUN) {
sprintf (strbuffer1, "PROFILE_LIBRARY( %s)", strbuffer2);
} else {
strcpy (strbuffer1, strbuffer2);
}
} else {
strcpy (strbuffer2, strbuffer1);
if (ANNOTATE_TAG (arg_node) & LIB_FUN) {
sprintf (strbuffer1, "PROFILE_LIBRARY( %s)", strbuffer2);
} else {
strcpy (strbuffer1, strbuffer2);
}
}
fprintf (global.outfile, "%s;", strbuffer1);
......@@ -1857,6 +1859,7 @@ PRTassign (node *arg_node, info *arg_info)
if (NODE_TYPE (instr) == N_annotate) {
if (global.compiler_phase < PH_compile) {
trav_instr = FALSE;
trav_instr = TRUE;
}
DBUG_EXECUTE ("PRINT_PROFILE", trav_instr = TRUE;);
}
......
......@@ -63,12 +63,14 @@
*/
struct INFO {
node *fundef;
node *parent;
};
/*
* INFO macros
*/
#define INFO_PF_FUNDEF(n) (n->fundef)
#define INFO_PF_PARENT(n) (n->parent)
/*
* INFO functions
......@@ -83,6 +85,7 @@ MakeInfo ()
result = ILIBmalloc (sizeof (info));
INFO_PF_FUNDEF (result) = NULL;
INFO_PF_PARENT (result) = NULL;
DBUG_RETURN (result);
}
......@@ -122,7 +125,9 @@ static node *
SearchMain (node *fundef)
{
DBUG_ENTER ("SearchMain");
while ((fundef != NULL) && (strcmp (FUNDEF_NAME (fundef), "main") != 0)) {
while ((fundef != NULL)
&& ((FUNDEF_ISWRAPPERFUN (fundef) == TRUE)
|| (strcmp (FUNDEF_NAME (fundef), "main") != 0))) {
fundef = FUNDEF_NEXT (fundef);
}
DBUG_RETURN (fundef);
......@@ -218,6 +223,10 @@ Fundef2FunTypeMask (node *fundef)
funtypemask = funtypemask | INL_FUN;
}
if (!FUNDEF_ISLOCAL (fundef)) {
funtypemask = funtypemask | LIB_FUN;
}
DBUG_RETURN (funtypemask);
}
......@@ -248,6 +257,7 @@ PFfundef (node *arg_node, info *arg_info)
{
char *str_buff;
ntype *wrappertype;
node *mem_parent;
DBUG_ENTER ("PFfundef");
......@@ -266,13 +276,20 @@ PFfundef (node *arg_node, info *arg_info)
FUNDEF_FUNNO (arg_node) = ++global.profile_funcntr;
}
if (FUNDEF_BODY (arg_node) != NULL) { /* library funs do have no body! */
mem_parent = INFO_PF_PARENT (arg_info);
INFO_PF_PARENT (arg_info) = arg_node;
FUNDEF_BODY (arg_node) = TRAVdo (FUNDEF_BODY (arg_node), arg_info);
INFO_PF_PARENT (arg_info) = mem_parent;
} else if (FUNDEF_ISWRAPPERFUN (arg_node)) {
wrappertype = FUNDEF_WRAPPERTYPE (arg_node);
if (TYisProd (wrappertype)) {
DBUG_ASSERT (FUNDEF_IMPL (arg_node) != NULL,
"product wrapper type without IMPL found!");
FUNDEF_IMPL (arg_node) = TRAVdo (FUNDEF_IMPL (arg_node), arg_info);
} else if (wrappertype == NULL) {
DBUG_ASSERT (FUNDEF_WASUSED (arg_node),
"non-used wrapperfun w/o wrappertype found");
} else {
FUNDEF_WRAPPERTYPE (arg_node)
= TYmapFunctionInstances (wrappertype, PFfundef, arg_info);
......@@ -307,7 +324,7 @@ node *
PFassign (node *arg_node, info *arg_info)
{
int funtypemask;
int funno, funap_cnt;
int funno, funap_cnt, parent_funno;
node *old_next_assign, *res;
char *str_buff;
......@@ -326,6 +343,7 @@ PFassign (node *arg_node, info *arg_info)
* PF - data structure indexing starts with 0:
*/
funno = FUNDEF_FUNNO (INFO_PF_FUNDEF (arg_info)) - 1;
parent_funno = FUNDEF_FUNNO (INFO_PF_PARENT (arg_info)) - 1;
/*
* incrementing the application counter for the function
......@@ -346,6 +364,7 @@ PFassign (node *arg_node, info *arg_info)
global.profile_funapmax = global.profile_funapcntr[funno];
}
global.profile_funapline[funno][funap_cnt] = NODE_LINE (arg_node);
global.profile_parentfunno[funno][funap_cnt] = parent_funno;
}
/*
......
This diff is collapsed.
......@@ -49,7 +49,8 @@ specific implementation of a function should remain with the source code.
#define CALL_FUN 0x0001
#define RETURN_FROM_FUN 0x0002
#define INL_FUN 0x0004
#define OVRLD_FUN 0x0008
#define LIB_FUN 0x0008
#define OVRLD_FUN 0x0010
/*--------------------------------------------------------------------------*/
/***
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment