I wish the command above can execute my pass in link time, but i found that the pass didn’t work
I guess maybe i need to compile .c fiel to bitcode file instead of objcode?
Another question, can i convert objcode file to bitcode file?
Yes, you need to add -flto to the first compile command too.
Not really. I think there were experiments in this direction in the past but it’s a difficult problem and there’s certainly nothing in mainline LLVM for it.
LTO operates only on bitcode files. A native object file is essentially later in the pipeline of source to executable than bitcode, so LTO has nothing to work with in that case, hence why your pass hasn’t run. Compiling the .c file as a bitcode file (which you do by using -flto at compilation time) would solve that problem. Once you have a bitcode file, you can link it. Someone else will need to explain how you customise the passes during LTO, as I am not familiar with it (I doubt that -Xclang will do it).