HomePhabricator

Flush bitcode incrementally for LTO output

Authored by Jianzhou Zhao <jianzhouzh@google.com> on Sat, Sep 12, 12:35 PM.

Description

Flush bitcode incrementally for LTO output

Bitcode writer does not flush buffer until the end by default. This is
fine to small bitcode files. When -flto,--plugin-opt=emit-llvm,-gmlt are
used, the final bitcode file is large, for example, >8G. Keeping all
data in memory consumes a lot of memory.

This change allows bitcode writer flush data to disk early when buffered
data size is above some threshold. This is only enabled when lld emits
LLVM bitcode.

One issue to address is backpatching bitcode: subblock length, function
body indexes, meta data indexes need to backfill. If buffer can be
flushed partially, we introduced raw_fd_stream that supports
read/seek/write, and enables backpatching bitcode flushed in disk.

Reviewed-by: tejohnson, MaskRay

Differential Revision: https://reviews.llvm.org/D86905

Details

Committed
Jianzhou Zhao <jianzhouzh@google.com>Wed, Sep 16, 8:32 PM
Differential Revision
D86905: Flush bitcode incrementally for LTO output
Parents
rG0dd4d70ec20c: [gn build] Port a895040eb02
Branches
Unknown
Tags
Unknown

Event Timeline

Jianzhou Zhao <jianzhouzh@google.com> committed rG11201315d588: Flush bitcode incrementally for LTO output (authored by Jianzhou Zhao <jianzhouzh@google.com>).Wed, Sep 16, 8:32 PM