Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
sac-group
sac2c
Commits
a0d6a84f
Commit
a0d6a84f
authored
Jun 22, 2006
by
Sven-Bodo Scholz
Browse files
changed profiling and made it work. Not thoroughly tested though....
parent
c82fddd6
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
317 additions
and
216 deletions
+317
-216
src/compile/gen_startup_code.c
src/compile/gen_startup_code.c
+24
-0
src/flatten/fun2lac.c
src/flatten/fun2lac.c
+5
-2
src/global/globals.mac
src/global/globals.mac
+1
-0
src/global/main.c
src/global/main.c
+5
-5
src/libsac/profile.c
src/libsac/profile.c
+21
-32
src/optimize/SSALIR.c
src/optimize/SSALIR.c
+4
-0
src/optimize/SSALUR.c
src/optimize/SSALUR.c
+5
-1
src/optimize/deadcoderemoval.c
src/optimize/deadcoderemoval.c
+19
-0
src/optimize/deadcoderemoval.h
src/optimize/deadcoderemoval.h
+1
-0
src/print/print.c
src/print/print.c
+17
-14
src/profile/annotate_fun_calls.c
src/profile/annotate_fun_calls.c
+21
-2
src/runtime/sac_profile.h
src/runtime/sac_profile.h
+192
-159
src/tree/tree_compound.h
src/tree/tree_compound.h
+2
-1
No files found.
src/compile/gen_startup_code.c
View file @
a0d6a84f
...
...
@@ -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
;
}
...
...
src/flatten/fun2lac.c
View file @
a0d6a84f
...
...
@@ -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"
);
...
...
src/global/globals.mac
View file @
a0d6a84f
...
...
@@ -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)
/*
...
...
src/global/main.c
View file @
a0d6a84f
...
...
@@ -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
*/
...
...
src/libsac/profile.c
View file @
a0d6a84f
/*
*
* $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:
...
...
src/optimize/SSALIR.c
View file @
a0d6a84f
...
...
@@ -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
)
...
...
src/optimize/SSALUR.c
View file @
a0d6a84f
...
...
@@ -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
),
...
...
src/optimize/deadcoderemoval.c
View file @
a0d6a84f
...
...
@@ -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:
...
...
src/optimize/deadcoderemoval.h
View file @
a0d6a84f
...
...
@@ -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
);
...
...
src/print/print.c
View file @
a0d6a84f
...
...
@@ -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
;);
}
...
...
src/profile/annotate_fun_calls.c
View file @
a0d6a84f
...
...
@@ -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
;
}
/*
...
...
src/runtime/sac_profile.h
View file @
a0d6a84f
This diff is collapsed.
Click to expand it.
src/tree/tree_compound.h
View file @
a0d6a84f
...
...
@@ -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
/*--------------------------------------------------------------------------*/
/***
...
...
Hans-Nikolai Viessmann
@hans
mentioned in issue
#2251
·
Jan 28, 2020
mentioned in issue
#2251
mentioned in issue #2251
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment