summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2015-04-17 06:40:14 +0000
committerDavid Blaikie <dblaikie@gmail.com>2015-04-17 06:40:14 +0000
commitdbe6e0f17187f02c836bbd34b8b153dd83225b59 (patch)
tree8de52267f95b8b60b0d6c02fa2bffe4979073214 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parente6aba2806cc3380b7c2cb29aa6ceba8af4c71534 (diff)
downloadbcm5719-llvm-dbe6e0f17187f02c836bbd34b8b153dd83225b59.tar.gz
bcm5719-llvm-dbe6e0f17187f02c836bbd34b8b153dd83225b59.zip
[opaque pointer type] Explicit pointee type for call instruction
Use an extra bit in the CCInfo to flag the newer version of the instructiont hat includes the type explicitly. Tested the newer error cases I added, but didn't add tests for the finer granularity improvements to existing error paths. llvm-svn: 235160
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 5366f5fb4ea..e37e8f49b33 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -299,9 +299,9 @@ private:
// have.
ResVal = getFnValueByID(ValNo, nullptr);
return ResVal == nullptr;
- } else if (Slot == Record.size()) {
- return true;
}
+ if (Slot == Record.size())
+ return true;
unsigned TypeNo = (unsigned)Record[Slot++];
ResVal = getFnValueByID(ValNo, getTypeByID(TypeNo));
@@ -4168,19 +4168,32 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
if (Record.size() < 3)
return Error("Invalid record");
- AttributeSet PAL = getAttributes(Record[0]);
- unsigned CCInfo = Record[1];
+ unsigned OpNum = 0;
+ AttributeSet PAL = getAttributes(Record[OpNum++]);
+ unsigned CCInfo = Record[OpNum++];
+
+ FunctionType *FTy = nullptr;
+ if (CCInfo >> 15 & 1 &&
+ !(FTy = dyn_cast<FunctionType>(getTypeByID(Record[OpNum++]))))
+ return Error("Explicit call type is not a function type");
- unsigned OpNum = 2;
Value *Callee;
if (getValueTypePair(Record, OpNum, NextValueNo, Callee))
return Error("Invalid record");
PointerType *OpTy = dyn_cast<PointerType>(Callee->getType());
- FunctionType *FTy = nullptr;
- if (OpTy) FTy = dyn_cast<FunctionType>(OpTy->getElementType());
- if (!FTy || Record.size() < FTy->getNumParams()+OpNum)
- return Error("Invalid record");
+ if (!OpTy)
+ return Error("Callee is not a pointer type");
+ FunctionType *PFTy = dyn_cast<FunctionType>(OpTy->getElementType());
+ if (!PFTy)
+ return Error("Callee is not of pointer to function type");
+ if (!FTy)
+ FTy = PFTy;
+ if (PFTy != FTy)
+ return Error("Explicit call type does not match pointee type of "
+ "callee operand");
+ if (Record.size() < FTy->getNumParams() + OpNum)
+ return Error("Insufficient operands to call");
SmallVector<Value*, 16> Args;
// Read the fixed params.
OpenPOWER on IntegriCloud