dg icon indicating copy to clipboard operation
dg copied to clipboard

Is data-dependence analysis driven by self-defined pointer analysis or SVF?

Open for-just-we opened this issue 3 years ago • 8 comments

Hi, author. I try to integrate dg into other project and when I use data-dependence analysis. I found not like llvm-cda-dump.cpp, in llvm-dda-dump, there seems to be no code for leveraging SVF pointer analysis. So is there support for SVF in data-dependence analysis?

for-just-we avatar Dec 20 '22 11:12 for-just-we

DG can use SVF for points-to analysis and this then propagates to data dependence analysis. If you want to use the value-flow analysis from SVF, you must do that directly via SVF API.

mchalupa avatar Dec 20 '22 11:12 mchalupa

To answer the question from the title: both, depends on the options you pass on the command line (and if you compile DG with SVF support).

mchalupa avatar Dec 20 '22 11:12 mchalupa

data

DG can use SVF for points-to analysis and this then propagates to data dependence analysis. If you want to use the value-flow analysis from SVF, you must do that directly via SVF API.

So I just simply need to replace DGLLVMPointerAnalysis with SVFPointerAnalysis?

for-just-we avatar Dec 20 '22 12:12 for-just-we

Yes, that should do the trick, check this code: https://github.com/mchalupa/dg/blob/master/tools/llvm-pta-dump.cpp#L816

mchalupa avatar Dec 20 '22 12:12 mchalupa

Yes, that should do the trick, check this code: https://github.com/mchalupa/dg/blob/master/tools/llvm-pta-dump.cpp#L816

ok, and I want to map instructions in a bc file to the instructions they depend on. So the code for data dependence analysis is

LLVMDataDependenceAnalysis DDA(M.get(), &PTA, options.dgOptions.DDAOptions);
DDA.run();
auto *SSA = static_cast<MemorySSATransformation *>(
                DDA->getDDA()->getImpl());
SSA->computeAllDefinitions();

right?

for-just-we avatar Dec 20 '22 13:12 for-just-we

This part is important:

LLVMDataDependenceAnalysis DDA(M.get(), &PTA, options.dgOptions.DDAOptions);
DDA.run();

Then you can query directly the DDA object for the definitions.

mchalupa avatar Dec 20 '22 13:12 mchalupa

This part is important:

LLVMDataDependenceAnalysis DDA(M.get(), &PTA, options.dgOptions.DDAOptions);
DDA.run();

Then you can query directly the DDA object for the definitions.

So, this part

auto *SSA = static_cast<MemorySSATransformation *>(
                DDA->getDDA()->getImpl());
SSA->computeAllDefinitions();

is only optional? If I don't run SSA, would there be differences in the data dependence results?

for-just-we avatar Dec 21 '22 06:12 for-just-we

SSA is run either way, but this code makes it to compute all the results immediately (otherwise they are computed on-demand upon querying DDA object) so that llvm-dda-dump can show dump all the results including some internal information obtained from the SSA object.

There should be no differences in the results if you omit this code.

mchalupa avatar Dec 21 '22 10:12 mchalupa