[PATCH] D117244: [Bitcode] [ThinLTO] Add a new bitcode module record for THINLTO_INDEX_FLAG

Mingming Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 13 12:52:13 PST 2022


luna created this revision.
luna added a reviewer: tejohnson.
Herald added subscribers: ormris, arphaman, steven_wu, hiraditya, inglorion.
luna requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

- The record is of format [uint64_t] (one uint64_t integer). Only last bit is used so far; if last bit is true, the bitcode is minimized for the ThinLTO thin link only (i.e., bitcode generated by `opt --thin-link-bitcode-file=<minimized-bitcode>` or `clang -Xclang -fthin-link-bitcode=<minimized-bitcode>`.

- Writer
  - In BitcodeWriter.cpp, only `ThinLinkBitcodeWriter::write` writes 1, the rest of two bitcode writers write 0.

- Reader
  - In BitcodeReader.cpp, method `BitcodeModule::getLTOInfo` reads this record.
    - Implementation-wise, the method records the read state of {lto subblocks, index flag record}, skip records after index flag is read, and bails out early after both is read.
    - Optimize by using the fact that flag is written before subblocks, but correctness doesn't depend on this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117244

Files:
  llvm/include/llvm/Bitcode/BitcodeReader.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/test/Bitcode/bcanalyzer-thinlto-index-flag.ll
  llvm/tools/llvm-dis/llvm-dis.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117244.399755.patch
Type: text/x-patch
Size: 12220 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220113/6c7745bb/attachment.bin>


More information about the llvm-commits mailing list