y liu via llvm-dev
2020-Apr-15 13:02 UTC
[llvm-dev] How can pass be used to optimize a project?
Hi, I have written a pass and get a psss.so file. My pass optimization relies on some of my own target files. This is how I use them when there is only one source file. For example: Pass: *Hello-pass.so* The dependent object file: *units.o* and *helper.o* Target file: *simple.c* I'm using the following command.>>> >>> */usr/local/bin/clang -emit-llvm -c -o obj/simple.bc simple.c* >>> */usr/local/bin/llvm-link obj/simple.bc ./units.o ./helper.o >obj/simple-link.bc *>>> */usr/local/bin/opt -load ../Hello-pass.so -O3 < obj/simple-link.bc >obj/simple-opt.bc *>>> */usr/local/bin/clang -o obj/simple obj/simple-opt.bc -g -O3* >>>Now, I need to optimize a large project with my pass and object file(Hello-pass.so units.o and helper.o),such as "md5sum" project. It needs to be compiled and installed using the following command:>>>>>> * ./configure*>>> * make*>>>* make install* >>>I need use LLVM to compile and optimize it. How can I apply my pass to the entire program? What should I do? Please tell me an easy way. Please help me! Thank you! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200415/91843627/attachment.html>
Victor Campos via llvm-dev
2020-Apr-17 10:20 UTC
[llvm-dev] How can pass be used to optimize a project?
Hi, one solution is to create wrappers and use them as CC and CXX (as in ./configure CC=path/to/wrapper CXX=/path/to/wrapper) in the project you are building. For example, you can create a Python script which receives the command-line arguments passed originally to the C compiler and decides what to do based on them: 1. if a "-c" is present, it's a compilation job, therefore add "-emit-llvm" to the argument list. 2. else, this is a link job, therefore call llvm-link, then opt, then generate the binary. There are a few more cases to cover depending on the project. For instance, if static libraries are built, you may need to create a wrapper for 'ar' as well. Cheers, Victor. On Wed, 15 Apr 2020 at 14:03, y liu via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > Hi, I have written a pass and get a psss.so file. My pass optimization relies on some of my own target files. > This is how I use them when there is only one source file. > > For example: > > Pass: Hello-pass.so > The dependent object file: units.o and helper.o > > Target file: simple.c > > I'm using the following command. > > >>> > >>> /usr/local/bin/clang -emit-llvm -c -o obj/simple.bc simple.c > >>> /usr/local/bin/llvm-link obj/simple.bc ./units.o ./helper.o > obj/simple-link.bc > >>> /usr/local/bin/opt -load ../Hello-pass.so -O3 < obj/simple-link.bc > obj/simple-opt.bc > >>> /usr/local/bin/clang -o obj/simple obj/simple-opt.bc -g -O3 > >>> > > Now, I need to optimize a large project with my pass and object file(Hello-pass.so units.o and helper.o),such as "md5sum" project. > It needs to be compiled and installed using the following command: > > >>> > > >>> ./configure > > >>> make > > >>> make install > >>> > > I need use LLVM to compile and optimize it. How can I apply my pass to the entire program? > What should I do? Please tell me an easy way. > > Please help me! > Thank you! > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev