[PATCH] D102907: [Verifier] Fail if vectors overrun for {insert,extract} vector intrinsics

Joe Ellis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 21 02:37:56 PDT 2021


joechrisellis created this revision.
joechrisellis added reviewers: sdesmalen, david-arm, peterwaller-arm, DavidTruby, bsmith.
Herald added subscribers: dexonsmith, hiraditya.
joechrisellis requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The langref (llvm/docs/LangRef.rst) specifies the following for the
llvm.experimental.vector.insert intrinsic:

  Elements ``idx`` through (``idx`` + num_elements(``subvec``) - 1)
  must be valid ``vec`` indices. If this condition cannot be determined
  statically but is false at runtime, then the result vector is
  undefined.

and the following for the llvm.experimental.vector.extract intrinsic:

  Elements ``idx`` through (``idx`` + num_elements(result_type) - 1)
  must be valid vector indices. If this condition cannot be determined
  statically but is false at runtime, then the result vector is
  undefined.

For the non-mixed cases (e.g. inserting/extracting a scalable into/from
another scalable, or inserting/extracting a fixed into/from another
fixed), it is possible to statically check whether or not the above
conditions are met.

This was previously missing from the verifier, and if the conditions
were found to be false, the result of the insertion/extraction would be
replaced with an undef.

This patch adds more checks to the verifier to ensure that these
constraints are not violated.

Depends on: D102842 <https://reviews.llvm.org/D102842>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102907

Files:
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/Verifier/insert-extract-intrinsics-invalid.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102907.346964.patch
Type: text/x-patch
Size: 7851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210521/8cbe1b00/attachment.bin>


More information about the llvm-commits mailing list