<div dir="ltr">I'm using llvm 3.3,which was built with the options below:<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="monospace, monospace">../llvm-3.3.src/configure --prefix=/home/admin/jianzhang.zj/llvm/llvm-install-2/ --with-gcc-toolchain=/home/admin/jianzhang.zj/gcc-4.8.2-install/ --enable-optimized --enable-debug-runtime --enable-debug-symbols --disable-assertions --with-oprofile=/home/admin/jianzhang.zj/oprofile-0.9.9-install/ --enable-profiling --with-intel-jitevents</font></blockquote><div><br></div><div>The oprofile's version is 0.99</div><div><br></div><div>I'm using the following Makefile to build the Fibonacci examples in the llvm source code:</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">LLVM_CONFIG=/home/admin/jianzhang.zj/llvm/llvm-install-2/bin/llvm-config<br>CLANG=/home/admin/jianzhang.zj/llvm/llvm-install-2/bin/clang<br>SRC_IDR=$(PWD)<br>LLVM_FLAGS=$(shell $(LLVM_CONFIG) --cxxflags --cppflags --ldflags --ldflags --libs )<br>COMMON_FLAGS= -DTEST -DMCJIT -g -rdynamic -O3 -lpthread -ldl <br>SRC_DIR = .<br>INCLUDE = -I/home/admin/jianzhang.zj/llvm/llvm-install-2/include/<br>CXX=g++<br>PROGRAM= fibonacci<br>all: clean output<br>output: $(PROGRAM)<br>$(PROGRAM):<br><span class="" style="white-space:pre"> </span>$(CXX) $@.cpp $(INCLUDE) -o $@ $(COMMON_FLAGS) $(LLVM_FLAGS) -fexceptions<br>clean:<br><span class="" style="white-space:pre">       </span>rm -f $(PROGRAM)  *.o *LOG*</blockquote></div><div><br></div><div>then I use the operf command to sampling:</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="monospace, monospace">$ /home/admin/jianzhang.zj/oprofile-0.9.9-install/bin/operf ./fibonacci 40<br></font><font face="monospace, monospace">operf: Profiler started<br></font><font face="monospace, monospace">verifying... OK<br></font><font face="monospace, monospace">We just constructed this LLVM module:</font><font face="monospace, monospace"><br></font><font face="monospace, monospace">---------<br></font><font face="monospace, monospace">; ModuleID = 'test'</font><font face="monospace, monospace"><br></font><font face="monospace, monospace">define i32 @fib(i32 %AnArg) {<br></font><font face="monospace, monospace">EntryBlock:<br></font><font face="monospace, monospace">  %cond = icmp sle i32 %AnArg, 2<br></font><font face="monospace, monospace">  br i1 %cond, label %return, label %recurse</font><font face="monospace, monospace"><br></font><font face="monospace, monospace">return:                                           ; preds = %EntryBlock<br></font><font face="monospace, monospace">  ret i32 1</font><font face="monospace, monospace"><br></font><font face="monospace, monospace">recurse:                                          ; preds = %EntryBlock<br></font><font face="monospace, monospace">  %arg = sub i32 %AnArg, 1<br></font><font face="monospace, monospace">  %fibx1 = tail call i32 @fib(i32 %arg)<br></font><font face="monospace, monospace">  %arg1 = sub i32 %AnArg, 2<br></font><font face="monospace, monospace">  %fibx2 = tail call i32 @fib(i32 %arg1)<br></font><font face="monospace, monospace">  %addresult = add i32 %fibx1, %fibx2<br></font><font face="monospace, monospace">  ret i32 %addresult<br></font><font face="monospace, monospace">}<br></font><font face="monospace, monospace">---------<br></font><font face="monospace, monospace">starting fibonacci(40) with JIT...<br></font><font face="monospace, monospace">Result: 102334155</font><font face="monospace, monospace"><br></font><font face="monospace, monospace">Profiling done.</font></blockquote></div><div><br></div><div>then use opreport:</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="monospace, monospace">$ /home/admin/jianzhang.zj/oprofile-0.9.9-install/bin/opreport <br></font><font face="monospace, monospace">Using /apsarapangu/disk8/jianzhang.zj/llvm/llvm-3.3.src/examples/Fibonacci/oprofile_data/samples/ for samples directory.<br></font><font face="monospace, monospace">CPU: Intel Sandy Bridge microarchitecture, speed 2199.75 MHz (estimated)<br></font><font face="monospace, monospace">Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit mask of 0x00 (No unit mask) count 100000<br></font><font face="monospace, monospace">CPU_CLK_UNHALT...|<br></font><font face="monospace, monospace">  samples|      %|<br></font><font face="monospace, monospace">------------------<br></font><font face="monospace, monospace">    16252 100.000 fibonacci<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">    </span>CPU_CLK_UNHALT...|<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">       </span>  samples|      %|<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">   </span>------------------<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">       </span>    15368 94.5607 anon (tgid:60546 range:0x7faa17b40000-0x7faa17bbffff)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">        </span>      656  4.0364 no-vmlinux<br></font><font face="monospace, monospace"><span class="" style="white-space:pre"> </span>      139  0.8553 <a href="http://libc-2.5.so">libc-2.5.so</a><br></font><font face="monospace, monospace"><span class="" style="white-space:pre"> </span>       54  0.3323 fibonacci<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">  </span>       33  0.2031 <a href="http://ld-2.5.so">ld-2.5.so</a><br></font><font face="monospace, monospace"><span class="" style="white-space:pre">     </span>        2  0.0123 libstdc++.so.6.0.8</font></blockquote></div><div><br></div><div>here the '<b><font color="#ff0000">anon (tgid:60546 range:0x7faa17b40000-0x7faa17bbffff)</font></b>' isn't the result I expected, so I think there must be something wrong and I use the ldd command to check the dependencies:</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="monospace, monospace">$ ldd fibonacci<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">    </span>linux-vdso.so.1 =>  (0x00007fffcd1ba000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">     </span>libpthread.so.0 => /lib64/libpthread.so.0 (0x00000031edc00000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">        </span>libdl.so.2 => /lib64/libdl.so.2 (0x00000031ed800000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">  </span>libz.so.1 => /lib64/libz.so.1 (0x00000031ee400000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">    </span>librt.so.1 => /lib64/librt.so.1 (0x00000031ef000000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">  </span>libopagent.so.1 => /home/admin/jianzhang.zj/oprofile-0.9.9-install//lib/oprofile/libopagent.so.1 (0x00007fb835b86000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre"> </span>libm.so.6 => /lib64/libm.so.6 (0x00000031ee000000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">    </span>libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000031f3000000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">      </span>libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000031f0800000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">    </span>libc.so.6 => /lib64/libc.so.6 (0x00000031ed400000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">    </span>/lib64/ld-linux-x86-64.so.2 (0x00000031ed000000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre"> </span><a href="http://libbfd-2.24.so">libbfd-2.24.so</a> => /home/admin/jianzhang.zj/binutils-2.24-install/lib/<a href="http://libbfd-2.24.so">libbfd-2.24.so</a> (0x00007fb83587b000)<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">  </span>libiberty.so => /home/admin/jianzhang.zj/binutils-2.24-install/lib/libiberty.so (0x00007fb83563e000)</font><font face="monospace, monospace"><br></font><font face="monospace, monospace"><br></font><font face="monospace, monospace">$ ldd -u fibonacci<br></font><font face="monospace, monospace">Unused direct dependencies:<br></font><span class="" style="white-space:pre"><font face="monospace, monospace">   <br></font></span><font face="monospace, monospace"><span class="" style="white-space:pre"> </span>/lib64/libdl.so.2<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">        </span>/lib64/libz.so.1<br></font><font face="monospace, monospace"><span class="" style="white-space:pre"> </span>/lib64/librt.so.1<br></font><font face="monospace, monospace"><span class="" style="white-space:pre">        </span>/home/admin/jianzhang.zj/oprofile-0.9.9-install//lib/oprofile/libopagent.so.1</font></blockquote></div><div><br></div><div>can anyone tell me how to profile the llvm JITed code or which step was wrong ?</div><div><br></div><div>thanks very much.</div><div><br></div></div>