Tuesday, September 25, 2007

Profiling LLVM

It is possible to use gprof to profile the LLVM tools such as llc and such. It is necessary to build LLVM with the profiling functions enabled. To do this, go to the LLVM root and type:

make -j2 ENABLE_PROFILING=1

That will build a 'Profile' directory containing all the binaries of LLVM tools. Now, every time you run llc it will produce the gmon.out file containing profiling information. This file can be read with gprof using the command line:

gprof $PATH_TO_LLC/llc > out.prof

Sunday, September 23, 2007

Jump tables

Jump tables are a nice idea, but the way that LLVM is producing them is hurting the pass to break critical edges. My solution, not quite democratic, was to forbid jump tables altogether. To do this, I had to edit the file SelectionDAG/SelectionDAGISel.cpp. The method visitSwitch is responsible for creating jump tables. I simply commented that code out.
Now, my SelectionDAGISel.cpp looks like this.

Monday, September 17, 2007

Four little things

Four things. First, this script from Lang Hames happens to be very useful when building LLVM. It unpacks the downloaded files and compiles everything, including the sources.

Second, enabling spec 2000 in LLVM 2.0 is different from 1.9. For the latter, just use the command in the post below. For the former, use:


./configure --enable=spec=/project/fernando --with-spec=/project/fernando --with-externals=/project/fernando


Third, to run llvm 2.0 is a little different from 1.9. In order to produce .bc files, the following can be used:


llvm-gcc -o XXXX.bc XXXX.c -c -emit-llvm -O1


Finally, when using the test suite that comes with LLVM, if you want, say, to enable the beta llc, and disable the C-back end:


make TEST=nightly report.html DISABLE_JIT=1 ENABLE_LLCBETA=1


To specify the beta-options, change Makefile.program under the platform that you are running.

Friday, September 14, 2007

Teste Suite 1.9

I have just finished installing the test suite of LLVM v1.9. The whole process is not that difficult, but I had to directly download the test files. The version in svn was made for the most recent version of LLVM. Additionally, I had to create a symbolic link pointing to the location of the spec files, e.g: ln -s $SPEC_LOCATION/spec2000 speccpu2000. This speccpu2000 is the name that the LLVM configuration file expects. This done, I had to go to $LLVM_SRC/projects/llvm-tests and type:


./configure --enable-spec2000 --with-externals=/misc/project/fernando


That was it! To run tests, I can just use the same old command line:


make TEST=nightly report.html DISABLE_JIT=1

Wednesday, September 12, 2007

Bank of register v1.9

This is the register list for the x86 architecture in LLVM 1.9:



1: AH, 2: AL, 3: AX, 4: BH, 5: BL, 6: BP, 7: BPL, 8: BX, 9: CH, 10: CL, 11: CX, 12: DH, 13: DI, 14: DIL, 15: DL, 16: DX, 17: EAX, 18: EBP, 19: EBX, 20: ECX, 21: EDI, 22: EDX, 23: ESI, 24: ESP, 25: FP0, 26: FP1, 27: FP2, 28: FP3, 29: FP4, 30: FP5, 31: FP6, 32: MM0, 33: MM1, 34: MM2, 35: MM3, 36: MM4, 37: MM5, 38: MM6, 39: MM7, 40: R10, 41: R10B, 42: R10D, 43: R10W, 44: R11, 45: R11B, 46: R11D, 47: R11W, 48: R12, 49: R12B, 50: R12D, 51: R12W, 52: R13, 53: R13B, 54: R13D, 55: R13W, 56: R14, 57: R14B, 58: R14D, 59: R14W, 60: R15, 61: R15B, 62: R15D, 63: R15W, 64: R8, 65: R8B, 66: R8D, 67: R8W, 68: R9, 69: R9B, 70: R9D, 71: R9W, 72: RAX, 73: RBP, 74: RBX, 75: RCX, 76: RDI, 77: RDX, 78: RSI, 79: RSP, 80: SI, 81: SIL, 82: SP, 83: SPL, 84: ST(0), 85: ST(1), 86: ST(2), 87: ST(3), 88: ST(4), 89: ST(5), 90: ST(6), 91: ST(7), 92: XMM0, 93: XMM1, 94: XMM10, 95: XMM11, 96: XMM12, 97: XMM13, 98: XMM14, 99: XMM15, 100: XMM2, 101: XMM3, 102: XMM4, 103: XMM5, 104: XMM6, 105: XMM7, 106: XMM8, 107: XMM9.



And these are the classes of registers:

















































































Class ID

Number of regs

Reg size

Alignment
11644
21688
31622
4422
51644
6444
71688
82011
9784
10884
11161616
12888

Friday, September 07, 2007

AMPL

Today I used ampl for the first time. To use it, follow the following steps:



  1. specify a license file: setenv ILOG_LICENSE_FILE "/usr/share/ilog/ilm/access.ilm"



  2. start the daemon process: ./ilmd &



  3. run the ampl command: ./ampl



  4. in the command prompt, it may be necessary to specify the solver to use:
    option solver '/usr/share/ilog/ampl20021038.cplex91/cplexamp' ;



  5. Enjoy!