<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Not sure if this is the root cause, but one difference between the
two lines is the "-analyse" on the first one. This will change
behaviour between the two runs.<br>
<br>
<br>
<div class="moz-cite-prefix">On 01/16/2015 11:28 AM, Hao Yu (Cody)
wrote:<br>
</div>
<blockquote
cite="mid:CA+N53VnEUXfBqNU9Qxh-6fTh3VAmezmNJ9XtXZNL9XD1w_VRqQ@mail.gmail.com"
type="cite">
<div dir="ltr"><span style="font-size:13px">Hello,</span>
<div style="font-size:13px"><br>
</div>
<div style="font-size:13px">
<div>I am trying to use Dependence analysis to figure out some
information form my benchmarks. However, I got different
results by using LLVM analysis and my own pass. For example
I have this case:</div>
<div><br>
</div>
<div><b><i>int test(int a, int* out, int N)</i></b></div>
<div><b><i>{</i></b></div>
<div><b><i> int sum = 0;</i></b></div>
<div><b><i> for(i = 2; i < N; ++i)<br>
{</i></b></div>
<div><b><i> out[i] = a + i;</i></b></div>
<div><b><i> sum += out[i - 2];<br>
}</i></b></div>
<div><b><i> return sum;</i></b></div>
<div><b><i>}</i></b></div>
<div><br>
</div>
<div>I compiled this C code by using the following command:</div>
<div><br>
</div>
<div><b><i>clang -fno-unroll-loops -emit-llvm -O2 -c -o
test.bc test.c</i></b><br>
</div>
<div><br>
</div>
<div>Then I run DependenceAnalysis pass:</div>
<div><br>
</div>
<div><b><i>opt -basicaa -mem2reg -indvars -instcombine
-instnamer -loop-simplify -mergereturn -da -analyze
test.bc > /dev/null</i></b></div>
<div><br>
</div>
<div>and got this result:</div>
<div><br>
</div>
<div>
<div><b><i>Printing analysis 'Dependence Analysis' for
function 'test':</i></b></div>
<div><b><i>da analyze - none!</i></b></div>
<div><b><i>da analyze - consistent flow [2]!</i></b></div>
<div><b><i>da analyze - none!</i></b></div>
</div>
<div><br>
</div>
<div>Actually this what I expect to got. However if I write a
pass like this:</div>
<div><br>
</div>
<div><b><i>TestPass.h</i></b></div>
<div>
<div><b><i> virtual void getAnalysisUsage(AnalysisUsage
&AU) const</i></b></div>
<div><b><i> {</i></b></div>
<div><b><i> AU.setPreservesAll();</i></b></div>
<div><b><i> AU.addRequired<DependenceAnalysis>();</i></b></div>
<div><b><i> }</i></b></div>
</div>
<div><br>
</div>
<div><b><i>TestPass.cpp</i></b></div>
<div>
<div><b><i>bool TestPass::runOnFunction(Function& F)</i></b></div>
<div><b><i>{</i></b></div>
<div><b><i> llvmDependenceAnalysis =
&(getAnalysis<DependenceAnalysis>(F));</i></b></div>
<div><b><i><br>
</i></b></div>
<div><b><i> // The following code is copied from
DependenceAnalysis.cpp:dumpExampleDependence (157 -
182)</i></b></div>
<div><b><i> for (inst_iterator SrcI = inst_begin(F), SrcE
= inst_end(F); SrcI != SrcE; ++SrcI) { ... SKIP... }</i></b></div>
<div><b><i> </i></b></div>
<div><b><i> return true; </i></b></div>
<div><b><i>}</i></b></div>
</div>
<div><br>
</div>
<div>And I executed this pass by using the following command:</div>
<div><br>
</div>
<div><b><i>opt -basicaa </i></b><b><i>-mem2reg -indvars
-instcombine -instnamer -loop-simplify -mergereturn</i></b><b><i> -load
./TestPass.so -test-pass test.bc > /dev/null</i></b></div>
<div><br>
</div>
<div>at this time I got:</div>
<div><br>
</div>
<div>
<div><b><i>da analyze - confused!</i></b></div>
<div><b><i>da analyze - confused!<br>
</i></b></div>
<div><b><i>da analyze - confused!</i></b><br>
</div>
</div>
<div><br>
</div>
<div>Am I doing a wrong usage about this analysis?</div>
<div><br>
</div>
<div>Hao</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>