Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 713fa81

Browse files
committed
Merge origin/master.
Fix typo in unittests/Bitcode/CMakeLists.txt Fix new dbg.value tests in replace-ptrs-with-ints.ll test for new format
2 parents 9449db4 + fe3e971 commit 713fa81

36 files changed

+3438
-1124
lines changed

include/llvm/Bitcode/NaCl/NaClBitcodeHeader.h

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@ class NaClBitcodeHeaderField {
3838
// Defines the ID associated with the value. Valid values are in
3939
// {0x0, ..., 0xFFF}
4040
typedef enum {
41-
kInvalid = 0, // KUnknownType.
42-
kPNaClVersion = 1 // kUint32.
41+
kInvalid = 0, // KUnknownType.
42+
kPNaClVersion = 1, // kUint32Type.
43+
kAlignBitcodeRecords = 2, // kFlagType.
44+
kTag_MAX = kAlignBitcodeRecords
4345
} Tag;
4446
// Defines the type of value.
4547
typedef enum {
4648
kBufferType, // Buffer of form uint8_t[len].
47-
kUInt32Type
49+
kUInt32Type,
50+
kFlagType,
51+
kUnknownType,
52+
kFieldType_MAX = kUnknownType
4853
} FieldType;
4954
// Defines the number of bytes in a (32-bit) word.
5055
static const int WordSize = 4;
@@ -55,6 +60,9 @@ class NaClBitcodeHeaderField {
5560
// Create an invalid header field.
5661
NaClBitcodeHeaderField();
5762

63+
// Creates a header field where MyID is a flag.
64+
NaClBitcodeHeaderField(Tag MyID);
65+
5866
// Create a header field with an uint32_t value.
5967
NaClBitcodeHeaderField(Tag MyID, uint32_t value);
6068

@@ -78,6 +86,18 @@ class NaClBitcodeHeaderField {
7886
/// \brief Read field from Buf[BufLen].
7987
bool Read(const uint8_t *Buf, size_t BufLen);
8088

89+
/// \brief Returns string describing ID of field.
90+
static const char *IDName(Tag ID);
91+
const char *IDName() const {
92+
return IDName(ID);
93+
}
94+
95+
/// \brief Returns string describing type of field.
96+
static const char *TypeName(FieldType FType);
97+
const char *TypeName() const {
98+
return TypeName(FType);
99+
}
100+
81101
/// \brief Returns string describing field.
82102
std::string Contents() const;
83103

@@ -108,8 +128,11 @@ class NaClBitcodeHeaderField {
108128
FixedSubfield EncodeTypedID() const { return (ID << 4) | FType; }
109129
// Extract out ID and Type from a fixed subfield.
110130
void DecodeTypedID(FixedSubfield Subfield, Tag &ID, FieldType &FType) {
111-
ID = static_cast<Tag>(Subfield >> 4);
112-
FType = static_cast<FieldType>(Subfield & 0xF);
131+
FixedSubfield PossibleID = Subfield >> 4;
132+
ID = (PossibleID > kTag_MAX ? kInvalid : static_cast<Tag>(PossibleID));
133+
FixedSubfield PossibleFType = Subfield & 0xF;
134+
FType = (PossibleFType > kFieldType_MAX
135+
? kUnknownType : static_cast<FieldType>(PossibleFType));
113136
}
114137
// Combined size of the fixed subfields
115138
const static size_t kTagLenSize = 2 * sizeof(FixedSubfield);
@@ -144,6 +167,8 @@ class NaClBitcodeHeader {
144167
bool IsReadableFlag;
145168
// Defines the PNaCl version defined by the header file.
146169
uint32_t PNaClVersion;
170+
// Byte align bitcode records when nonzero.
171+
bool AlignBitcodeRecords = false;
147172

148173
public:
149174
static const int WordSize = NaClBitcodeHeaderField::WordSize;
@@ -173,7 +198,7 @@ class NaClBitcodeHeader {
173198
/// field.
174199
///
175200
/// Returns false if able to read (all of) the bitcode header.
176-
bool Read(const unsigned char *&BufPtr, const unsigned char *&BufEnd);
201+
bool Read(const unsigned char *BufPtr, const unsigned char *BufEnd);
177202

178203
// \brief Read the PNaCl bitcode header, recording the fields found
179204
// in the header. Returns false if able to read (all of) the bitcode header.
@@ -209,6 +234,9 @@ class NaClBitcodeHeader {
209234
/// \brief Returns the PNaClVersion, as defined by the header.
210235
uint32_t GetPNaClVersion() const { return PNaClVersion; }
211236

237+
/// \brief Returns if one should byte align bitcode records.
238+
bool getAlignBitcodeRecords() const { return AlignBitcodeRecords; }
239+
212240
private:
213241
// Reads and verifies the first 8 bytes of the header, consisting
214242
// of the magic number 'PEXE', and the value defining the number

0 commit comments

Comments
 (0)