Revert [BitcodeReader] Validate OpNum, before accessing Record array.
authorFlorian Hahn <flo@fhahn.com>
Thu, 11 Jul 2019 10:53:40 +0000 (10:53 +0000)
committerFlorian Hahn <flo@fhahn.com>
Thu, 11 Jul 2019 10:53:40 +0000 (10:53 +0000)
This reverts r365750 (git commit 8b222ecf2769ee133691f208f6166ce118c4a164)

llvm-dis runs out of memory while opening invalid-fcmp-opnum.bc on
llvm-hexagon-elf, probably because the bitcode file contains other
suspicious values.

http://lab.llvm.org:8011/builders/llvm-hexagon-elf/builds/21949

llvm-svn: 365757

llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/test/Bitcode/Inputs/invalid-fcmp-opnum.bc [deleted file]
llvm/test/Bitcode/invalid.test

index 0d302b7..0ba76f0 100644 (file)
@@ -4165,10 +4165,6 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
           popValue(Record, OpNum, NextValueNo, LHS->getType(), RHS))
         return error("Invalid record");
 
-      if (OpNum >= Record.size())
-        return error(
-            "Invalid record: operand number exceeded available operands");
-
       unsigned PredVal = Record[OpNum];
       bool IsFP = LHS->getType()->isFPOrFPVectorTy();
       FastMathFlags FMF;
diff --git a/llvm/test/Bitcode/Inputs/invalid-fcmp-opnum.bc b/llvm/test/Bitcode/Inputs/invalid-fcmp-opnum.bc
deleted file mode 100644 (file)
index 454a14b..0000000
Binary files a/llvm/test/Bitcode/Inputs/invalid-fcmp-opnum.bc and /dev/null differ
index d1f9d7c..2a9af06 100644 (file)
@@ -235,8 +235,3 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-nonpointer-atomicrmw.bc 2>&1
 RUN:   FileCheck --check-prefix=NONPOINTER-ATOMICRMW %s
 
 NONPOINTER-ATOMICRMW: Invalid record
-
-RUN: not llvm-dis -disable-output %p/Inputs/invalid-fcmp-opnum.bc 2>&1 | \
-RUN:   FileCheck --check-prefix=INVALID-FCMP-OPNUM %s
-
-INVALID-FCMP-OPNUM: Invalid record: operand number exceeded available operands