aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-06-26 09:51:31 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-06-26 09:51:31 -0700
commit69aca3260c03ec742256b5518886f0562a658df2 (patch)
treee48e5c5cf70bb9564a43140dfb89b05036677a3c /lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
parente635564fe07f78c19fd6022aa105f620e7cad60a (diff)
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
Diffstat (limited to 'lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp')
-rw-r--r--lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp17
1 files changed, 8 insertions, 9 deletions
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<PointerType>(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;
}