mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-03 01:12:59 +00:00
fbf768a4d3
The implementation is fairly obvious. This is preparation for using some blobs in bitcode. For clarity (and perhaps future-proofing?), I moved the call to JumpToBit in BitstreamCursor::readRecord ahead of calling MemoryObject::getPointer, since JumpToBit can theoretically (a) read bytes, which (b) invalidates the blob pointer. This isn't strictly necessary the two memory objects we have: - The return of RawMemoryObject::getPointer is valid until the memory object is destroyed. - StreamingMemoryObject::getPointer is valid until the next chunk is read from the stream. Since the JumpToBit call is only going ahead to a word boundary, we'll never load another chunk. However, reordering makes it clear by inspection that the blob returned by BitstreamCursor::readRecord will be valid. I added some tests for StreamingMemoryObject::getPointer and BitstreamCursor::readRecord. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264549 91177308-0d34-0410-b5e6-96231b3b80d8
215 lines
9.7 KiB
Plaintext
215 lines
9.7 KiB
Plaintext
RUN: not llvm-dis -disable-output %p/Inputs/invalid-pr20485.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INVALID-ENCODING %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-abbrev.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=BAD-ABBREV %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-unexpected-eof.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=UNEXPECTED-EOF %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-bad-abbrev-number.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=BAD-ABBREV-NUMBER %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-type-table-forward-ref.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=BAD-TYPE-TABLE-FORWARD-REF %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-bitwidth.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=BAD-BITWIDTH %s
|
|
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
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-gep-operator-mismatched-explicit-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=MISMATCHED-EXPLICIT-GEP-OPERATOR %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-call-mismatched-explicit-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=MISMATCHED-EXPLICIT-CALL %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-call-non-function-explicit-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=NON-FUNCTION-EXPLICIT-CALL %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-invoke-mismatched-explicit-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=MISMATCHED-EXPLICIT-INVOKE %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-invoke-non-function-explicit-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=NON-FUNCTION-EXPLICIT-INVOKE %s
|
|
|
|
INVALID-ENCODING: Invalid encoding
|
|
BAD-ABBREV: Abbreviation starts with an Array or a Blob
|
|
UNEXPECTED-EOF: Unexpected end of file
|
|
BAD-ABBREV-NUMBER: Invalid abbrev number
|
|
BAD-TYPE-TABLE-FORWARD-REF: Invalid TYPE table: Only named structs can be forward referenced
|
|
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/store type does not match pointee type of pointer operand
|
|
MISMATCHED-EXPLICIT-GEP-OPERATOR: Explicit gep operator type does not match pointee type of pointer operand
|
|
MISMATCHED-EXPLICIT-CALL: Explicit call type does not match pointee type of callee operand
|
|
NON-FUNCTION-EXPLICIT-CALL: Explicit call type is not a function type
|
|
MISMATCHED-EXPLICIT-INVOKE: Explicit invoke type does not match pointee type of callee operand
|
|
NON-FUNCTION-EXPLICIT-INVOKE: Explicit invoke type is not a function type
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-extractval-array-idx.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=EXTRACT-ARRAY %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-extractval-struct-idx.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=EXTRACT-STRUCT %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-extractval-too-many-idxs.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=EXTRACT-IDXS %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-insertval-array-idx.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INSERT-ARRAY %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-insertval-struct-idx.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INSERT-STRUCT %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-insertval-too-many-idxs.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INSERT-IDXS %s
|
|
|
|
|
|
EXTRACT-ARRAY: EXTRACTVAL: Invalid array index
|
|
EXTRACT-STRUCT: EXTRACTVAL: Invalid struct index
|
|
EXTRACT-IDXS: EXTRACTVAL: Invalid type
|
|
INSERT-ARRAY: INSERTVAL: Invalid array index
|
|
INSERT-STRUCT: INSERTVAL: Invalid struct index
|
|
INSERT-IDXS: INSERTVAL: Invalid type
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-no-proper-module.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=NO-MODULE %s
|
|
|
|
NO-MODULE: Malformed IR file
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-fp-shift.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=FP-SHIFT %s
|
|
|
|
FP-SHIFT: Invalid record
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-abbrev-vbr-size-too-big.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=HUGE-ABBREV-OP %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-abbrev-fixed-size-too-big.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=HUGE-ABBREV-OP %s
|
|
|
|
HUGE-ABBREV-OP: Fixed or VBR abbrev record with size > MaxChunkData
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=ARRAY-TYPE %s
|
|
|
|
ARRAY-TYPE: Array element type can't be an Array or a Blob
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-non-vector-extractelement.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INVALID-TYPE %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-non-vector-insertelement.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INVALID-TYPE %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-non-vector-shufflevector.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INVALID-TYPE %s
|
|
|
|
INVALID-TYPE: Invalid type for value
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-fwdref-type-mismatch.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=FWDREF-TYPE %s
|
|
|
|
FWDREF-TYPE: Invalid record
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-fwdref-type-mismatch-2.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=FWDREF-TYPE-MISMATCH %s
|
|
|
|
FWDREF-TYPE-MISMATCH: Type mismatch in constant table!
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-element-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=ELEMENT-TYPE %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-vector-element-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=ELEMENT-TYPE %s
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-pointer-element-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=ELEMENT-TYPE %s
|
|
|
|
ELEMENT-TYPE: Invalid type
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-cast.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INVALID-CAST %s
|
|
|
|
INVALID-CAST: Invalid cast
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-op-not-2nd-to-last.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=ARRAY-NOT-2LAST %s
|
|
|
|
ARRAY-NOT-2LAST: Array op not second to last
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-too-big-fwdref.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=HUGE-FWDREF %s
|
|
|
|
HUGE-FWDREF: Invalid record
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-load-pointer-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=LOAD-BAD-TYPE %s
|
|
|
|
LOAD-BAD-TYPE: Load/Store operand is not a pointer type
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-GCTable-overflow.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=GCTABLE-OFLOW %s
|
|
|
|
GCTABLE-OFLOW: Invalid ID
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-insert-0-indices.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INSERT-0-IDXS %s
|
|
|
|
INSERT-0-IDXS: INSERTVAL: Invalid instruction with 0 indices
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-extract-0-indices.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=EXTRACT-0-IDXS %s
|
|
|
|
EXTRACT-0-IDXS: EXTRACTVAL: Invalid instruction with 0 indices
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-load-ptr-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=BAD-LOAD-PTR-TYPE %s
|
|
|
|
BAD-LOAD-PTR-TYPE: Cannot load/store from pointer
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-inserted-value-type-mismatch.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INSERT-TYPE-MISMATCH %s
|
|
|
|
INSERT-TYPE-MISMATCH: Inserted value type doesn't match aggregate type
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-code-len-width.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INVALID-CODELENWIDTH %s
|
|
|
|
INVALID-CODELENWIDTH: Malformed block
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-function-argument-type.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INVALID-ARGUMENT-TYPE %s
|
|
|
|
INVALID-ARGUMENT-TYPE: Invalid function argument type
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-function-comdat-id.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INVALID-FCOMDAT-ID %s
|
|
|
|
INVALID-FCOMDAT-ID: Invalid function comdat ID
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-global-var-comdat-id.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INVALID-GVCOMDAT-ID %s
|
|
|
|
INVALID-GVCOMDAT-ID: Invalid global variable comdat ID
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-abbrev-no-operands.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=ABBREV-NO-OPS %s
|
|
|
|
ABBREV-NO-OPS: Abbrev record with no operands
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-operand-encoding.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=ARRAY-OP-ENC %s
|
|
|
|
ARRAY-OP-ENC: Array element type has to be an encoding of a type
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-metadata-not-followed-named-node.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=META-NOT-FOLLOWED-BY-NAMED-META %s
|
|
|
|
META-NOT-FOLLOWED-BY-NAMED-META: METADATA_NAME not followed by METADATA_NAMED_NODE
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-vector-length.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=VECTOR-LENGTH %s
|
|
|
|
VECTOR-LENGTH: Invalid vector length
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-alias-type-mismatch.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=ALIAS-TYPE-MISMATCH %s
|
|
|
|
ALIAS-TYPE-MISMATCH: Alias and aliasee types don't match
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-no-function-block.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=NO-FUNCTION-BLOCK %s
|
|
|
|
NO-FUNCTION-BLOCK: Trying to materialize functions before seeing function blocks
|
|
|
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-name-with-0-byte.bc 2>&1 | \
|
|
RUN: FileCheck --check-prefix=NAME-WITH-0 %s
|
|
|
|
NAME-WITH-0: Invalid value name
|