[LLVMdev] Fwd: LLVM Help

Omar Abed Alkar Darwish omar.darwish at wmich.edu
Fri Nov 7 15:31:32 PST 2014


> Hi All,

> Attached above my InstCount.cpp after modification. I did simple
> modification which is the following (The statements between the
> ************** ) :

> bool InstCount::runOnFunction(Function &F) {
> unsigned StartMemInsts =
> NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst +
> NumInvokeInst + NumAllocaInst;

> //*******************************Omar********
> FILE *f = fopen("omar.txt", "w");
> if (f == NULL)
> {
> printf("Error opening file!\n");
> exit(1);
> }
> fprintf(f, "NumGetElementPtrInst: %d\n, NumLoadInst:
> %d\n,NumStoreInst: %d\n,NumCallInst: %d\n,NumInvokeInst:
> %d\n,NumAllocaInst: %d\n",NumGetElementPtrInst ,
> NumLoadInst,NumStoreInst,NumCallInst,NumInvokeInst,NumAllocaInst);
> fclose(f);
> //********************************************
> visit(F);
> unsigned EndMemInsts =
> NumGetElementPtrInst + NumLoadInst + NumStoreInst + NumCallInst +
> NumInvokeInst + NumAllocaInst;
> TotalMemInst += EndMemInsts-StartMemInsts;
> return false;
> }

> each time I run instcount pass in different .bc files I got the same
> results which are

> NumGetElementPtrInst: 163959956
> , NumLoadInst: 163960670
> ,NumStoreInst: 0
> ,NumCallInst: 0
> ,NumInvokeInst: 163959956
> ,NumAllocaInst: 163960722

> Those numbers are not changed even the bc file changed.

> Please:
> 1- Give me the right way to extract the above information from any
> c++ source code (attached also the .bc files and their corresponding
> c++ files)
> 2-If I changed the InstCount.cpp do I have to make llvm from the
> scratch or their is a simple way to do the make (where it doesn't
> take long time just take the minor changes)
> 3- how can I justify those huge numbers above for simple programs.

> Thank you so much for your help.

> Please advice me as I told you I am completely new with LLVM and I am
> really suffering.

> --Omar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141107/adbcf5ed/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aa.bc
Type: application/octet-stream
Size: 884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141107/adbcf5ed/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aa.c
Type: text/x-csrc
Size: 106 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141107/adbcf5ed/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: welcome.bc
Type: application/octet-stream
Size: 940 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141107/adbcf5ed/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: welcome.c
Type: text/x-csrc
Size: 70 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141107/adbcf5ed/attachment-0001.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: InstCount.cpp
Type: text/x-c++src
Size: 3241 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141107/adbcf5ed/attachment.cpp>


More information about the llvm-dev mailing list