Index: src/PNaClTranslator.cpp |
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp |
index 0f4feacafe5d2768bd8edae99a2ab2f6c5a65087..f858da97e84a499c556950ed7c9a35eb43e9c530 100644 |
--- a/src/PNaClTranslator.cpp |
+++ b/src/PNaClTranslator.cpp |
@@ -158,10 +158,13 @@ void ExtendedType::dump(Ice::Ostream &Stream) const { |
} |
} |
+class BlockParserBaseClass; |
+ |
// Top-level class to read PNaCl bitcode files, and translate to ICE. |
class TopLevelParser : public NaClBitcodeParser { |
TopLevelParser(const TopLevelParser &) = delete; |
TopLevelParser &operator=(const TopLevelParser &) = delete; |
+ friend class BlockParserBaseClass; |
Jim Stichnoth
2014/11/19 19:21:00
Can we avoid resorting to friend declarations this
Karl
2014/11/20 17:32:09
No longer friendly.
|
public: |
typedef std::vector<Ice::FunctionDeclaration *> FunctionDeclarationListType; |
@@ -173,7 +176,7 @@ public: |
Mod(new Module(InputName, getGlobalContext())), DL(PNaClDataLayout), |
Header(Header), TypeConverter(Mod->getContext()), |
ErrorStatus(ErrorStatus), NumErrors(0), NumFunctionIds(0), |
- NumFunctionBlocks(0) { |
+ NumFunctionBlocks(0), BlockParser(nullptr) { |
Mod->setDataLayout(PNaClDataLayout); |
setErrStream(Translator.getContext()->getStrDump()); |
} |
@@ -183,14 +186,10 @@ public: |
Ice::Translator &getTranslator() { return Translator; } |
// Generates error with given Message. Always returns true. |
- bool Error(const std::string &Message) override { |
- ErrorStatus = true; |
- ++NumErrors; |
- NaClBitcodeParser::Error(Message); |
- if (!AllowErrorRecovery) |
- report_fatal_error("Unable to continue"); |
- return true; |
- } |
+ bool Error(const std::string &Message) override; |
+ |
+ // Generates error message with respect to the current block parser. |
+ bool BlockError(const std::string &Message); |
/// Returns the number of errors found while parsing the bitcode |
/// file. |
@@ -319,7 +318,7 @@ public: |
std::string Buffer; |
raw_string_ostream StrBuf(Buffer); |
StrBuf << "Reference to global not defined: " << ID; |
- Error(StrBuf.str()); |
+ BlockError(StrBuf.str()); |
// TODO(kschimpf) Remove error recovery once implementation complete. |
Name = "??"; |
SuppressMangling = false; |
@@ -429,6 +428,9 @@ private: |
std::vector<unsigned> DefiningFunctionDeclarationsList; |
// Error recovery value to use when getFuncSigTypeByID fails. |
Ice::FuncSigType UndefinedFuncSigType; |
+ // The block parser currently being applied. Used for error |
+ // reporting. |
+ BlockParserBaseClass *BlockParser; |
bool ParseBlock(unsigned BlockID) override; |
@@ -466,6 +468,15 @@ private: |
Ice::Type convertToIceTypeError(Type *LLVMTy); |
}; |
+bool TopLevelParser::Error(const std::string &Message) { |
+ ErrorStatus = true; |
+ ++NumErrors; |
+ NaClBitcodeParser::Error(Message); |
+ if (!AllowErrorRecovery) |
+ report_fatal_error("Unable to continue"); |
+ return true; |
+} |
+ |
void TopLevelParser::reportBadTypeIDAs(unsigned ID, const ExtendedType *Ty, |
ExtendedType::TypeKind WantedType) { |
std::string Buffer; |
@@ -475,7 +486,7 @@ void TopLevelParser::reportBadTypeIDAs(unsigned ID, const ExtendedType *Ty, |
} else { |
StrBuf << "Type id " << ID << " not " << WantedType << ". Found: " << *Ty; |
} |
- Error(StrBuf.str()); |
+ BlockError(StrBuf.str()); |
} |
Ice::FunctionDeclaration * |
@@ -485,7 +496,7 @@ TopLevelParser::reportGetFunctionByIDError(unsigned ID) { |
StrBuf << "Function index " << ID |
<< " not allowed. Out of range. Must be less than " |
<< FunctionDeclarationList.size(); |
- Error(StrBuf.str()); |
+ BlockError(StrBuf.str()); |
// TODO(kschimpf) Remove error recovery once implementation complete. |
if (!FunctionDeclarationList.empty()) |
return FunctionDeclarationList[0]; |
@@ -499,7 +510,7 @@ TopLevelParser::reportGetGlobalVariableByIDError(unsigned Index) { |
StrBuf << "Global index " << Index |
<< " not allowed. Out of range. Must be less than " |
<< VariableDeclarations.size(); |
- Error(StrBuf.str()); |
+ BlockError(StrBuf.str()); |
// TODO(kschimpf) Remove error recovery once implementation complete. |
if (!VariableDeclarations.empty()) |
return VariableDeclarations[0]; |
@@ -519,12 +530,24 @@ Ice::Type TopLevelParser::convertToIceTypeError(Type *LLVMTy) { |
// messages if ParseBlock or ParseRecord is not overridden in derived |
// classes. |
class BlockParserBaseClass : public NaClBitcodeParser { |
+ BlockParserBaseClass(const BlockParserBaseClass &) = delete; |
+ BlockParserBaseClass &operator=(const BlockParserBaseClass &) = delete; |
+ friend class TopLevelParser; |
+ |
public: |
// Constructor for the top-level module block parser. |
BlockParserBaseClass(unsigned BlockID, TopLevelParser *Context) |
- : NaClBitcodeParser(BlockID, Context), Context(Context) {} |
+ : NaClBitcodeParser(BlockID, Context), Context(Context) { |
+ Context->BlockParser = this; |
+ } |
- ~BlockParserBaseClass() override {} |
+ ~BlockParserBaseClass() override { Context->BlockParser = nullptr; } |
+ |
+ // Returns the printable name of the type of block being parsed. |
+ virtual const char *getBlockName() const { |
+ // If this class is used, it is parsing an unknown block. |
+ return "unknown"; |
+ } |
protected: |
// The context parser that contains the decoded state. |
@@ -546,20 +569,7 @@ protected: |
} |
// Generates an error Message with the bit address prefixed to it. |
- bool Error(const std::string &Message) override { |
- uint64_t Bit = Record.GetStartBit() + Context->getHeaderSize() * 8; |
- std::string Buffer; |
- raw_string_ostream StrBuf(Buffer); |
- StrBuf << "(" << format("%" PRIu64 ":%u", (Bit / 8), |
- static_cast<unsigned>(Bit % 8)) << ") "; |
- // Note: If dump routines have been turned off, the error messages |
- // will not be readable. Hence, replace with simple error. |
- if (ALLOW_DUMP) |
- StrBuf << Message; |
- else |
- StrBuf << "Invalid input record"; |
- return Context->Error(StrBuf.str()); |
- } |
+ bool Error(const std::string &Message) override; |
// Default implementation. Reports that block is unknown and skips |
// its contents. |
@@ -620,12 +630,43 @@ private: |
const char *ContextMessage); |
}; |
+bool TopLevelParser::BlockError(const std::string &Message) { |
+ if (BlockParser) |
+ return BlockParser->Error(Message); |
+ else |
+ return Error(Message); |
+} |
+ |
+// Generates an error Message with the bit address prefixed to it. |
+bool BlockParserBaseClass::Error(const std::string &Message) { |
+ uint64_t Bit = Record.GetStartBit() + Context->getHeaderSize() * 8; |
+ std::string Buffer; |
+ raw_string_ostream StrBuf(Buffer); |
+ StrBuf << "(" << format("%" PRIu64 ":%u", (Bit / 8), |
+ static_cast<unsigned>(Bit % 8)) << ") "; |
+ // Note: If dump routines have been turned off, the error messages |
+ // will not be readable. Hence, replace with simple error. |
+ if (ALLOW_DUMP) |
+ StrBuf << Message; |
+ else { |
+ StrBuf << "Invalid " << getBlockName() << " record: <" << Record.GetCode(); |
+ for (const auto Val : Record.GetValues()) { |
Jim Stichnoth
2014/11/19 23:30:36
Probably better not to use auto here, since one ha
|
+ StrBuf << " " << Val; |
+ } |
+ StrBuf << ">"; |
+ } |
+ return Context->Error(StrBuf.str()); |
+} |
+ |
void BlockParserBaseClass::ReportRecordSizeError(unsigned ExpectedSize, |
const char *RecordName, |
const char *ContextMessage) { |
std::string Buffer; |
raw_string_ostream StrBuf(Buffer); |
- StrBuf << RecordName << " record expects"; |
+ const char *BlockName = getBlockName(); |
+ const char FirstChar = toupper(*BlockName); |
+ StrBuf << FirstChar << (BlockName + 1) << " " << RecordName |
+ << " record expects"; |
if (ContextMessage) |
StrBuf << " " << ContextMessage; |
StrBuf << " " << ExpectedSize << " argument"; |
@@ -651,7 +692,8 @@ void BlockParserBaseClass::ProcessRecord() { |
// If called, derived class doesn't know how to handle. |
std::string Buffer; |
raw_string_ostream StrBuf(Buffer); |
- StrBuf << "Don't know how to process record: " << Record; |
+ StrBuf << "Don't know how to process " << getBlockName() |
+ << " record:" << Record; |
Error(StrBuf.str()); |
} |
@@ -673,6 +715,8 @@ private: |
void ProcessRecord() override; |
+ const char *getBlockName() const override { return "type"; } |
+ |
void setNextTypeIDAsSimpleType(Ice::Type Ty) { |
Context->getTypeByIDForDefining(NextTypeId++)->setAsSimpleType(Ty); |
} |
@@ -683,31 +727,31 @@ void TypesParser::ProcessRecord() { |
switch (Record.GetCode()) { |
case naclbitc::TYPE_CODE_NUMENTRY: |
// NUMENTRY: [numentries] |
- if (!isValidRecordSize(1, "Type count")) |
+ if (!isValidRecordSize(1, "count")) |
return; |
Context->resizeTypeIDValues(Values[0]); |
return; |
case naclbitc::TYPE_CODE_VOID: |
// VOID |
- if (!isValidRecordSize(0, "Type void")) |
+ if (!isValidRecordSize(0, "void")) |
return; |
setNextTypeIDAsSimpleType(Ice::IceType_void); |
return; |
case naclbitc::TYPE_CODE_FLOAT: |
// FLOAT |
- if (!isValidRecordSize(0, "Type float")) |
+ if (!isValidRecordSize(0, "float")) |
return; |
setNextTypeIDAsSimpleType(Ice::IceType_f32); |
return; |
case naclbitc::TYPE_CODE_DOUBLE: |
// DOUBLE |
- if (!isValidRecordSize(0, "Type double")) |
+ if (!isValidRecordSize(0, "double")) |
return; |
setNextTypeIDAsSimpleType(Ice::IceType_f64); |
return; |
case naclbitc::TYPE_CODE_INTEGER: |
// INTEGER: [width] |
- if (!isValidRecordSize(1, "Type integer")) |
+ if (!isValidRecordSize(1, "integer")) |
return; |
switch (Values[0]) { |
case 1: |
@@ -737,7 +781,7 @@ void TypesParser::ProcessRecord() { |
return; |
case naclbitc::TYPE_CODE_VECTOR: { |
// VECTOR: [numelts, eltty] |
- if (!isValidRecordSize(2, "Type vector")) |
+ if (!isValidRecordSize(2, "vector")) |
return; |
Ice::Type BaseTy = Context->getSimpleTypeByID(Values[1]); |
Ice::SizeT Size = Values[0]; |
@@ -795,7 +839,7 @@ void TypesParser::ProcessRecord() { |
} |
case naclbitc::TYPE_CODE_FUNCTION: { |
// FUNCTION: [vararg, retty, paramty x N] |
- if (!isValidRecordSizeAtLeast(2, "Type signature")) |
+ if (!isValidRecordSizeAtLeast(2, "signature")) |
return; |
if (Values[0]) |
Error("Function type can't define varargs"); |
@@ -841,6 +885,8 @@ public: |
~GlobalsParser() final {} |
+ const char *getBlockName() const override { return "globals"; } |
+ |
private: |
Ice::TimerMarker Timer; |
// Keeps track of how many initializers are expected for the global variable |
@@ -864,7 +910,7 @@ private: |
if (NextGlobalID < NumIDs) { |
std::string Buffer; |
raw_string_ostream StrBuf(Buffer); |
- StrBuf << "Globals block expects " << NumIDs |
+ StrBuf << getBlockName() << " block expects " << NumIDs |
<< " global variable declarations. Found: " << NextGlobalID; |
Error(StrBuf.str()); |
} |
@@ -898,7 +944,7 @@ void GlobalsParser::ProcessRecord() { |
switch (Record.GetCode()) { |
case naclbitc::GLOBALVAR_COUNT: |
// COUNT: [n] |
- if (!isValidRecordSize(1, "Globals count")) |
+ if (!isValidRecordSize(1, "count")) |
return; |
if (NextGlobalID != Context->getNumGlobalVariables()) { |
Error("Globals count record not first in block."); |
@@ -908,7 +954,7 @@ void GlobalsParser::ProcessRecord() { |
return; |
case naclbitc::GLOBALVAR_VAR: { |
// VAR: [align, isconst] |
- if (!isValidRecordSize(2, "Globals variable")) |
+ if (!isValidRecordSize(2, "variable")) |
return; |
verifyNoMissingInitializers(); |
if (!isIRGenerationDisabled()) { |
@@ -922,7 +968,7 @@ void GlobalsParser::ProcessRecord() { |
} |
case naclbitc::GLOBALVAR_COMPOUND: |
// COMPOUND: [size] |
- if (!isValidRecordSize(1, "globals compound")) |
+ if (!isValidRecordSize(1, "compound")) |
return; |
if (!CurGlobalVar->getInitializers().empty()) { |
Error("Globals compound record not first initializer"); |
@@ -931,7 +977,8 @@ void GlobalsParser::ProcessRecord() { |
if (Values[0] < 2) { |
std::string Buffer; |
raw_string_ostream StrBuf(Buffer); |
- StrBuf << "Globals compound record size invalid. Found: " << Values[0]; |
+ StrBuf << getBlockName() |
+ << " compound record size invalid. Found: " << Values[0]; |
Error(StrBuf.str()); |
return; |
} |
@@ -941,7 +988,7 @@ void GlobalsParser::ProcessRecord() { |
return; |
case naclbitc::GLOBALVAR_ZEROFILL: { |
// ZEROFILL: [size] |
- if (!isValidRecordSize(1, "Globals zerofill")) |
+ if (!isValidRecordSize(1, "zerofill")) |
return; |
if (isIRGenerationDisabled()) |
return; |
@@ -951,7 +998,7 @@ void GlobalsParser::ProcessRecord() { |
} |
case naclbitc::GLOBALVAR_DATA: { |
// DATA: [b0, b1, ...] |
- if (!isValidRecordSizeAtLeast(1, "Globals data")) |
+ if (!isValidRecordSizeAtLeast(1, "data")) |
return; |
if (isIRGenerationDisabled()) |
return; |
@@ -961,7 +1008,7 @@ void GlobalsParser::ProcessRecord() { |
} |
case naclbitc::GLOBALVAR_RELOC: { |
// RELOC: [val, [addend]] |
- if (!isValidRecordSizeInRange(1, 2, "Globals reloc")) |
+ if (!isValidRecordSizeInRange(1, 2, "reloc")) |
return; |
if (isIRGenerationDisabled()) |
return; |
@@ -990,6 +1037,8 @@ public: |
~ValuesymtabParser() override {} |
+ const char *getBlockName() const override { return "valuesymtab"; } |
+ |
protected: |
typedef SmallString<128> StringType; |
@@ -1017,7 +1066,7 @@ void ValuesymtabParser::ProcessRecord() { |
switch (Record.GetCode()) { |
case naclbitc::VST_CODE_ENTRY: { |
// VST_ENTRY: [ValueId, namechar x N] |
- if (!isValidRecordSizeAtLeast(2, "Valuesymtab value entry")) |
+ if (!isValidRecordSizeAtLeast(2, "value entry")) |
return; |
ConvertToString(ConvertedName); |
setValueName(Values[0], ConvertedName); |
@@ -1025,7 +1074,7 @@ void ValuesymtabParser::ProcessRecord() { |
} |
case naclbitc::VST_CODE_BBENTRY: { |
// VST_BBENTRY: [BbId, namechar x N] |
- if (!isValidRecordSizeAtLeast(2, "Valuesymtab basic block entry")) |
+ if (!isValidRecordSizeAtLeast(2, "basic block entry")) |
return; |
ConvertToString(ConvertedName); |
setBbName(Values[0], ConvertedName); |
@@ -1087,6 +1136,8 @@ public: |
~FunctionParser() final {} |
+ const char *getBlockName() const override { return "function"; } |
+ |
void setNextLocalInstIndex(Ice::Operand *Op) { |
setOperand(NextLocalInstIndex++, Op); |
} |
@@ -1758,7 +1809,7 @@ void FunctionParser::ProcessRecord() { |
switch (Record.GetCode()) { |
case naclbitc::FUNC_CODE_DECLAREBLOCKS: { |
// DECLAREBLOCKS: [n] |
- if (!isValidRecordSize(1, "function block count")) |
+ if (!isValidRecordSize(1, "count")) |
return; |
uint32_t NumBbs = Values[0]; |
if (NumBbs == 0) { |
@@ -1780,7 +1831,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_BINOP: { |
// BINOP: [opval, opval, opcode] |
- if (!isValidRecordSize(3, "function block binop")) |
+ if (!isValidRecordSize(3, "binop")) |
return; |
Ice::Operand *Op1 = getRelativeOperand(Values[0], BaseIndex); |
Ice::Operand *Op2 = getRelativeOperand(Values[1], BaseIndex); |
@@ -1809,7 +1860,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_CAST: { |
// CAST: [opval, destty, castopc] |
- if (!isValidRecordSize(3, "function block cast")) |
+ if (!isValidRecordSize(3, "cast")) |
return; |
Ice::Operand *Src = getRelativeOperand(Values[0], BaseIndex); |
Ice::Type CastType = Context->getSimpleTypeByID(Values[1]); |
@@ -1846,7 +1897,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_VSELECT: { |
// VSELECT: [opval, opval, pred] |
- if (!isValidRecordSize(3, "function block select")) |
+ if (!isValidRecordSize(3, "select")) |
return; |
Ice::Operand *ThenVal = getRelativeOperand(Values[0], BaseIndex); |
Ice::Operand *ElseVal = getRelativeOperand(Values[1], BaseIndex); |
@@ -1895,7 +1946,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_EXTRACTELT: { |
// EXTRACTELT: [opval, opval] |
- if (!isValidRecordSize(2, "function block extract element")) |
+ if (!isValidRecordSize(2, "extract element")) |
return; |
Ice::Operand *Vec = getRelativeOperand(Values[0], BaseIndex); |
Ice::Operand *Index = getRelativeOperand(Values[1], BaseIndex); |
@@ -1922,7 +1973,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_INSERTELT: { |
// INSERTELT: [opval, opval, opval] |
- if (!isValidRecordSize(3, "function block insert element")) |
+ if (!isValidRecordSize(3, "insert element")) |
return; |
Ice::Operand *Vec = getRelativeOperand(Values[0], BaseIndex); |
Ice::Operand *Elt = getRelativeOperand(Values[1], BaseIndex); |
@@ -1951,7 +2002,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_CMP2: { |
// CMP2: [opval, opval, pred] |
- if (!isValidRecordSize(3, "function block compare")) |
+ if (!isValidRecordSize(3, "compare")) |
return; |
Ice::Operand *Op1 = getRelativeOperand(Values[0], BaseIndex); |
Ice::Operand *Op2 = getRelativeOperand(Values[1], BaseIndex); |
@@ -2017,7 +2068,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_RET: { |
// RET: [opval?] |
- if (!isValidRecordSizeInRange(0, 1, "function block ret")) |
+ if (!isValidRecordSizeInRange(0, 1, "return")) |
return; |
if (Values.empty()) { |
if (isIRGenerationDisabled()) |
@@ -2045,7 +2096,7 @@ void FunctionParser::ProcessRecord() { |
CurrentNode->appendInst(Ice::InstBr::create(Func, Block)); |
} else { |
// BR: [bb#, bb#, opval] |
- if (!isValidRecordSize(3, "function block branch")) |
+ if (!isValidRecordSize(3, "branch")) |
return; |
Ice::Operand *Cond = getRelativeOperand(Values[2], BaseIndex); |
if (isIRGenerationDisabled()) { |
@@ -2079,7 +2130,7 @@ void FunctionParser::ProcessRecord() { |
// unnecesary data fields (i.e. constants 1). These were not |
// cleaned up in PNaCl bitcode because the bitcode format was |
// already frozen when the problem was noticed. |
- if (!isValidRecordSizeAtLeast(4, "function block switch")) |
+ if (!isValidRecordSizeAtLeast(4, "switch")) |
return; |
Ice::Type CondTy = Context->getSimpleTypeByID(Values[0]); |
@@ -2109,7 +2160,7 @@ void FunctionParser::ProcessRecord() { |
unsigned NumCases = Values[3]; |
// Now recognize each of the cases. |
- if (!isValidRecordSize(4 + NumCases * 4, "Function block switch")) |
+ if (!isValidRecordSize(4 + NumCases * 4, "switch")) |
return; |
Ice::InstSwitch *Switch = |
isIRGenDisabled ? nullptr : Ice::InstSwitch::create(Func, NumCases, |
@@ -2141,7 +2192,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_UNREACHABLE: { |
// UNREACHABLE: [] |
- if (!isValidRecordSize(0, "function block unreachable")) |
+ if (!isValidRecordSize(0, "unreachable")) |
return; |
if (isIRGenerationDisabled()) |
return; |
@@ -2152,7 +2203,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_PHI: { |
// PHI: [ty, val1, bb1, ..., valN, bbN] for n >= 2. |
- if (!isValidRecordSizeAtLeast(3, "function block phi")) |
+ if (!isValidRecordSizeAtLeast(3, "phi")) |
return; |
Ice::Type Ty = Context->getSimpleTypeByID(Values[0]); |
if ((Values.size() & 0x1) == 0) { |
@@ -2198,7 +2249,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_ALLOCA: { |
// ALLOCA: [Size, align] |
- if (!isValidRecordSize(2, "function block alloca")) |
+ if (!isValidRecordSize(2, "alloca")) |
return; |
Ice::Operand *ByteCount = getRelativeOperand(Values[0], BaseIndex); |
unsigned Alignment; |
@@ -2223,7 +2274,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_LOAD: { |
// LOAD: [address, align, ty] |
- if (!isValidRecordSize(3, "function block load")) |
+ if (!isValidRecordSize(3, "load")) |
return; |
Ice::Operand *Address = getRelativeOperand(Values[0], BaseIndex); |
Ice::Type Ty = Context->getSimpleTypeByID(Values[2]); |
@@ -2248,7 +2299,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_STORE: { |
// STORE: [address, value, align] |
- if (!isValidRecordSize(3, "function block store")) |
+ if (!isValidRecordSize(3, "store")) |
return; |
Ice::Operand *Address = getRelativeOperand(Values[0], BaseIndex); |
Ice::Operand *Value = getRelativeOperand(Values[1], BaseIndex); |
@@ -2280,10 +2331,10 @@ void FunctionParser::ProcessRecord() { |
// corresponding return type stored in CALL_INDIRECT record. |
Ice::SizeT ParamsStartIndex = 2; |
if (Record.GetCode() == naclbitc::FUNC_CODE_INST_CALL) { |
- if (!isValidRecordSizeAtLeast(2, "function block call")) |
+ if (!isValidRecordSizeAtLeast(2, "call")) |
return; |
} else { |
- if (!isValidRecordSizeAtLeast(3, "function block call indirect")) |
+ if (!isValidRecordSizeAtLeast(3, "call indirect")) |
return; |
ParamsStartIndex = 3; |
} |
@@ -2412,7 +2463,7 @@ void FunctionParser::ProcessRecord() { |
} |
case naclbitc::FUNC_CODE_INST_FORWARDTYPEREF: { |
// FORWARDTYPEREF: [opval, ty] |
- if (!isValidRecordSize(2, "function block forward type ref")) |
+ if (!isValidRecordSize(2, "forward type ref")) |
return; |
Ice::Type OpType = Context->getSimpleTypeByID(Values[1]); |
setOperand(Values[0], |
@@ -2439,6 +2490,8 @@ public: |
~ConstantsParser() override {} |
+ const char *getBlockName() const override { return "constants"; } |
+ |
private: |
Ice::TimerMarker Timer; |
// The parser of the function block this constants block appears in. |
@@ -2474,7 +2527,7 @@ void ConstantsParser::ProcessRecord() { |
} |
case naclbitc::CST_CODE_UNDEF: { |
// UNDEF |
- if (!isValidRecordSize(0, "constants block undef")) |
+ if (!isValidRecordSize(0, "undef")) |
return; |
if (!isValidNextConstantType()) |
return; |
@@ -2488,7 +2541,7 @@ void ConstantsParser::ProcessRecord() { |
} |
case naclbitc::CST_CODE_INTEGER: { |
// INTEGER: [intval] |
- if (!isValidRecordSize(1, "constants block integer")) |
+ if (!isValidRecordSize(1, "integer")) |
return; |
if (!isValidNextConstantType()) |
return; |
@@ -2516,7 +2569,7 @@ void ConstantsParser::ProcessRecord() { |
} |
case naclbitc::CST_CODE_FLOAT: { |
// FLOAT: [fpval] |
- if (!isValidRecordSize(1, "constants block float")) |
+ if (!isValidRecordSize(1, "float")) |
return; |
if (!isValidNextConstantType()) |
return; |
@@ -2648,6 +2701,8 @@ public: |
~ModuleParser() override {} |
+ const char *getBlockName() const override { return "module"; } |
+ |
private: |
Ice::TimerMarker Timer; |
// True if we have already installed names for unnamed global declarations, |
@@ -2767,7 +2822,7 @@ void ModuleParser::ProcessRecord() { |
switch (Record.GetCode()) { |
case naclbitc::MODULE_CODE_VERSION: { |
// VERSION: [version#] |
- if (!isValidRecordSize(1, "Module version")) |
+ if (!isValidRecordSize(1, "version")) |
return; |
unsigned Version = Values[0]; |
if (Version != 1) { |
@@ -2780,14 +2835,14 @@ void ModuleParser::ProcessRecord() { |
} |
case naclbitc::MODULE_CODE_FUNCTION: { |
// FUNCTION: [type, callingconv, isproto, linkage] |
- if (!isValidRecordSize(4, "Function heading")) |
+ if (!isValidRecordSize(4, "address")) |
return; |
const Ice::FuncSigType &Signature = Context->getFuncSigTypeByID(Values[0]); |
CallingConv::ID CallingConv; |
if (!naclbitc::DecodeCallingConv(Values[1], CallingConv)) { |
std::string Buffer; |
raw_string_ostream StrBuf(Buffer); |
- StrBuf << "Function heading has unknown calling convention: " |
+ StrBuf << "Function address has unknown calling convention: " |
<< Values[1]; |
Error(StrBuf.str()); |
return; |
@@ -2796,7 +2851,7 @@ void ModuleParser::ProcessRecord() { |
if (!naclbitc::DecodeLinkage(Values[3], Linkage)) { |
std::string Buffer; |
raw_string_ostream StrBuf(Buffer); |
- StrBuf << "Function heading has unknown linkage. Found " << Values[3]; |
+ StrBuf << "Function address has unknown linkage. Found " << Values[3]; |
Error(StrBuf.str()); |
return; |
} |