LLVM Pass in compiling and linking


According to the official documentation. It says to use the tool opt -load to run LLVM pass on the target bitcode.

According to my observation. When the program is very large, it is very slow and not efficient. I noticed that LLVM support to run LLVM pass during the compiling time or linking time.

For compiling time. It seems that the option -Xclang -load -Xclang mypass.so will work. However, after generating the object. the ld linker will say that it has no option -load. Thus aborted.

What can I do? I just want to write a LLVM pass and run it during the compiling time. No documentation is found. Could anyone tell me or give me some help? Many Thanks


Modify lib/Transforms/IPO/PassManagerBuilder.cpp to statically link and run your pass