This is an archive of the discontinued LLVM Phabricator instance.

[Verifier] Fail if vectors overrun for {insert,extract} vector intrinsics
AbandonedPublic

Authored by joechrisellis on May 21 2021, 2:37 AM.

Details

Summary

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

Diff Detail

Event Timeline

joechrisellis created this revision.May 21 2021, 2:37 AM
joechrisellis requested review of this revision.May 21 2021, 2:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 21 2021, 2:37 AM
bsmith accepted this revision.May 25 2021, 5:16 AM

LGTM with a few minor nits.

llvm/lib/IR/Verifier.cpp
5327–5328

Nit: This feels like half a sentence, I would expect a , then ... after this.

5352

Nit: Could be ResultEC, as you have done in the insert case.

5356–5357

Nit: Same here as above.

This revision is now accepted and ready to land.May 25 2021, 5:16 AM
joechrisellis marked 3 inline comments as done.

Address review comments.

  • @bsmith:
    • clearer comments.
    • use ResultEC where we can.
joechrisellis abandoned this revision.Jun 17 2021, 8:58 AM

Thanks for the reviews guys.

Abandoning in favour of D104468.

Cheers!