Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I do llvm link time optimization

Tags:

c++

llvm

clang

I compile a C++ program, using for example the following.

clang++ -O4 -emit-llvm file1.cpp -c -o file1.bc 
clang++ -O4 -emit-llvm file2.cpp -c -o file2.bc 

llvm-link file1.bc file2.bc 

How can I perform link time optimization here?

like image 802
pythonic Avatar asked Aug 02 '12 13:08

pythonic


1 Answers

Use opt:

clang++ -O4 -emit-llvm file1.cpp -c -o file1.bc 
clang++ -O4 -emit-llvm file2.cpp -c -o file2.bc 
llvm-link file1.bc file2.bc -o all.bc
opt -std-compile-opts -std-link-opts -O3 all.bc -o optimized.bc
like image 89
Chris Dodd Avatar answered Sep 24 '22 09:09

Chris Dodd