<div dir="ltr"><div>In the example you provided, the author uses the DependenceAnalysis to retrieve a dependence for the src and dest instructions. Note the line: <span style="font-family:palatino,georgia,verdana,arial,sans-serif;font-size:medium;line-height:24px;text-align:justify">dependenceAnalysis->depends(instructions[src], instructions[dst], true);</span></div><div>Without really exploring much I think you should note that getDistance is a function of the Dependence class and not DependenceAnalysis. You need to retrieve a dependence or dependencies to operate with getDistance. In your code you're just pulling the Analysis information and immediately attempting to retrieve the distance.</div>It might help to take a look at how DependenceAnalysis and getDistance are used in:  






<p><span>lib/Transforms/Scalar/LoopInterchange.cpp</span></p><p><span>Jake</span></p><p><span><br></span></p></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 28, 2015 at 11:42 PM, Manideepa Mukherjee <span dir="ltr"><<a href="mailto:manideepa.mukherjee@gmail.com" target="_blank">manideepa.mukherjee@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,<br><br></div>I am trying to use the DependenceAnalysis pass to get the Distance vector for the innermost loop. I am in LLVM learing process. I have used the following code inside my original code to get the distance vector. It is not giving any syntax error but it is has some logical but and giving segmentation fault.<br><br>void getAnalysisUsage(AnalysisUsage &AU) const {<br>             AU.setPreservesAll();<br>      AU.addRequired<PostDominatorTree>();<br>      AU.addRequired<LoopInfo>();<br>      AU.addRequired<DependenceAnalysis>();<br>      AU.addPreserved<DependenceAnalysis>();<br>    AU.addRequired<ScalarEvolution>();<br>   AU.addPreserved<ScalarEvolution>();<br>  AU.addRequired<AliasAnalysis>();<br>   AU.addPreserved<AliasAnalysis>();<br>   AU.addRequired<MemoryDependenceAnalysis>();<br>   AU.addPreserved<MemoryDependenceAnalysis>();<br>           }<br><br>In runOnFunction I have used dependence = &getAnalysis<DependenceAnalysis>();<br>if(L->getSubLoops().size()==0)<br>            {    Dependence* dependence;<br>                const SCEV* scev = dependence->getDistance(loopID);<br>               ....<br>               ................ <br clear="all"><div><div>              .............<br>           }<br></div><div>loopID is and unsigned int variable which I have increased after each time after doing some other operations on loop like printing the basic block of each loop.<br><br></div><div>Is this the correct way to do it. Any example would be a great help for me to understand this. For a loop how can I print the distance vector using getDistance(). I have tried the da pass which worked fine for the example given in this <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__comments.gmane.org_gmane.comp.compilers.llvm.devel_55437&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=qQylmJlO7KBr1bWLPo0kow2CiegPX7dhwSWuMwIVd3Y&s=vrl-8n0v-s7TeSDdYauMvjD8mNPAR0MqB1TEILSFxgU&e=" target="_blank">http://comments.gmane.org/gmane.comp.compilers.llvm.devel/55437</a> link. please help.<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div><br><br>-- <br><div><div dir="ltr"><div>Thanks & Regards,<br>Manideepa Mukherjee<br>Contact No:- <a href="tel:%2B91-7428062726" value="+917428062726" target="_blank">+91-7428062726</a></div></div></div>
</div></font></span></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>