[llvm-commits] [PATCH] Preparation for Optimal Edge Profiling: Build libprofile as bytecode.

Andreas Neustifter e0325716 at student.tuwien.ac.at
Tue Aug 25 02:27:48 PDT 2009


Hi Daniel!

Daniel Dunbar wrote:
 >
 > On Mon, Aug 24, 2009 at 12:06 PM, Andreas
 > Neustifter<e0325716 at student.tuwien.ac.at> wrote:
 >>
 >> Daniel Dunbar wrote:
 >>>
 >>> The exported change is fine, but I don't think MODULE_NAME is
 >>> necessary. libprofile_rt.bca (a bitcode archive) is already getting
 >>> built, isn't that good enough?
 >>
 >> I used that for bytecode linking of the whole module, there its not
 >> possible to use the libprofile_rt.bca. But its also possible to link the
 >> libprofile_rt.so instead later on. I will commit only the symbol export.
 >
 > I still don't understand, it should always be possible to link using a
 > .bca in any place that linking a .bc would work. What is the situation
 > where this fails?

I have the SPEC benchmark modified to use custom scripts instead of compiler and linker thus being able to use all the SPEC features but using LLVM instead of GCC in a very flexible way.

That said the scripts do the following to translate a series of C files into an executable:

---- llvm-gcc -g -emit-llvm -c  bits.c  -o bits.o
---- llvm-gcc -g -emit-llvm -c  deflate.c  -o deflate.o
---- llvm-gcc -g -emit-llvm -c  gzip.c  -o gzip.o
---- llvm-gcc -g -emit-llvm -c  getopt.c  -o getopt.o
---- llvm-gcc -g -emit-llvm -c  inflate.c  -o inflate.o
---- llvm-gcc -g -emit-llvm -c  lzw.c  -o lzw.o
---- llvm-gcc -g -emit-llvm -c  spec.c  -o spec.o
---- llvm-gcc -g -emit-llvm -c  trees.c  -o trees.o
---- llvm-gcc -g -emit-llvm -c  unlzh.c  -o unlzh.o
---- llvm-gcc -g -emit-llvm -c  unlzw.c  -o unlzw.o
---- llvm-gcc -g -emit-llvm -c  unpack.c  -o unpack.o
---- llvm-gcc -g -emit-llvm -c  unzip.c  -o unzip.o
---- llvm-gcc -g -emit-llvm -c  util.c  -o util.o
---- llvm-gcc -g -emit-llvm -c  zip.c  -o zip.o
---- llvm-ld  -stats -time-passes -link-as-library -disable-opt zip.o util.o unzip.o unpack.o unlzw.o unlzh.o trees.o spec.o lzw.o inflate.o getopt.o gzip.o deflate.o bits.o  -o gzip.0.o
---- opt -std-compile-opts -stats -time-passes gzip.0.o -f -o gzip.1.o
---- opt  -stats -time-passes -insert-edge-profiling gzip.1.o -f -o gzip.2.o
---- llvm-ld  -stats -time-passes -link-as-library -disable-opt /localtmp/astifter/llvm/llvm-van-install/lib/libprofile_rt.bca gzip.2.o -o gzip.3.o

Here I used the BCA you said should work fine, but later on it gives troubles...

---- llc  gzip.3.o -f -o gzip.4.s
---- gcc -g  gzip.4.s -o gzip
---- /tmp/cc2XnTEf.o: In function `main':
---- /nfs/a5/astifter/astifter/spec_cpu_2000_img/benchspec/CINT2000/164.gzip/run/00000001//spec.c:253: undefined reference to `llvm_start_edge_profiling'
---- collect2: ld returned 1 exit status

So the symbol llvm_start_edge_profiling that should be present in libprofile_rt.bca does not get linked by the llvm-ld.

Am I doing something wrong here? When using a regular bitcode file this works fine.

What I am doing now is linking the native library later on:

---- llvm-ld  -stats -time-passes -link-as-library -disable-opt zip.o util.o unzip.o unpack.o unlzw.o unlzh.o trees.o spec.o lzw.o inflate.o getopt.o gzip.o deflate.o bits.o  -o gzip.0.o
---- opt -std-compile-opts -stats -time-passes gzip.0.o -f -o gzip.1.o
---- opt  -stats -time-passes -insert-edge-profiling gzip.1.o -f -o gzip.2.o
---- llc  gzip.2.o -f -o gzip.3.s
---- gcc -g   /localtmp/astifter/llvm/llvm-van-install/lib/libprofile_rt.so gzip.3.s -o gzip

Andi




More information about the llvm-commits mailing list