[AMDGPU] Fix access beyond the end of the basic block in execMayBeModifiedBeforeAnyUse.
authorvpykhtin <valery.pykhtin@gmail.com>
Wed, 14 Oct 2020 11:47:18 +0000 (14:47 +0300)
committervpykhtin <valery.pykhtin@gmail.com>
Fri, 23 Oct 2020 16:17:48 +0000 (19:17 +0300)
commit00255f419298b93c812324a257ff057e57ab5c04
treeeb72474eaeb90b7b940c41b5c60ae3ad4920adbe
parent5dd39923a09ec284d30083e5fadaa29e618d4446
[AMDGPU] Fix access beyond the end of the basic block in execMayBeModifiedBeforeAnyUse.

I was wrong in thinking that MRI.use_instructions return unique instructions and mislead Jay in his previous patch D64393.

First loop counted more instructions than it was in reality and the second loop went beyond the basic block with that counter.

I used Jay's previous code that relied on MRI.use_operands to constrain the number of instructions to check among.
modifiesRegister is inlined to reduce the number of passes over instruction operands and added assert on BB end boundary.

Differential Revision: https://reviews.llvm.org/D89386
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/unittests/Target/AMDGPU/CMakeLists.txt
llvm/unittests/Target/AMDGPU/ExecMayBeModifiedBeforeAnyUse.cpp [new file with mode: 0755]