2016-11-01 97 views
0

鏈接lto後有什麼辦法可以獲得llvm IR?例如,我有以下行:lto鏈接後獲取llvm IR

$ clang -flto -O2 a.c main.c -fuse-ld=gold -v -save-temps

所以我想LLVM IR其中file a.c和文件main.c在一個monlithic.bc(或monlithic.o與IR)鏈接。我嘗試添加選項-Wl,-plugin-opt=save-temps但出現錯誤:

libLLVMLTO: Unknown command line argument 'save-temps'. Try: 'libLLVMLTO -help' clang: error: linker command failed with exit code 1 (use -v to see invocation)

而且也沒有什麼辦法來轉儲IR的LTO轉變?

回答

0

的問題與新的連接器和LLVM解決(LLVM-3.8和Binutils-2.25)以下列方式:

$ ls

t1.c t2.c t2.h

$ clang -flto -O2 t1.c t2.c -v -fuse-ld=gold -save-temps -Wl,-plugin-opt=save-temps -Wl,--verbose

...

$ ls

a.out a.out.bc a.out.o a.out.opt.bc t1.bc t1.c t1.i t1.o t2.bc t2.c t2.h t2.i t2.o

$ llvm-dis a.out.bc

$ vim a.out.ll