summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2015-03-16 21:48:46 +0000
committerDavid Blaikie <dblaikie@gmail.com>2015-03-16 21:48:46 +0000
commitc695cc7e589bd8b0380216ca875b1eaea6d10703 (patch)
tree67ab270a545bcafb8ad187780cde3a3acd16121c /llvm
parent73870dd4382065d261d7000d7c678fdaeccd9f61 (diff)
downloadbcm5719-llvm-c695cc7e589bd8b0380216ca875b1eaea6d10703.tar.gz
bcm5719-llvm-c695cc7e589bd8b0380216ca875b1eaea6d10703.zip
Add testing for mismatched explicit type on a load instruction when loading from bitcode
llvm-svn: 232424
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp6
-rw-r--r--llvm/test/Bitcode/Inputs/invalid-load-mismatched-explicit-type.bcbin0 -> 432 bytes
-rw-r--r--llvm/test/Bitcode/invalid.test3
3 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index a26c444c6cc..dd42bdb5804 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3648,9 +3648,9 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
return EC;
I = new LoadInst(Op, "", Record[OpNum+1], Align);
- (void)Ty;
- assert((!Ty || Ty == I->getType()) &&
- "Explicit type doesn't match pointee type of the first operand");
+ if (Ty && Ty != I->getType())
+ return Error("Explicit load type does not match pointee type of "
+ "pointer operand");
InstructionList.push_back(I);
break;
diff --git a/llvm/test/Bitcode/Inputs/invalid-load-mismatched-explicit-type.bc b/llvm/test/Bitcode/Inputs/invalid-load-mismatched-explicit-type.bc
new file mode 100644
index 00000000000..1b8cbc75131
--- /dev/null
+++ b/llvm/test/Bitcode/Inputs/invalid-load-mismatched-explicit-type.bc
Binary files differ
diff --git a/llvm/test/Bitcode/invalid.test b/llvm/test/Bitcode/invalid.test
index 7eb28aa6fba..edf122b8dff 100644
--- a/llvm/test/Bitcode/invalid.test
+++ b/llvm/test/Bitcode/invalid.test
@@ -14,6 +14,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-align.bc 2>&1 | \
RUN: FileCheck --check-prefix=BAD-ALIGN %s
RUN: not llvm-dis -disable-output %p/Inputs/invalid-gep-mismatched-explicit-type.bc 2>&1 | \
RUN: FileCheck --check-prefix=MISMATCHED-EXPLICIT-GEP %s
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-load-mismatched-explicit-type.bc 2>&1 | \
+RUN: FileCheck --check-prefix=MISMATCHED-EXPLICIT-LOAD %s
INVALID-ENCODING: Invalid encoding
BAD-ABBREV: Abbreviation starts with an Array or a Blob
@@ -23,6 +25,7 @@ BAD-TYPE-TABLE-FORWARD-REF: Invalid TYPE table: Only named structs can be forwar
BAD-BITWIDTH: Bitwidth for integer type out of range
BAD-ALIGN: Invalid alignment value
MISMATCHED-EXPLICIT-GEP: Explicit gep type does not match pointee type of pointer operand
+MISMATCHED-EXPLICIT-LOAD: Explicit load type does not match pointee type of pointer operand
RUN: not llvm-dis -disable-output %p/Inputs/invalid-extractval-array-idx.bc 2>&1 | \
RUN: FileCheck --check-prefix=EXTRACT-ARRAY %s
OpenPOWER on IntegriCloud