[AMDGPU] Fix crash in SILoadStoreOptimizer
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Wed, 1 Apr 2020 21:58:12 +0000 (14:58 -0700)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 2 Apr 2020 17:26:47 +0000 (10:26 -0700)
commitf2334a7ef255ffe906d864d7ba078aba54646abb
treeaa2150ae76626e9ba698cd78b169dfde370c9cf2
parentc3b5c98e39533302d27f13895dad1e7b2e425f68
[AMDGPU] Fix crash in SILoadStoreOptimizer

SILoadStoreOptimizer::checkAndPrepareMerge() expects base and
paired instruction to come in order and scans MBB from base to
the paired instruction. An original order can be changed if
there were a dependent instruction in between and base instruction
was moved.

Fixed by bailing the optimization. In theory it might be possible
still to perform a merge by swapping instructions, but on practice
it bails anyway because it finds dependency on that same instruction
which has resulted in the base move.

Differential Revision: https://reviews.llvm.org/D77245
llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
llvm/test/CodeGen/AMDGPU/merge-out-of-order-ldst.ll [new file with mode: 0644]
llvm/test/CodeGen/AMDGPU/merge-out-of-order-ldst.mir [new file with mode: 0644]