Update prebuilt Clang to r416183b from Android.
https://android.googlesource.com/platform/prebuilts/clang/host/
linux-x86/+/06a71ddac05c22edb2d10b590e1769b3f8619bef
clang 12.0.5 (based on r416183b) from build 7284624.
Change-Id: I277a316abcf47307562d8b748b84870f31a72866
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/linux-x64/clang/include/llvm/Bitcode/BitcodeAnalyzer.h b/linux-x64/clang/include/llvm/Bitcode/BitcodeAnalyzer.h
index cfdebd6..5fb8bb2 100644
--- a/linux-x64/clang/include/llvm/Bitcode/BitcodeAnalyzer.h
+++ b/linux-x64/clang/include/llvm/Bitcode/BitcodeAnalyzer.h
@@ -30,6 +30,7 @@
LLVMIRBitstream,
ClangSerializedASTBitstream,
ClangSerializedDiagnosticsBitstream,
+ LLVMBitstreamRemarks
};
struct BCDumpOptions {
diff --git a/linux-x64/clang/include/llvm/Bitcode/BitcodeCommon.h b/linux-x64/clang/include/llvm/Bitcode/BitcodeCommon.h
new file mode 100644
index 0000000..6a3e745
--- /dev/null
+++ b/linux-x64/clang/include/llvm/Bitcode/BitcodeCommon.h
@@ -0,0 +1,30 @@
+//===- BitcodeCommon.h - Common code for encode/decode --------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This header defines common code to be used by BitcodeWriter and
+// BitcodeReader.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_BITCODE_BITCODECOMMON_H
+#define LLVM_BITCODE_BITCODECOMMON_H
+
+#include "llvm/ADT/Bitfields.h"
+
+namespace llvm {
+
+struct AllocaPackedValues {
+ using Align = Bitfield::Element<unsigned, 0, 5>;
+ using UsedWithInAlloca = Bitfield::Element<bool, Align::NextBit, 1>;
+ using ExplicitType = Bitfield::Element<bool, UsedWithInAlloca::NextBit, 1>;
+ using SwiftError = Bitfield::Element<bool, ExplicitType::NextBit, 1>;
+};
+
+} // namespace llvm
+
+#endif // LLVM_BITCODE_BITCODECOMMON_H
diff --git a/linux-x64/clang/include/llvm/Bitcode/BitcodeConvenience.h b/linux-x64/clang/include/llvm/Bitcode/BitcodeConvenience.h
new file mode 100644
index 0000000..0060d01
--- /dev/null
+++ b/linux-x64/clang/include/llvm/Bitcode/BitcodeConvenience.h
@@ -0,0 +1,486 @@
+//===- llvm/Bitcode/BitcodeConvenience.h - Convenience Wrappers -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file Convenience wrappers for the LLVM bitcode format and bitstream APIs.
+///
+/// This allows you to use a sort of DSL to declare and use bitcode
+/// abbreviations and records. Example:
+///
+/// \code
+/// using Metadata = BCRecordLayout<
+/// METADATA_ID, // ID
+/// BCFixed<16>, // Module format major version
+/// BCFixed<16>, // Module format minor version
+/// BCBlob // misc. version information
+/// >;
+/// Metadata metadata(Out);
+/// metadata.emit(ScratchRecord, VERSION_MAJOR, VERSION_MINOR, Data);
+/// \endcode
+///
+/// For details on the bitcode format, see
+/// http://llvm.org/docs/BitCodeFormat.html
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_BITCODE_BITCODECONVENIENCE_H
+#define LLVM_BITCODE_BITCODECONVENIENCE_H
+
+#include "llvm/Bitstream/BitCodes.h"
+#include "llvm/Bitstream/BitstreamWriter.h"
+#include <cstdint>
+
+namespace llvm {
+namespace detail {
+/// Convenience base for all kinds of bitcode abbreviation fields.
+///
+/// This just defines common properties queried by the metaprogramming.
+template <bool Compound = false> class BCField {
+public:
+ static const bool IsCompound = Compound;
+
+ /// Asserts that the given data is a valid value for this field.
+ template <typename T> static void assertValid(const T &data) {}
+
+ /// Converts a raw numeric representation of this value to its preferred
+ /// type.
+ template <typename T> static T convert(T rawValue) { return rawValue; }
+};
+} // namespace detail
+
+/// Represents a literal operand in a bitcode record.
+///
+/// The value of a literal operand is the same for all instances of the record,
+/// so it is only emitted in the abbreviation definition.
+///
+/// Note that because this uses a compile-time template, you cannot have a
+/// literal operand that is fixed at run-time without dropping down to the
+/// raw LLVM APIs.
+template <uint64_t Value> class BCLiteral : public detail::BCField<> {
+public:
+ static void emitOp(llvm::BitCodeAbbrev &abbrev) {
+ abbrev.Add(llvm::BitCodeAbbrevOp(Value));
+ }
+
+ template <typename T> static void assertValid(const T &data) {
+ assert(data == Value && "data value does not match declared literal value");
+ }
+};
+
+/// Represents a fixed-width value in a bitcode record.
+///
+/// Note that the LLVM bitcode format only supports unsigned values.
+template <unsigned Width> class BCFixed : public detail::BCField<> {
+public:
+ static_assert(Width <= 64, "fixed-width field is too large");
+
+ static void emitOp(llvm::BitCodeAbbrev &abbrev) {
+ abbrev.Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Fixed, Width));
+ }
+
+ static void assertValid(const bool &data) {
+ assert(llvm::isUInt<Width>(data) &&
+ "data value does not fit in the given bit width");
+ }
+
+ template <typename T> static void assertValid(const T &data) {
+ assert(data >= 0 && "cannot encode signed integers");
+ assert(llvm::isUInt<Width>(data) &&
+ "data value does not fit in the given bit width");
+ }
+};
+
+/// Represents a variable-width value in a bitcode record.
+///
+/// The \p Width parameter should include the continuation bit.
+///
+/// Note that the LLVM bitcode format only supports unsigned values.
+template <unsigned Width> class BCVBR : public detail::BCField<> {
+ static_assert(Width >= 2, "width does not have room for continuation bit");
+
+public:
+ static void emitOp(llvm::BitCodeAbbrev &abbrev) {
+ abbrev.Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::VBR, Width));
+ }
+
+ template <typename T> static void assertValid(const T &data) {
+ assert(data >= 0 && "cannot encode signed integers");
+ }
+};
+
+/// Represents a character encoded in LLVM's Char6 encoding.
+///
+/// This format is suitable for encoding decimal numbers (without signs or
+/// exponents) and C identifiers (without dollar signs), but not much else.
+///
+/// \sa http://llvm.org/docs/BitCodeFormat.html#char6-encoded-value
+class BCChar6 : public detail::BCField<> {
+public:
+ static void emitOp(llvm::BitCodeAbbrev &abbrev) {
+ abbrev.Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Char6));
+ }
+
+ template <typename T> static void assertValid(const T &data) {
+ assert(llvm::BitCodeAbbrevOp::isChar6(data) && "invalid Char6 data");
+ }
+
+ template <typename T> char convert(T rawValue) {
+ return static_cast<char>(rawValue);
+ }
+};
+
+/// Represents an untyped blob of bytes.
+///
+/// If present, this must be the last field in a record.
+class BCBlob : public detail::BCField<true> {
+public:
+ static void emitOp(llvm::BitCodeAbbrev &abbrev) {
+ abbrev.Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
+ }
+};
+
+/// Represents an array of some other type.
+///
+/// If present, this must be the last field in a record.
+template <typename ElementTy> class BCArray : public detail::BCField<true> {
+ static_assert(!ElementTy::IsCompound, "arrays can only contain scalar types");
+
+public:
+ static void emitOp(llvm::BitCodeAbbrev &abbrev) {
+ abbrev.Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Array));
+ ElementTy::emitOp(abbrev);
+ }
+};
+
+namespace detail {
+/// Attaches the last field to an abbreviation.
+///
+/// This is the base case for \c emitOps.
+///
+/// \sa BCRecordLayout::emitAbbrev
+template <typename FieldTy> static void emitOps(llvm::BitCodeAbbrev &abbrev) {
+ FieldTy::emitOp(abbrev);
+}
+
+/// Attaches fields to an abbreviation.
+///
+/// This is the recursive case for \c emitOps.
+///
+/// \sa BCRecordLayout::emitAbbrev
+template <typename FieldTy, typename Next, typename... Rest>
+static void emitOps(llvm::BitCodeAbbrev &abbrev) {
+ static_assert(!FieldTy::IsCompound,
+ "arrays and blobs may not appear in the middle of a record");
+ FieldTy::emitOp(abbrev);
+ emitOps<Next, Rest...>(abbrev);
+}
+
+/// Helper class for dealing with a scalar element in the middle of a record.
+///
+/// \sa BCRecordLayout
+template <typename ElementTy, typename... Fields> class BCRecordCoding {
+public:
+ template <typename BufferTy, typename ElementDataTy, typename... DataTy>
+ static void emit(llvm::BitstreamWriter &Stream, BufferTy &buffer,
+ unsigned code, ElementDataTy element, DataTy &&...data) {
+ static_assert(!ElementTy::IsCompound,
+ "arrays and blobs may not appear in the middle of a record");
+ ElementTy::assertValid(element);
+ buffer.push_back(element);
+ BCRecordCoding<Fields...>::emit(Stream, buffer, code,
+ std::forward<DataTy>(data)...);
+ }
+
+ template <typename T, typename ElementDataTy, typename... DataTy>
+ static void read(ArrayRef<T> buffer, ElementDataTy &element,
+ DataTy &&...data) {
+ assert(!buffer.empty() && "too few elements in buffer");
+ element = ElementTy::convert(buffer.front());
+ BCRecordCoding<Fields...>::read(buffer.slice(1),
+ std::forward<DataTy>(data)...);
+ }
+
+ template <typename T, typename... DataTy>
+ static void read(ArrayRef<T> buffer, NoneType, DataTy &&...data) {
+ assert(!buffer.empty() && "too few elements in buffer");
+ BCRecordCoding<Fields...>::read(buffer.slice(1),
+ std::forward<DataTy>(data)...);
+ }
+};
+
+/// Helper class for dealing with a scalar element at the end of a record.
+///
+/// This has a separate implementation because up until now we've only been
+/// \em building the record (into a data buffer), and now we need to hand it
+/// off to the BitstreamWriter to be emitted.
+///
+/// \sa BCRecordLayout
+template <typename ElementTy> class BCRecordCoding<ElementTy> {
+public:
+ template <typename BufferTy, typename DataTy>
+ static void emit(llvm::BitstreamWriter &Stream, BufferTy &buffer,
+ unsigned code, const DataTy &data) {
+ static_assert(!ElementTy::IsCompound,
+ "arrays and blobs need special handling");
+ ElementTy::assertValid(data);
+ buffer.push_back(data);
+ Stream.EmitRecordWithAbbrev(code, buffer);
+ }
+
+ template <typename T, typename DataTy>
+ static void read(ArrayRef<T> buffer, DataTy &data) {
+ assert(buffer.size() == 1 && "record data does not match layout");
+ data = ElementTy::convert(buffer.front());
+ }
+
+ template <typename T> static void read(ArrayRef<T> buffer, NoneType) {
+ assert(buffer.size() == 1 && "record data does not match layout");
+ (void)buffer;
+ }
+
+ template <typename T> static void read(ArrayRef<T> buffer) = delete;
+};
+
+/// Helper class for dealing with an array at the end of a record.
+///
+/// \sa BCRecordLayout::emitRecord
+template <typename ElementTy> class BCRecordCoding<BCArray<ElementTy>> {
+public:
+ template <typename BufferTy>
+ static void emit(llvm::BitstreamWriter &Stream, BufferTy &buffer,
+ unsigned code, StringRef data) {
+ // TODO: validate array data.
+ Stream.EmitRecordWithArray(code, buffer, data);
+ }
+
+ template <typename BufferTy, typename ArrayTy>
+ static void emit(llvm::BitstreamWriter &Stream, BufferTy &buffer,
+ unsigned code, const ArrayTy &array) {
+#ifndef NDEBUG
+ for (auto &element : array)
+ ElementTy::assertValid(element);
+#endif
+ buffer.reserve(buffer.size() + std::distance(array.begin(), array.end()));
+ std::copy(array.begin(), array.end(), std::back_inserter(buffer));
+ Stream.EmitRecordWithAbbrev(code, buffer);
+ }
+
+ template <typename BufferTy, typename ElementDataTy, typename... DataTy>
+ static void emit(llvm::BitstreamWriter &Stream, BufferTy &buffer,
+ unsigned code, ElementDataTy element, DataTy... data) {
+ std::array<ElementDataTy, 1 + sizeof...(data)> array{{element, data...}};
+ emit(Stream, buffer, code, array);
+ }
+
+ template <typename BufferTy>
+ static void emit(llvm::BitstreamWriter &Stream, BufferTy &Buffer,
+ unsigned code, NoneType) {
+ Stream.EmitRecordWithAbbrev(code, Buffer);
+ }
+
+ template <typename T>
+ static void read(ArrayRef<T> Buffer, ArrayRef<T> &rawData) {
+ rawData = Buffer;
+ }
+
+ template <typename T, typename ArrayTy>
+ static void read(ArrayRef<T> buffer, ArrayTy &array) {
+ array.append(llvm::map_iterator(buffer.begin(), T::convert),
+ llvm::map_iterator(buffer.end(), T::convert));
+ }
+
+ template <typename T> static void read(ArrayRef<T> buffer, NoneType) {
+ (void)buffer;
+ }
+
+ template <typename T> static void read(ArrayRef<T> buffer) = delete;
+};
+
+/// Helper class for dealing with a blob at the end of a record.
+///
+/// \sa BCRecordLayout
+template <> class BCRecordCoding<BCBlob> {
+public:
+ template <typename BufferTy>
+ static void emit(llvm::BitstreamWriter &Stream, BufferTy &buffer,
+ unsigned code, StringRef data) {
+ Stream.EmitRecordWithBlob(code, buffer, data);
+ }
+
+ template <typename T> static void read(ArrayRef<T> buffer) { (void)buffer; }
+
+ /// Blob data is not stored in the buffer if you are using the correct
+ /// accessor; this method should not be used.
+ template <typename T, typename DataTy>
+ static void read(ArrayRef<T> buffer, DataTy &data) = delete;
+};
+
+/// A type trait whose \c type field is the last of its template parameters.
+template <typename Head, typename... Tail> struct last_type {
+ using type = typename last_type<Tail...>::type;
+};
+
+template <typename Head> struct last_type<Head> { using type = Head; };
+
+/// A type trait whose \c value field is \c true if the last type is BCBlob.
+template <typename... Types>
+using has_blob = std::is_same<BCBlob, typename last_type<int, Types...>::type>;
+
+/// A type trait whose \c value field is \c true if the given type is a
+/// BCArray (of any element kind).
+template <typename T> struct is_array {
+private:
+ template <typename E> static bool check(BCArray<E> *);
+ static int check(...);
+
+public:
+ typedef bool value_type;
+ static constexpr bool value = !std::is_same<decltype(check((T *)nullptr)),
+ decltype(check(false))>::value;
+};
+
+/// A type trait whose \c value field is \c true if the last type is a
+/// BCArray (of any element kind).
+template <typename... Types>
+using has_array = is_array<typename last_type<int, Types...>::type>;
+} // namespace detail
+
+/// Represents a single bitcode record type.
+///
+/// This class template is meant to be instantiated and then given a name,
+/// so that from then on that name can be used.
+template <typename IDField, typename... Fields> class BCGenericRecordLayout {
+ llvm::BitstreamWriter &Stream;
+
+public:
+ /// The abbreviation code used for this record in the current block.
+ ///
+ /// Note that this is not the same as the semantic record code, which is the
+ /// first field of the record.
+ const unsigned AbbrevCode;
+
+ /// Create a layout and register it with the given bitstream writer.
+ explicit BCGenericRecordLayout(llvm::BitstreamWriter &Stream)
+ : Stream(Stream), AbbrevCode(emitAbbrev(Stream)) {}
+
+ /// Emit a record to the bitstream writer, using the given buffer for scratch
+ /// space.
+ ///
+ /// Note that even fixed arguments must be specified here.
+ template <typename BufferTy, typename... Data>
+ void emit(BufferTy &buffer, unsigned id, Data &&...data) const {
+ emitRecord(Stream, buffer, AbbrevCode, id, std::forward<Data>(data)...);
+ }
+
+ /// Registers this record's layout with the bitstream reader.
+ ///
+ /// eturns The abbreviation code for the newly-registered record type.
+ static unsigned emitAbbrev(llvm::BitstreamWriter &Stream) {
+ auto Abbrev = std::make_shared<llvm::BitCodeAbbrev>();
+ detail::emitOps<IDField, Fields...>(*Abbrev);
+ return Stream.EmitAbbrev(std::move(Abbrev));
+ }
+
+ /// Emit a record identified by \p abbrCode to bitstream reader \p Stream,
+ /// using \p buffer for scratch space.
+ ///
+ /// Note that even fixed arguments must be specified here. Blobs are passed
+ /// as StringRefs, while arrays can be passed inline, as aggregates, or as
+ /// pre-encoded StringRef data. Skipped values and empty arrays should use
+ /// the special Nothing value.
+ template <typename BufferTy, typename... Data>
+ static void emitRecord(llvm::BitstreamWriter &Stream, BufferTy &buffer,
+ unsigned abbrCode, unsigned recordID, Data &&...data) {
+ static_assert(sizeof...(data) <= sizeof...(Fields) ||
+ detail::has_array<Fields...>::value,
+ "Too many record elements");
+ static_assert(sizeof...(data) >= sizeof...(Fields),
+ "Too few record elements");
+ buffer.clear();
+ detail::BCRecordCoding<IDField, Fields...>::emit(
+ Stream, buffer, abbrCode, recordID, std::forward<Data>(data)...);
+ }
+
+ /// Extract record data from \p buffer into the given data fields.
+ ///
+ /// Note that even fixed arguments must be specified here. Pass \c Nothing
+ /// if you don't care about a particular parameter. Blob data is not included
+ /// in the buffer and should be handled separately by the caller.
+ template <typename ElementTy, typename... Data>
+ static void readRecord(ArrayRef<ElementTy> buffer, Data &&...data) {
+ static_assert(sizeof...(data) <= sizeof...(Fields),
+ "Too many record elements");
+ static_assert(sizeof...(Fields) <=
+ sizeof...(data) + detail::has_blob<Fields...>::value,
+ "Too few record elements");
+ return detail::BCRecordCoding<Fields...>::read(buffer,
+ std::forward<Data>(data)...);
+ }
+
+ /// Extract record data from \p buffer into the given data fields.
+ ///
+ /// Note that even fixed arguments must be specified here. Pass \c Nothing
+ /// if you don't care about a particular parameter. Blob data is not included
+ /// in the buffer and should be handled separately by the caller.
+ template <typename BufferTy, typename... Data>
+ static void readRecord(BufferTy &buffer, Data &&...data) {
+ return readRecord(llvm::makeArrayRef(buffer), std::forward<Data>(data)...);
+ }
+};
+
+/// A record with a fixed record code.
+template <unsigned RecordCode, typename... Fields>
+class BCRecordLayout
+ : public BCGenericRecordLayout<BCLiteral<RecordCode>, Fields...> {
+ using Base = BCGenericRecordLayout<BCLiteral<RecordCode>, Fields...>;
+
+public:
+ enum : unsigned {
+ /// The record code associated with this layout.
+ Code = RecordCode
+ };
+
+ /// Create a layout and register it with the given bitstream writer.
+ explicit BCRecordLayout(llvm::BitstreamWriter &Stream) : Base(Stream) {}
+
+ /// Emit a record to the bitstream writer, using the given buffer for scratch
+ /// space.
+ ///
+ /// Note that even fixed arguments must be specified here.
+ template <typename BufferTy, typename... Data>
+ void emit(BufferTy &buffer, Data &&...data) const {
+ Base::emit(buffer, RecordCode, std::forward<Data>(data)...);
+ }
+
+ /// Emit a record identified by \p abbrCode to bitstream reader \p Stream,
+ /// using \p buffer for scratch space.
+ ///
+ /// Note that even fixed arguments must be specified here. Currently, arrays
+ /// and blobs can only be passed as StringRefs.
+ template <typename BufferTy, typename... Data>
+ static void emitRecord(llvm::BitstreamWriter &Stream, BufferTy &buffer,
+ unsigned abbrCode, Data &&...data) {
+ Base::emitRecord(Stream, buffer, abbrCode, RecordCode,
+ std::forward<Data>(data)...);
+ }
+};
+
+/// RAII object to pair entering and exiting a sub-block.
+class BCBlockRAII {
+ llvm::BitstreamWriter &Stream;
+
+public:
+ BCBlockRAII(llvm::BitstreamWriter &Stream, unsigned block, unsigned abbrev)
+ : Stream(Stream) {
+ Stream.EnterSubblock(block, abbrev);
+ }
+
+ ~BCBlockRAII() { Stream.ExitBlock(); }
+};
+} // namespace llvm
+
+#endif
diff --git a/linux-x64/clang/include/llvm/Bitcode/BitcodeReader.h b/linux-x64/clang/include/llvm/Bitcode/BitcodeReader.h
index ba61da7..a82791c 100644
--- a/linux-x64/clang/include/llvm/Bitcode/BitcodeReader.h
+++ b/linux-x64/clang/include/llvm/Bitcode/BitcodeReader.h
@@ -31,6 +31,9 @@
class LLVMContext;
class Module;
+typedef llvm::function_ref<Optional<std::string>(StringRef)>
+ DataLayoutCallbackTy;
+
// These functions are for converting Expected/Error values to
// ErrorOr/std::error_code for compatibility with legacy clients. FIXME:
// Remove these functions once no longer needed by the C and libLTO APIs.
@@ -77,10 +80,10 @@
friend Expected<BitcodeFileContents>
getBitcodeFileContents(MemoryBufferRef Buffer);
- Expected<std::unique_ptr<Module>> getModuleImpl(LLVMContext &Context,
- bool MaterializeAll,
- bool ShouldLazyLoadMetadata,
- bool IsImporting);
+ Expected<std::unique_ptr<Module>>
+ getModuleImpl(LLVMContext &Context, bool MaterializeAll,
+ bool ShouldLazyLoadMetadata, bool IsImporting,
+ DataLayoutCallbackTy DataLayoutCallback);
public:
StringRef getBuffer() const {
@@ -100,7 +103,9 @@
bool IsImporting);
/// Read the entire bitcode module and return it.
- Expected<std::unique_ptr<Module>> parseModule(LLVMContext &Context);
+ Expected<std::unique_ptr<Module>> parseModule(
+ LLVMContext &Context, DataLayoutCallbackTy DataLayoutCallback =
+ [](StringRef) { return None; });
/// Returns information about the module to be used for LTO: whether to
/// compile with ThinLTO, and whether it has a summary.
@@ -163,8 +168,11 @@
Expected<std::string> getBitcodeProducerString(MemoryBufferRef Buffer);
/// Read the specified bitcode file, returning the module.
- Expected<std::unique_ptr<Module>> parseBitcodeFile(MemoryBufferRef Buffer,
- LLVMContext &Context);
+ Expected<std::unique_ptr<Module>> parseBitcodeFile(
+ MemoryBufferRef Buffer, LLVMContext &Context,
+ DataLayoutCallbackTy DataLayoutCallback = [](StringRef) {
+ return None;
+ });
/// Returns LTO information for the specified bitcode file.
Expected<BitcodeLTOInfo> getBitcodeLTOInfo(MemoryBufferRef Buffer);
@@ -255,6 +263,8 @@
return false;
}
+ APInt readWideAPInt(ArrayRef<uint64_t> Vals, unsigned TypeBits);
+
const std::error_category &BitcodeErrorCategory();
enum class BitcodeError { CorruptedBitcode = 1 };
inline std::error_code make_error_code(BitcodeError E) {
diff --git a/linux-x64/clang/include/llvm/Bitcode/BitcodeWriter.h b/linux-x64/clang/include/llvm/Bitcode/BitcodeWriter.h
index 39061e0..7ad2d37 100644
--- a/linux-x64/clang/include/llvm/Bitcode/BitcodeWriter.h
+++ b/linux-x64/clang/include/llvm/Bitcode/BitcodeWriter.h
@@ -17,6 +17,7 @@
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/MC/StringTableBuilder.h"
#include "llvm/Support/Allocator.h"
+#include "llvm/Support/MemoryBuffer.h"
#include <map>
#include <memory>
#include <string>
@@ -46,7 +47,7 @@
public:
/// Create a BitcodeWriter that writes to Buffer.
- BitcodeWriter(SmallVectorImpl<char> &Buffer);
+ BitcodeWriter(SmallVectorImpl<char> &Buffer, raw_fd_stream *FS = nullptr);
~BitcodeWriter();
@@ -151,6 +152,19 @@
const std::map<std::string, GVSummaryMapTy>
*ModuleToSummariesForIndex = nullptr);
+ /// If EmbedBitcode is set, save a copy of the llvm IR as data in the
+ /// __LLVM,__bitcode section (.llvmbc on non-MacOS).
+ /// If available, pass the serialized module via the Buf parameter. If not,
+ /// pass an empty (default-initialized) MemoryBufferRef, and the serialization
+ /// will be handled by this API. The same behavior happens if the provided Buf
+ /// is not bitcode (i.e. if it's invalid data or even textual LLVM assembly).
+ /// If EmbedCmdline is set, the command line is also exported in
+ /// the corresponding section (__LLVM,_cmdline / .llvmcmd) - even if CmdArgs
+ /// were empty.
+ void EmbedBitcodeInModule(Module &M, MemoryBufferRef Buf, bool EmbedBitcode,
+ bool EmbedCmdline,
+ const std::vector<uint8_t> &CmdArgs);
+
} // end namespace llvm
#endif // LLVM_BITCODE_BITCODEWRITER_H
diff --git a/linux-x64/clang/include/llvm/Bitcode/LLVMBitCodes.h b/linux-x64/clang/include/llvm/Bitcode/LLVMBitCodes.h
index 3ec0b38..03dac9e 100644
--- a/linux-x64/clang/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/linux-x64/clang/include/llvm/Bitcode/LLVMBitCodes.h
@@ -85,7 +85,7 @@
MODULE_CODE_ASM = 4, // ASM: [strchr x N]
MODULE_CODE_SECTIONNAME = 5, // SECTIONNAME: [strchr x N]
- // FIXME: Remove DEPLIB in 4.0.
+ // Deprecated, but still needed to read old bitcode files.
MODULE_CODE_DEPLIB = 6, // DEPLIB: [strchr x N]
// GLOBALVAR: [pointer type, isconst, initid,
@@ -121,7 +121,7 @@
/// PARAMATTR blocks have code for defining a parameter attribute set.
enum AttributeCodes {
- // FIXME: Remove `PARAMATTR_CODE_ENTRY_OLD' in 4.0
+ // Deprecated, but still needed to read old bitcode files.
PARAMATTR_CODE_ENTRY_OLD = 1, // ENTRY: [paramidx0, attr0,
// paramidx1, attr1...]
PARAMATTR_CODE_ENTRY = 2, // ENTRY: [attrgrp0, attrgrp1, ...]
@@ -166,7 +166,10 @@
TYPE_CODE_FUNCTION = 21, // FUNCTION: [vararg, retty, paramty x N]
- TYPE_CODE_TOKEN = 22 // TOKEN
+ TYPE_CODE_TOKEN = 22, // TOKEN
+
+ TYPE_CODE_BFLOAT = 23, // BRAIN FLOATING POINT
+ TYPE_CODE_X86_AMX = 24 // X86 AMX
};
enum OperandBundleTagCode {
@@ -288,6 +291,11 @@
// numrefs, numrefs x valueid,
// n x (valueid, offset)]
FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS = 23,
+ // The total number of basic blocks in the module.
+ FS_BLOCK_COUNT = 24,
+ // Range information for accessed offsets for every argument.
+ // [n x (paramno, range, numcalls, numcalls x (callee_guid, paramno, range))]
+ FS_PARAM_ACCESS = 25,
};
enum MetadataCodes {
@@ -331,7 +339,11 @@
METADATA_INDEX_OFFSET = 38, // [offset]
METADATA_INDEX = 39, // [bitpos]
METADATA_LABEL = 40, // [distinct, scope, name, file, line]
- METADATA_COMMON_BLOCK = 44, // [distinct, scope, name, variable,...]
+ METADATA_STRING_TYPE = 41, // [distinct, name, size, align,...]
+ // Codes 42 and 43 are reserved for support for Fortran array specific debug
+ // info.
+ METADATA_COMMON_BLOCK = 44, // [distinct, scope, name, variable,...]
+ METADATA_GENERIC_SUBRANGE = 45 // [distinct, count, lo, up, stride]
};
// The constants block (CONSTANTS_BLOCK_ID) describes emission for each
@@ -364,6 +376,7 @@
// asmdialect,asmstr,conststr]
CST_CODE_CE_GEP_WITH_INRANGE_INDEX = 24, // [opty, flags, n x operands]
CST_CODE_CE_UNOP = 25, // CE_UNOP: [opcode, opval]
+ CST_CODE_POISON = 26, // POISON
};
/// CastOpcodes - These are values used in the bitcode files to encode which
@@ -391,7 +404,7 @@
/// have no fixed relation to the LLVM IR enum values. Changing these will
/// break compatibility with old files.
enum UnaryOpcodes {
- UNOP_NEG = 0
+ UNOP_FNEG = 0
};
/// BinaryOpcodes - These are values used in the bitcode files to encode which
@@ -529,8 +542,9 @@
FUNC_CODE_DEBUG_LOC = 35, // DEBUG_LOC: [Line,Col,ScopeVal, IAVal]
FUNC_CODE_INST_FENCE = 36, // FENCE: [ordering, synchscope]
- FUNC_CODE_INST_CMPXCHG_OLD = 37, // CMPXCHG: [ptrty,ptr,cmp,new, align, vol,
- // ordering, synchscope]
+ FUNC_CODE_INST_CMPXCHG_OLD = 37, // CMPXCHG: [ptrty, ptr, cmp, val, vol,
+ // ordering, synchscope,
+ // failure_ordering?, weak?]
FUNC_CODE_INST_ATOMICRMW = 38, // ATOMICRMW: [ptrty,ptr,val, operation,
// align, vol,
// ordering, synchscope]
@@ -544,8 +558,9 @@
FUNC_CODE_INST_GEP = 43, // GEP: [inbounds, n x operands]
FUNC_CODE_INST_STORE = 44, // STORE: [ptrty,ptr,valty,val, align, vol]
FUNC_CODE_INST_STOREATOMIC = 45, // STORE: [ptrty,ptr,val, align, vol
- FUNC_CODE_INST_CMPXCHG = 46, // CMPXCHG: [ptrty,ptr,valty,cmp,new, align,
- // vol,ordering,synchscope]
+ FUNC_CODE_INST_CMPXCHG = 46, // CMPXCHG: [ptrty, ptr, cmp, val, vol,
+ // success_ordering, synchscope,
+ // failure_ordering, weak]
FUNC_CODE_INST_LANDINGPAD = 47, // LANDINGPAD: [ty,val,num,id0,val0...]
FUNC_CODE_INST_CLEANUPRET = 48, // CLEANUPRET: [val] or [val,bb#]
FUNC_CODE_INST_CATCHRET = 49, // CATCHRET: [val,bb#]
@@ -559,6 +574,7 @@
FUNC_CODE_INST_UNOP = 56, // UNOP: [opcode, ty, opval]
FUNC_CODE_INST_CALLBR = 57, // CALLBR: [attr, cc, norm, transfs,
// fnty, fnid, args...]
+ FUNC_CODE_INST_FREEZE = 58, // FREEZE: [opty, opval]
};
enum UseListCodes {
@@ -629,7 +645,17 @@
ATTR_KIND_SPECULATIVE_LOAD_HARDENING = 59,
ATTR_KIND_IMMARG = 60,
ATTR_KIND_WILLRETURN = 61,
- ATTR_KIND_NOFREE = 62
+ ATTR_KIND_NOFREE = 62,
+ ATTR_KIND_NOSYNC = 63,
+ ATTR_KIND_SANITIZE_MEMTAG = 64,
+ ATTR_KIND_PREALLOCATED = 65,
+ ATTR_KIND_NO_MERGE = 66,
+ ATTR_KIND_NULL_POINTER_IS_VALID = 67,
+ ATTR_KIND_NOUNDEF = 68,
+ ATTR_KIND_BYREF = 69,
+ ATTR_KIND_MUSTPROGRESS = 70,
+ ATTR_KIND_NO_CALLBACK = 71,
+ ATTR_KIND_HOT = 72,
};
enum ComdatSelectionKindCodes {