<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Ya I am using it the same way. By </span><font face="arial, sans-serif" style="font-family:arial,sans-serif;font-size:13px">dividing</font><span style="font-family:arial,sans-serif;font-size:13px"> it into header file and including it from "llvm/Analysis/CostModel.h"</span><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">I believe it returns -1 for all function calls? How can I get make it return cost of each function call inside my basic block. </div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">One way is running it recursively on calls and return summaries. Is there a direct way than this?</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">Thanks!</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 18, 2014 at 1:13 AM, Jonas Wagner <span dir="ltr"><<a href="mailto:jonas.wagner@epfl.ch" target="_blank">jonas.wagner@epfl.ch</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><div><div><div><div><div><div>Hi Don,<br><br></div>In it's current version, tha pass can only be used via "opt -cost-model -analyze". It will then print out the estimated cost for every instruction.<br>
<br></div>In order to be able to use it from a different pass, I split it into a source and header file (attached).<br><br></div>You can then add it to your pass dependencies, and use it as follows:<br>custom::CostModelAnalysis &CM = getAnalysis<custom::CostModelAnalysis>();<br>
</div>Instruction *Inst = ...<br>unsigned Cost = CM.getInstructionCost(CI);<br>if (Cost != (unsigned)(-1)) {<br></div> // do something<br>}<br><br></div>Hope this helps!<span class="HOEnZb"><font color="#888888"><br></font></span></div>
<span class="HOEnZb"><font color="#888888">Jonas<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra">
<br>
<br><div class="gmail_quote">On Thu, Jul 17, 2014 at 4:10 AM, <span dir="ltr"><<a href="mailto:donney.blue@gmail.com" target="_blank">donney.blue@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
There is CostModel.cpp since LLVM3, I am wondering if anyone can give me an concrete example on how to use this pass to estimate cycles used in a given IR file.<br>
<br>
Thank you very much.<br>
<br>
<br>
Don<br>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
</blockquote></div><br></div>
</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" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>