diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /include/llvm/Bitcode | |
parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) |
Notes
Diffstat (limited to 'include/llvm/Bitcode')
-rw-r--r-- | include/llvm/Bitcode/BitcodeReader.h | 27 | ||||
-rw-r--r-- | include/llvm/Bitcode/BitcodeWriter.h | 42 | ||||
-rw-r--r-- | include/llvm/Bitcode/BitstreamReader.h | 4 | ||||
-rw-r--r-- | include/llvm/Bitcode/LLVMBitCodes.h | 4 |
4 files changed, 56 insertions, 21 deletions
diff --git a/include/llvm/Bitcode/BitcodeReader.h b/include/llvm/Bitcode/BitcodeReader.h index 160ddad5761f8..ce8bdd9cf0b4a 100644 --- a/include/llvm/Bitcode/BitcodeReader.h +++ b/include/llvm/Bitcode/BitcodeReader.h @@ -1,4 +1,4 @@ -//===-- llvm/Bitcode/BitcodeReader.h - Bitcode reader ----*- C++ -*-===// +//===- llvm/Bitcode/BitcodeReader.h - Bitcode reader ------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,18 +14,23 @@ #ifndef LLVM_BITCODE_BITCODEREADER_H #define LLVM_BITCODE_BITCODEREADER_H +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Bitcode/BitCodes.h" -#include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/ModuleSummaryIndex.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/MemoryBuffer.h" +#include <cstdint> #include <memory> - +#include <string> +#include <system_error> +#include <vector> namespace llvm { - class LLVMContext; - class Module; + +class LLVMContext; +class Module; // These functions are for converting Expected/Error values to // ErrorOr/std::error_code for compatibility with legacy clients. FIXME: @@ -81,6 +86,7 @@ namespace llvm { StringRef getBuffer() const { return StringRef((const char *)Buffer.begin(), Buffer.size()); } + StringRef getStrtab() const { return Strtab; } StringRef getModuleIdentifier() const { return ModuleIdentifier; } @@ -182,7 +188,6 @@ namespace llvm { /// isBitcodeWrapper - Return true if the given bytes are the magic bytes /// for an LLVM IR bitcode wrapper. - /// inline bool isBitcodeWrapper(const unsigned char *BufPtr, const unsigned char *BufEnd) { // See if you can find the hidden message in the magic bytes :-). @@ -196,7 +201,6 @@ namespace llvm { /// isRawBitcode - Return true if the given bytes are the magic bytes for /// raw LLVM IR bitcode (without a wrapper). - /// inline bool isRawBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd) { // These bytes sort of have a hidden message, but it's not in @@ -210,7 +214,6 @@ namespace llvm { /// isBitcode - Return true if the given bytes are the magic bytes for /// LLVM IR bitcode, either with or without a wrapper. - /// inline bool isBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd) { return isBitcodeWrapper(BufPtr, BufEnd) || @@ -258,10 +261,12 @@ namespace llvm { return std::error_code(static_cast<int>(E), BitcodeErrorCategory()); } -} // End llvm namespace +} // end namespace llvm namespace std { + template <> struct is_error_code_enum<llvm::BitcodeError> : std::true_type {}; -} -#endif +} // end namespace std + +#endif // LLVM_BITCODE_BITCODEREADER_H diff --git a/include/llvm/Bitcode/BitcodeWriter.h b/include/llvm/Bitcode/BitcodeWriter.h index f8b7fb341e881..c78077525c8b3 100644 --- a/include/llvm/Bitcode/BitcodeWriter.h +++ b/include/llvm/Bitcode/BitcodeWriter.h @@ -1,4 +1,4 @@ -//===-- llvm/Bitcode/BitcodeWriter.h - Bitcode writers ----*- C++ -*-===// +//===- llvm/Bitcode/BitcodeWriter.h - Bitcode writers -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,14 +14,20 @@ #ifndef LLVM_BITCODE_BITCODEWRITER_H #define LLVM_BITCODE_BITCODEWRITER_H +#include "llvm/ADT/StringRef.h" #include "llvm/IR/ModuleSummaryIndex.h" #include "llvm/MC/StringTableBuilder.h" +#include "llvm/Support/Allocator.h" +#include <map> +#include <memory> #include <string> +#include <vector> namespace llvm { - class BitstreamWriter; - class Module; - class raw_ostream; + +class BitstreamWriter; +class Module; +class raw_ostream; class BitcodeWriter { SmallVectorImpl<char> &Buffer; @@ -39,7 +45,7 @@ namespace llvm { std::vector<Module *> Mods; - public: + public: /// Create a BitcodeWriter that writes to Buffer. BitcodeWriter(SmallVectorImpl<char> &Buffer); @@ -84,6 +90,16 @@ namespace llvm { const ModuleSummaryIndex *Index = nullptr, bool GenerateHash = false, ModuleHash *ModHash = nullptr); + /// Write the specified thin link bitcode file (i.e., the minimized bitcode + /// file) to the buffer specified at construction time. The thin link + /// bitcode file is used for thin link, and it only contains the necessary + /// information for thin link. + /// + /// ModHash is for use in ThinLTO incremental build, generated while the + /// IR bitcode file writing. + void writeThinLinkBitcode(const Module *M, const ModuleSummaryIndex &Index, + const ModuleHash &ModHash); + void writeIndex( const ModuleSummaryIndex *Index, const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex); @@ -116,6 +132,17 @@ namespace llvm { bool GenerateHash = false, ModuleHash *ModHash = nullptr); + /// Write the specified thin link bitcode file (i.e., the minimized bitcode + /// file) to the given raw output stream, where it will be written in a new + /// bitcode block. The thin link bitcode file is used for thin link, and it + /// only contains the necessary information for thin link. + /// + /// ModHash is for use in ThinLTO incremental build, generated while the IR + /// bitcode file writing. + void WriteThinLinkBitcodeToFile(const Module *M, raw_ostream &Out, + const ModuleSummaryIndex &Index, + const ModuleHash &ModHash); + /// Write the specified module summary index to the given raw output stream, /// where it will be written in a new bitcode block. This is used when /// writing the combined index file for ThinLTO. When writing a subset of the @@ -124,6 +151,7 @@ namespace llvm { void WriteIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out, const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex = nullptr); -} // End llvm namespace -#endif +} // end namespace llvm + +#endif // LLVM_BITCODE_BITCODEWRITER_H diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h index fc06eeefbf265..b484fa2efbfba 100644 --- a/include/llvm/Bitcode/BitstreamReader.h +++ b/include/llvm/Bitcode/BitstreamReader.h @@ -43,7 +43,7 @@ public: unsigned BlockID; std::vector<std::shared_ptr<BitCodeAbbrev>> Abbrevs; std::string Name; - std::vector<std::pair<unsigned, std::string> > RecordNames; + std::vector<std::pair<unsigned, std::string>> RecordNames; }; private: @@ -88,7 +88,7 @@ public: /// follow the word size of the host machine for efficiency. We use word_t in /// places that are aware of this to make it perfectly explicit what is going /// on. - typedef size_t word_t; + using word_t = size_t; private: word_t CurWord = 0; diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h index 3777f956cf279..70194c0434790 100644 --- a/include/llvm/Bitcode/LLVMBitCodes.h +++ b/include/llvm/Bitcode/LLVMBitCodes.h @@ -558,7 +558,9 @@ enum AttributeKindCodes { ATTR_KIND_INACCESSIBLEMEM_OR_ARGMEMONLY = 50, ATTR_KIND_ALLOC_SIZE = 51, ATTR_KIND_WRITEONLY = 52, - ATTR_KIND_SPECULATABLE = 53 + ATTR_KIND_SPECULATABLE = 53, + ATTR_KIND_STRICT_FP = 54, + ATTR_KIND_SANITIZE_HWADDRESS = 55, }; enum ComdatSelectionKindCodes { |