summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2015-04-17 19:56:21 +0000
committerDavid Blaikie <dblaikie@gmail.com>2015-04-17 19:56:21 +0000
commitb7a029873183cde33cfe065e655cd95309c6ac7f (patch)
treea4052ee9435f91896a4c18c06937bdac0ce4e04d /llvm/lib/Bitcode/Reader
parent50604a69e9c78d71c01fa171058f5bdfc83c4f50 (diff)
downloadbcm5719-llvm-b7a029873183cde33cfe065e655cd95309c6ac7f.tar.gz
bcm5719-llvm-b7a029873183cde33cfe065e655cd95309c6ac7f.zip
[opaque pointer types] Use the pointee type loaded from bitcode when constructing a LoadInst
Now (with a few carefully placed suppressions relating to general type serialization, etc) we can round trip a simple load through bitcode and textual IR without calling getElementType on a PointerType. llvm-svn: 235221
Diffstat (limited to 'llvm/lib/Bitcode/Reader')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index a3552e92a53..bc78a71efad 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -4002,15 +4002,16 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
Type *Ty = nullptr;
if (OpNum + 3 == Record.size())
Ty = getTypeByID(Record[OpNum++]);
+ if (!Ty)
+ Ty = cast<PointerType>(Op->getType())->getElementType();
+ else if (Ty != cast<PointerType>(Op->getType())->getElementType())
+ return Error("Explicit load type does not match pointee type of "
+ "pointer operand");
unsigned Align;
if (std::error_code EC = parseAlignmentValue(Record[OpNum], Align))
return EC;
- I = new LoadInst(Op, "", Record[OpNum+1], Align);
-
- if (Ty && Ty != I->getType())
- return Error("Explicit load type does not match pointee type of "
- "pointer operand");
+ I = new LoadInst(Ty, Op, "", Record[OpNum + 1], Align);
InstructionList.push_back(I);
break;
OpenPOWER on IntegriCloud