[llvm-dev] Four bitcode generated with plugin-opt=save-temps

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] Four bitcode generated with plugin-opt=save-temps

Zhizhou Yang via llvm-dev
Hi 

I use the LDFLAGS=" -flto -fuse-ld=gold  -Wl,-plugin-opt=save-temps " to generate the makefile and to make the whole program. However,  found four different kinds of bitcode for each target. For example, I am compiling coreutils. For the program "nohup", I can get
 
 nohup.0.0.preopt.bc
 nohup.0.2.internalize.bc
 nohup.0.4.opt.bc 
 nohup.0.5.precodegen.bc 

If I am right, I can also get the bitcode with emit-llvm option in clang. May I know which bc among the above four should be the same as the one I generated with emit-llvm. More information are very thankful. 

Regards
Muhui

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Four bitcode generated with plugin-opt=save-temps

Zhizhou Yang via llvm-dev
These are the bitcode at different stages of the LTO portion of the compile. LTO merges the IR for all files being linked and optimizes them as a single monolithic module. The preopt.bc is the merged IR just after merging and before performing any LTO optimizations. internalize.bc is after performing whole program internalization. opt.bc is after the optimization pipeline, and .precodegen.bc is immediately before native code generation.

The emit-llvm option will give you the IR for a single source file when you compile it with -c. All of those files when combined give the IR in the preopt.bc temp file.

Hope that helps,
Teresa

On Tue, May 15, 2018 at 4:43 AM Muhui Jiang via llvm-dev <[hidden email]> wrote:
Hi 

I use the LDFLAGS=" -flto -fuse-ld=gold  -Wl,-plugin-opt=save-temps " to generate the makefile and to make the whole program. However,  found four different kinds of bitcode for each target. For example, I am compiling coreutils. For the program "nohup", I can get
 
 nohup.0.0.preopt.bc
 nohup.0.2.internalize.bc
 nohup.0.4.opt.bc 
 nohup.0.5.precodegen.bc 

If I am right, I can also get the bitcode with emit-llvm option in clang. May I know which bc among the above four should be the same as the one I generated with emit-llvm. More information are very thankful. 

Regards
Muhui
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


--
Teresa Johnson | Software Engineer | [hidden email] | 408-460-2413

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Four bitcode generated with plugin-opt=save-temps

Zhizhou Yang via llvm-dev
Hi Teresa

Thanks for your very quick and clear explanation. I have one more question.

The emit-llvm option will give you the IR for a single source file when you compile it with -c. All of those files when combined give the IR in the preopt.bc temp file.
===========
So if I use "clang -emit-llvm -c" to generate the .ll file. It should be the same as the one I generated by using "llvm-dis *.preopt.bc -o *.preopt.ll" to translate the bitcode to IR. Actually, I would like to obtain the control flow information from the LLVM IR. Will different stages of the bitcode influence the generated CFG?
Many Thanks

Regards
Muhui

2018-05-15 21:19 GMT+08:00 Teresa Johnson <[hidden email]>:
These are the bitcode at different stages of the LTO portion of the compile. LTO merges the IR for all files being linked and optimizes them as a single monolithic module. The preopt.bc is the merged IR just after merging and before performing any LTO optimizations. internalize.bc is after performing whole program internalization. opt.bc is after the optimization pipeline, and .precodegen.bc is immediately before native code generation.

The emit-llvm option will give you the IR for a single source file when you compile it with -c. All of those files when combined give the IR in the preopt.bc temp file.

Hope that helps,
Teresa

On Tue, May 15, 2018 at 4:43 AM Muhui Jiang via llvm-dev <[hidden email]> wrote:
Hi 

I use the LDFLAGS=" -flto -fuse-ld=gold  -Wl,-plugin-opt=save-temps " to generate the makefile and to make the whole program. However,  found four different kinds of bitcode for each target. For example, I am compiling coreutils. For the program "nohup", I can get
 
 nohup.0.0.preopt.bc
 nohup.0.2.internalize.bc
 nohup.0.4.opt.bc 
 nohup.0.5.precodegen.bc 

If I am right, I can also get the bitcode with emit-llvm option in clang. May I know which bc among the above four should be the same as the one I generated with emit-llvm. More information are very thankful. 

Regards
Muhui
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


--
Teresa Johnson | Software Engineer | [hidden email] | 408-460-2413


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] Four bitcode generated with plugin-opt=save-temps

Zhizhou Yang via llvm-dev


On Tue, May 15, 2018 at 6:25 AM Muhui Jiang <[hidden email]> wrote:
Hi Teresa

Thanks for your very quick and clear explanation. I have one more question.

The emit-llvm option will give you the IR for a single source file when you compile it with -c. All of those files when combined give the IR in the preopt.bc temp file.
===========
So if I use "clang -emit-llvm -c" to generate the .ll file. It should be the same as the one I generated by using "llvm-dis *.preopt.bc -o *.preopt.ll" to translate the bitcode to IR.

Not unless there is a single source file being used to compile the program. Assuming there are multiple source files being linked into nohup, the nohup.0.0.preopt.bc will contain the IR of all of those combined. Whereas the clang -emit-llvm -c .ll file is the IR for just one of them.
 
Actually, I would like to obtain the control flow information from the LLVM IR. Will different stages of the bitcode influence the generated CFG?

Yes since some of the optimizations may change the CFG. Specifically the .opt.bc file may reflect optimizations affecting the CFG. 

Teresa

Many Thanks

Regards
Muhui

2018-05-15 21:19 GMT+08:00 Teresa Johnson <[hidden email]>:
These are the bitcode at different stages of the LTO portion of the compile. LTO merges the IR for all files being linked and optimizes them as a single monolithic module. The preopt.bc is the merged IR just after merging and before performing any LTO optimizations. internalize.bc is after performing whole program internalization. opt.bc is after the optimization pipeline, and .precodegen.bc is immediately before native code generation.

The emit-llvm option will give you the IR for a single source file when you compile it with -c. All of those files when combined give the IR in the preopt.bc temp file.

Hope that helps,
Teresa

On Tue, May 15, 2018 at 4:43 AM Muhui Jiang via llvm-dev <[hidden email]> wrote:
Hi 

I use the LDFLAGS=" -flto -fuse-ld=gold  -Wl,-plugin-opt=save-temps " to generate the makefile and to make the whole program. However,  found four different kinds of bitcode for each target. For example, I am compiling coreutils. For the program "nohup", I can get
 
 nohup.0.0.preopt.bc
 nohup.0.2.internalize.bc
 nohup.0.4.opt.bc 
 nohup.0.5.precodegen.bc 

If I am right, I can also get the bitcode with emit-llvm option in clang. May I know which bc among the above four should be the same as the one I generated with emit-llvm. More information are very thankful. 

Regards
Muhui
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


--
Teresa Johnson | Software Engineer | [hidden email] | 408-460-2413



--
Teresa Johnson | Software Engineer | [hidden email] | 408-460-2413

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev