summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2015-04-24 18:06:06 +0000
committerDavid Blaikie <dblaikie@gmail.com>2015-04-24 18:06:06 +0000
commit5ea1f7b7440b7050abb912ce360c7cabcd8c2881 (patch)
tree885d2dedc2fa53f5a428d7f522fe8a2e705de731 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent08c5f1efc1c6d5c065eb9e66fc57ca681b8cf19e (diff)
downloadbcm5719-llvm-5ea1f7b7440b7050abb912ce360c7cabcd8c2881.tar.gz
bcm5719-llvm-5ea1f7b7440b7050abb912ce360c7cabcd8c2881.zip
[opaque pointer type] bitcode: add explicit callee type to invoke instructions
llvm-svn: 235735
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp37
1 files changed, 23 insertions, 14 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 57cd1d434dc..5f7a5ea1291 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3863,24 +3863,33 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
// INVOKE: [attrs, cc, normBB, unwindBB, fnty, op0,op1,op2, ...]
if (Record.size() < 4)
return Error("Invalid record");
- AttributeSet PAL = getAttributes(Record[0]);
- unsigned CCInfo = Record[1];
- BasicBlock *NormalBB = getBasicBlock(Record[2]);
- BasicBlock *UnwindBB = getBasicBlock(Record[3]);
+ unsigned OpNum = 0;
+ AttributeSet PAL = getAttributes(Record[OpNum++]);
+ unsigned CCInfo = Record[OpNum++];
+ BasicBlock *NormalBB = getBasicBlock(Record[OpNum++]);
+ BasicBlock *UnwindBB = getBasicBlock(Record[OpNum++]);
+
+ FunctionType *FTy = nullptr;
+ if (CCInfo >> 13 & 1 &&
+ !(FTy = dyn_cast<FunctionType>(getTypeByID(Record[OpNum++]))))
+ return Error("Explicit invoke type is not a function type");
- unsigned OpNum = 4;
Value *Callee;
if (getValueTypePair(Record, OpNum, NextValueNo, Callee))
return Error("Invalid record");
PointerType *CalleeTy = dyn_cast<PointerType>(Callee->getType());
- FunctionType *FTy = !CalleeTy ? nullptr :
- dyn_cast<FunctionType>(CalleeTy->getElementType());
-
- // Check that the right number of fixed parameters are here.
- if (!FTy || !NormalBB || !UnwindBB ||
- Record.size() < OpNum+FTy->getNumParams())
- return Error("Invalid record");
+ if (!CalleeTy)
+ return Error("Callee is not a pointer");
+ if (!FTy) {
+ FTy = dyn_cast<FunctionType>(CalleeTy->getElementType());
+ if (!FTy)
+ return Error("Callee is not of pointer to function type");
+ } else if (CalleeTy->getElementType() != FTy)
+ return Error("Explicit invoke type does not match pointee type of "
+ "callee operand");
+ if (Record.size() < FTy->getNumParams() + OpNum)
+ return Error("Insufficient operands to call");
SmallVector<Value*, 16> Ops;
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
@@ -3905,8 +3914,8 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
I = InvokeInst::Create(Callee, NormalBB, UnwindBB, Ops);
InstructionList.push_back(I);
- cast<InvokeInst>(I)->setCallingConv(
- static_cast<CallingConv::ID>(CCInfo));
+ cast<InvokeInst>(I)
+ ->setCallingConv(static_cast<CallingConv::ID>(~(1U << 13) & CCInfo));
cast<InvokeInst>(I)->setAttributes(PAL);
break;
}
OpenPOWER on IntegriCloud