From 69aca3260c03ec742256b5518886f0562a658df2 Mon Sep 17 00:00:00 2001 From: Mark Seaborn Date: Wed, 26 Jun 2013 09:51:31 -0700 Subject: PNaCl wire format: Clean up representation of "alloca" instruction For some reason, the size operand of "alloca" was represented using an absolute value ID + type, unlike other instructions where relative value IDs are used. Change the "alloca" representation to be consistent with other instructions, so that we can use PushValueAndType() in the writer and getValue() in the reader. Also take this opportunity to remove the field for alloca's result type, since it's always i8* in PNaCl. This is part of a cleanup to make forward reference handling stricter: it removes a use of getOrCreateFnValueByID(), which isn't strict (that is, it doesn't reject duplicate FORWARDTYPEREF records). BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17757004 --- lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp') diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp index 57dcea8953..8defdb5d1b 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp @@ -2283,16 +2283,15 @@ bool NaClBitcodeReader::ParseFunctionBody(Function *F) { break; } - case naclbitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align] - if (Record.size() != 4) + case naclbitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [op, align] + if (Record.size() != 2) + return Error("Invalid ALLOCA record"); + Value *Size; + unsigned OpNum = 0; + if (getValue(Record, OpNum, NextValueNo, Size)) return Error("Invalid ALLOCA record"); - PointerType *Ty = - dyn_cast_or_null(getTypeByID(Record[0])); - Type *OpTy = getTypeByID(Record[1]); - Value *Size = getOrCreateFnValueByID(Record[2], OpTy); - unsigned Align = Record[3]; - if (!Ty || !Size) return Error("Invalid ALLOCA record"); - I = new AllocaInst(Ty->getElementType(), Size, (1 << Align) >> 1); + unsigned Align = Record[1]; + I = new AllocaInst(Type::getInt8Ty(Context), Size, (1 << Align) >> 1); InstructionList.push_back(I); break; } -- cgit v1.2.3-70-g09d2