Discussion:
[Open64-devel] about data flow analysis
daniel tian
2013-10-11 22:46:25 UTC
Permalink
hey guys:
I have a question about how to get the in/out variables list for a
block in high level whirl? I checked the def/use chain. But there is no
such thing in WOPT. I mean there must be a existing module to analysis a
input block and get the in/out list.

For example:

Block1:

sum = 0;
for(i=0; i<n; i++)
{
A[i] = B[c] + C[c]
sum+=A[i];
}

For here, this block require the input list"B, C, n", and the output is "A,
sum". And "i" is obviously defined in the block. BTW, here the block is in
IR, but not three address code.

Does anyone have clue?
Any suggestion is appreciated.

Thank you very much.
Daniel
Kun Ling
2013-10-14 04:20:24 UTC
Permalink
Hi Daniel,

Firstly, I am also not an expert in WOPT and Open64. The following is
just for some of clue that maybe helpful to you.

1. Whirl is AST based IR, while the in/out list used in Data-flow
analysis is based on BB and CFG.

2. According to the Pre_Optimizer() in be/opt/opt_main.cxx. At the
beginning of WOPT, WHIRL IR will be translated into CFG ( a different IR
for SSA-based DFA analysis) after comp_unit->Ssa()->Construct().

3. set a breakpoint after the SSA construction using gdb, and run
comp_unit->Ssa()->Print(), Comp_unit->Cfg()->Print(stderr,1,-1),
Cr->Print_str(true), cr->Print_node(1,stderr), Sr->Print(stderr),
BB_Node->Print(stderr) for object of comp_unit, CODEREP, STMTREP, BB_Node
may help understand what is going on during the OPT, and also help you to
get an idea of how the in/out is generated.

4. If you want to know the actual definition of in/out list of BBs in
CFG of WOPT, looking into the code of opt_bb.cxx/h may be a good start.


Regards,
Kun Ling
Post by daniel tian
I have a question about how to get the in/out variables list for a
block in high level whirl? I checked the def/use chain. But there is no
such thing in WOPT. I mean there must be a existing module to analysis a
input block and get the in/out list.
sum = 0;
for(i=0; i<n; i++)
{
A[i] = B[c] + C[c]
sum+=A[i];
}
For here, this block require the input list"B, C, n", and the output is
"A, sum". And "i" is obviously defined in the block. BTW, here the block is
in IR, but not three address code.
Does anyone have clue?
Any suggestion is appreciated.
Thank you very much.
Daniel
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Open64-devel mailing list
https://lists.sourceforge.net/lists/listinfo/open64-devel
--
http://www.lingcc.com
Jian-Xin Lai
2013-10-15 23:49:26 UTC
Permalink
The first step is to define the "def" clear. For example,
A[i] = ...
It doesn't define A or i. The value of A and i are not changed in this
statement. You should always take care about the indirect access when you
are talking about "def".

In the next, if you are working on H/VH WHIRL, you just need to traverse
the WHIRL tree and take different actions according to the operator of the
WHIRL node. For example:

void Collect_Def_Use(WN* wn) {
switch(WN_Operator(wn)) {
case OPR_BLOCK:
......
break;
case OPR_LDID:
......
break;
case OPR_STID:
......
break;
case OPR_ILOAD:
......
break;
case OPR_ISTORE:
......
default:
for (INT i = 0; i < WN_kid_count(wn); ++i) {
.......
}
}
}
Post by Kun Ling
Hi Daniel,
Firstly, I am also not an expert in WOPT and Open64. The following is
just for some of clue that maybe helpful to you.
1. Whirl is AST based IR, while the in/out list used in Data-flow
analysis is based on BB and CFG.
2. According to the Pre_Optimizer() in be/opt/opt_main.cxx. At the
beginning of WOPT, WHIRL IR will be translated into CFG ( a different IR
for SSA-based DFA analysis) after comp_unit->Ssa()->Construct().
3. set a breakpoint after the SSA construction using gdb, and run
comp_unit->Ssa()->Print(), Comp_unit->Cfg()->Print(stderr,1,-1),
Cr->Print_str(true), cr->Print_node(1,stderr), Sr->Print(stderr),
BB_Node->Print(stderr) for object of comp_unit, CODEREP, STMTREP, BB_Node
may help understand what is going on during the OPT, and also help you to
get an idea of how the in/out is generated.
4. If you want to know the actual definition of in/out list of BBs in
CFG of WOPT, looking into the code of opt_bb.cxx/h may be a good start.
Regards,
Kun Ling
Post by daniel tian
I have a question about how to get the in/out variables list for a
block in high level whirl? I checked the def/use chain. But there is no
such thing in WOPT. I mean there must be a existing module to analysis a
input block and get the in/out list.
sum = 0;
for(i=0; i<n; i++)
{
A[i] = B[c] + C[c]
sum+=A[i];
}
For here, this block require the input list"B, C, n", and the output is
"A, sum". And "i" is obviously defined in the block. BTW, here the block is
in IR, but not three address code.
Does anyone have clue?
Any suggestion is appreciated.
Thank you very much.
Daniel
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Open64-devel mailing list
https://lists.sourceforge.net/lists/listinfo/open64-devel
--
http://www.lingcc.com
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Open64-devel mailing list
https://lists.sourceforge.net/lists/listinfo/open64-devel
--
Regards,
Lai Jian-Xin
Loading...