[LLVMdev] How to gather data dependences
Valmico
valmico88 at gmail.com
Fri Aug 9 13:05:54 PDT 2013
2013/8/8 Preston Briggs <preston.briggs at gmail.com>
>
> Hi,
>
> The DependenceAnalysis pass isn't reliable yet; it has several errors that
> need to be corrected. These manifest by the analysis claiming there's no
> dependence when one in fact exists.
>
> Your proposed scheme of testing every pair of instructions is
> asymptotically expensive, requiring O(n^2) tests, where each test is
> already fairly expensive. I describe (or start to describe) a better
> approach here<https://sites.google.com/site/parallelizationforllvm/building-the-dependence-graph>
> .
>
> In the meantime, you should be getting better results than you report.
> You'll want to use several other passes in conjunction with DA. Try
> something like
>
> opt -basicaa -mem2reg -simplifycfg -loop-simplify -loop-rotate
> -simplifycfg -instcombine -indvars -da
>
>
> Also, a confused dependences mean that the analysis wasn't able to prove
> anything; a FullDependence means the analysis was able to prove some facts,
> though it wasn't actually able to disprove the dependence. It's not
> reasonable to cast a Dependence to a FullDependence.
>
> Preston
>
>
Hi,
I assume that DA is tool capable to give me an list of Dependencies in code
or at least a easy way to test instructions without much knowledge about
ZIV SIV, and other tests that has to be done find out dependencies?
Personally i'm an PHP programmer and i feel lack of proper (at least for
me) documentation with good use examples about LLVM, and it's modules like
analysis, transforms etc.
I agree that testing every pair is asymptotically expensive, requiring
O(n^2), but it doesnt matter for me for now.
This is code i came up for now:
virtual bool runOnFunction(Function &F) {
DependenceAnalysis &DA = this->getAnalysis<DependenceAnalysis>();
std::vector<Instruction*> instructions;
for( inst_iterator I = inst_begin(F); I != inst_end(F); I++ ) {
if( isa<StoreInst>( *I ) || isa<LoadInst>( *I ) ) {
errs() << "Instruction " << *I << '\n';
for(std::vector<Instruction*>::iterator it =
instructions.begin(); it != instructions.end(); it++) {
Dependence *dep = DA.depends(&*I,*it,false);
if( dep == NULL ) {
//errs() << " no dependence." << '\n';
} else if( dep->isConfused() == true ) {
if( dep->isInput() ) {
errs() << '\t' << **it << " input dependence." <<
'\n';
} else if( dep->isOutput() ) {
errs() << '\t' << **it << " output dependence." <<
'\n';
} else if( dep->isFlow() ) {
errs() << '\t' << **it << " flow dependence." <<
'\n';
} else if( dep->isAnti() ) {
errs() << '\t' << **it << " anti dependence." <<
'\n';
}
} else if( dep->isConfused() == false ) {
errs() << "# full dependence." << '\n';
//if( FullDependence *FDep = cast<FullDependence>( dep
) ) {
// errs() << " full dep casted" << '\n';
//}
}
}
instructions.push_back(&*I);
}
}
}
Most likely i'm moving totally in wrong direction, but thats what happens
when people do sth completly blindly. Please dont' bother performance
concerns, it's my least problem.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130809/0941c160/attachment.html>
More information about the llvm-dev
mailing list