diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2015-10-26 18:37:00 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2015-10-26 18:37:00 +0000 |
commit | 5d303285b9825a44f233102766be39bd1cff4de9 (patch) | |
tree | dcb1588e4f535601df4698dff21a6e80f60a8eaf /llvm/include | |
parent | d1aad265891cf58b4c16c532d3578c4bbbb297ff (diff) | |
download | bcm5719-llvm-5d303285b9825a44f233102766be39bd1cff4de9.tar.gz bcm5719-llvm-5d303285b9825a44f233102766be39bd1cff4de9.zip |
Add an (optional) identification block in the bitcode
Processing bitcode from a different LLVM version can lead to
unexpected behavior. The LLVM project guarantees autoupdating
bitcode from a previous minor revision for the same major, but
can't make any promise when reading bitcode generated from a
either a non-released LLVM, a vendor toolchain, or a "future"
LLVM release. This patch aims at being more user-friendly and
allows a bitcode produce to emit an optional block at the
beginning of the bitcode that will contains an opaque string
intended to describe the bitcode producer information. The
bitcode reader will dump this information alongside any error it
reports.
The optional block also includes an "epoch" number, monotonically
increasing when incompatible changes are made to the bitcode. The
reader will reject bitcode whose epoch is different from the one
expected.
Differential Revision: http://reviews.llvm.org/D13666
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 251325
Diffstat (limited to 'llvm/include')
-rw-r--r-- | llvm/include/llvm/Bitcode/LLVMBitCodes.h | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h b/llvm/include/llvm/Bitcode/LLVMBitCodes.h index d5f3c7f6096..a4ba05216ad 100644 --- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h +++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h @@ -23,33 +23,50 @@ namespace llvm { namespace bitc { // The only top-level block type defined is for a module. - enum BlockIDs { - // Blocks - MODULE_BLOCK_ID = FIRST_APPLICATION_BLOCKID, - - // Module sub-block id's. - PARAMATTR_BLOCK_ID, - PARAMATTR_GROUP_BLOCK_ID, - - CONSTANTS_BLOCK_ID, - FUNCTION_BLOCK_ID, - - UNUSED_ID1, - - VALUE_SYMTAB_BLOCK_ID, - METADATA_BLOCK_ID, - METADATA_ATTACHMENT_ID, - - TYPE_BLOCK_ID_NEW, - - USELIST_BLOCK_ID, - - MODULE_STRTAB_BLOCK_ID, - FUNCTION_SUMMARY_BLOCK_ID, - - OPERAND_BUNDLE_TAGS_BLOCK_ID - }; - +enum BlockIDs { + // Blocks + MODULE_BLOCK_ID = FIRST_APPLICATION_BLOCKID, + + // Module sub-block id's. + PARAMATTR_BLOCK_ID, + PARAMATTR_GROUP_BLOCK_ID, + + CONSTANTS_BLOCK_ID, + FUNCTION_BLOCK_ID, + + // Block intended to contains information on the bitcode versioning. + // Can be used to provide better error messages when we fail to parse a + // bitcode file. + IDENTIFICATION_BLOCK_ID, + + VALUE_SYMTAB_BLOCK_ID, + METADATA_BLOCK_ID, + METADATA_ATTACHMENT_ID, + + TYPE_BLOCK_ID_NEW, + + USELIST_BLOCK_ID, + + MODULE_STRTAB_BLOCK_ID, + FUNCTION_SUMMARY_BLOCK_ID, + + OPERAND_BUNDLE_TAGS_BLOCK_ID +}; + +/// Idenfitication block contains a string that describes the producer details, +/// and an epoch that defines the auto-upgrade capability. +enum IdentificationCodes { + IDENTIFICATION_CODE_STRING = 1, // IDENTIFICATION: [strchr x N] + IDENTIFICATION_CODE_EPOCH = 2, // EPOCH: [epoch#] +}; + +/// The epoch that defines the auto-upgrade compatibility for the bitcode. +/// +/// LLVM guarantees in a major release that a minor release can read bitcode +/// generated by previous minor releases. We translate this by making the reader +/// accepting only bitcode with the same epoch, except for the X.0 release which +/// also accepts N-1. +enum { BITCODE_CURRENT_EPOCH = 0 }; /// MODULE blocks have a number of optional fields and subblocks. enum ModuleCodes { |