[LLVMdev] Using CostModel to estimate machine cycles of each instruction

Manish Gupta mgupta.iitr at gmail.com
Mon Aug 4 10:08:46 PDT 2014


Ya I am using it the same way. By dividing it into header file and
including it from  "llvm/Analysis/CostModel.h"

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.

One way is running it recursively on calls and return summaries. Is there a
direct way than this?

Thanks!
Manish


On Fri, Jul 18, 2014 at 1:13 AM, Jonas Wagner <jonas.wagner at epfl.ch> wrote:

> Hi Don,
>
> 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.
>
> In order to be able to use it from a different pass, I split it into a
> source and header file (attached).
>
> You can then add it to your pass dependencies, and use it as follows:
> custom::CostModelAnalysis &CM = getAnalysis<custom::CostModelAnalysis>();
> Instruction *Inst = ...
> unsigned Cost = CM.getInstructionCost(CI);
> if (Cost != (unsigned)(-1)) {
>   // do something
> }
>
> Hope this helps!
> Jonas
>
>
> On Thu, Jul 17, 2014 at 4:10 AM, <donney.blue at gmail.com> wrote:
>
>> 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.
>>
>> Thank you very much.
>>
>>
>> Don
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140804/9f8d9c0a/attachment.html>


More information about the llvm-dev mailing list