[Matrix] Check if iterator is at beginning of BB in optimizeTranspose.
authorFlorian Hahn <flo@fhahn.com>
Tue, 14 Jun 2022 20:37:02 +0000 (21:37 +0100)
committerFlorian Hahn <flo@fhahn.com>
Tue, 14 Jun 2022 20:37:02 +0000 (21:37 +0100)
commit7c0089d7351cf7ab067e987aa2e32db4b07b3adf
tree7a507191cf632989da291fff15ed235e5ce0f37c
parent1a19abf38c3afb66b680cea69c8e61ea152e1514
[Matrix] Check if iterator is at beginning of BB in optimizeTranspose.

If an instruction at the beginning of a block is erased,  this may
trigger crash due to dereferencing an invalid iterator.

Check if II is at the end before dereferencing it.

Reviewed By: thegameg

Differential Revision: https://reviews.llvm.org/D127736
llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
llvm/test/Transforms/LowerMatrixIntrinsics/transpose-opts-iterator-invalidation.ll [new file with mode: 0644]