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

Teresa Johnson via llvm-dev llvm-dev at lists.llvm.org
Tue May 15 06:33:13 PDT 2018


On Tue, May 15, 2018 at 6:25 AM Muhui Jiang <jiangmuhui at gmail.com> 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 <tejohnson at google.com>:
>
>> 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 <
>> llvm-dev at lists.llvm.org> 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
>>> llvm-dev at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>>
>>
>>
>> --
>> Teresa Johnson |  Software Engineer |  tejohnson at google.com |
>>  408-460-2413
>>
>
>

-- 
Teresa Johnson |  Software Engineer |  tejohnson at google.com |  408-460-2413
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180515/70e78f83/attachment.html>


More information about the llvm-dev mailing list