summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp11
-rw-r--r--llvm/lib/IR/Instructions.cpp4
2 files changed, 8 insertions, 7 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;
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 85b7521f316..1c831ccd289 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -945,9 +945,9 @@ LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
BasicBlock *InsertAE)
: LoadInst(Ptr, Name, isVolatile, /*Align=*/0, InsertAE) {}
-LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
+LoadInst::LoadInst(Type *Ty, Value *Ptr, const Twine &Name, bool isVolatile,
unsigned Align, Instruction *InsertBef)
- : LoadInst(Ptr, Name, isVolatile, Align, NotAtomic, CrossThread,
+ : LoadInst(Ty, Ptr, Name, isVolatile, Align, NotAtomic, CrossThread,
InsertBef) {}
LoadInst::LoadInst(Value *Ptr, const Twine &Name, bool isVolatile,
OpenPOWER on IntegriCloud