Hi! Certain GIMPLE codes, such as OpenMP ones, have a structured block attached to them, for exmaple, gcc/gimple.def:GIMPLE_OMP_PARALLEL:
/* GIMPLE_OMP_PARALLEL <BODY, CLAUSES, CHILD_FN, DATA_ARG> represents
#pragma omp parallel [CLAUSES]
BODY
BODY is a the sequence of statements to be executed by all threads.
[...]
CHILD_FN is set when outlining the body of the parallel region.
All the statements in BODY are moved into this newly created
function when converting OMP constructs into low-GIMPLE.
[...]
DEFGSCODE(GIMPLE_OMP_PARALLEL, "gimple_omp_parallel",
GSS_OMP_PARALLEL_LAYOUT)
Using -ftree-dump-all, I can see this structured block (BODY) getting
dumped, but it then "disappears" in the ompexp pass', and "reappears" (as
function main._omp_fn.0) in the next ssa pass' dump.
If I'm correctly understanding the GCC sources as well as operating GDB,
in the gimple pass we get main._omp_fn.0 dumped because
gcc/cgraphunit.c:analyze_functions iterates over all functions
(analyze_function -> dump_function). In the following passes,
presumably, this is not done anymore: omplower, lower, eh, cfg. In
ompexp, the GIMPLE_OMP_PARALLEL is expanded into a
»__builtin_GOMP_parallel (main._omp_fn.0)« call, but the main._omp_fn.0
is not dumped (and there is no BODY anymore to dump). In the next ssa
pass, main._omp_fn.0 again is being dumped, by means of
gcc/passes.c:do_per_function_toporder (execute_pass_list ->
execute_one_pass -> execute_function_dump -> dump_function_to_file), as I
understand it. What do I need to modify to get main._omp_fn.0 included
in the dumps before the ssa pass, too?
Example:
int
main(void)
{
#pragma omp parallel
{
extern void foo(void);
foo ();
}
return 0;
}
p2.c.003t.original:
;; Function main (null)
{
#pragma omp parallel
{
{
{
extern void foo (void);
foo ();
}
}
}
return 0;
}
p2.c.004t.gimple:
main ()
{
int D.1749;
#pragma omp parallel
{
{
extern void foo (void);
foo ();
}
}
D.1749 = 0;
return D.1749;
}
main._omp_fn.0 (void * .omp_data_i)
{
<bb 5>:
<bb 3>:
foo ();
return;
}
p2.c.006t.omplower:
;; Function main (main, funcdef_no=0, decl_uid=1743, symbol_order=0)
main ()
{
int D.1749;
{
#pragma omp parallel [child fn: main._omp_fn.0 (???)]
{
extern void foo (void);
foo ();
}
#pragma omp return
}
D.1749 = 0;
return D.1749;
}
p2.c.007t.lower, p2.c.010t.eh:
;; Function main (main, funcdef_no=0, decl_uid=1743, symbol_order=0)
main ()
{
int D.1749;
#pragma omp parallel [child fn: main._omp_fn.0 (???)]
foo ();
#pragma omp return
D.1749 = 0;
goto <D.1754>;
<D.1754>:
return D.1749;
}
p2.c.011t.cfg:
;; Function main (main, funcdef_no=0, decl_uid=1743, symbol_order=0)
[...]
main ()
{
int D.1749;
<bb 2>:
#pragma omp parallel [child fn: main._omp_fn.0 (???)]
<bb 3>:
foo ();
#pragma omp return
<bb 4>:
D.1749 = 0;
return D.1749;
}
p2.c.012t.ompexp:
;; Function main (main, funcdef_no=0, decl_uid=1743, symbol_order=0)
OMP region tree
bb 2: gimple_omp_parallel
bb 3: GIMPLE_OMP_RETURN
Introduced new external node (foo/2).
Merging blocks 2 and 6
Merging blocks 2 and 4
main ()
{
int D.1749;
<bb 2>:
__builtin_GOMP_parallel (main._omp_fn.0, 0B, 0, 0);
D.1749 = 0;
return D.1749;
}
p2.c.015t.ssa:
;; Function main._omp_fn.0 (main._omp_fn.0, funcdef_no=1, decl_uid=1751,
symbol_order=1)
main._omp_fn.0 (void * .omp_data_i)
{
<bb 5>:
<bb 3>:
foo ();
return;
}
;; Function main (main, funcdef_no=0, decl_uid=1743, symbol_order=0)
main ()
{
int _3;
<bb 2>:
__builtin_GOMP_parallel (main._omp_fn.0, 0B, 0, 0);
_3 = 0;
return _3;
}
Grüße,
Thomas
pgpv_AdE6Cp9f.pgp
Description: PGP signature
