[ARM] Fix crash in chained BFI combine due to incorrectly RAUW'ing a node.
authorAmara Emerson <amara@apple.com>
Thu, 24 Jun 2021 18:10:42 +0000 (11:10 -0700)
committerAmara Emerson <amara@apple.com>
Fri, 25 Jun 2021 06:35:47 +0000 (23:35 -0700)
commitf9b3840c3daf050d748f452a8105dfe661f8122e
treed8e0ce29f16e75f5008712d2ca62a72d865827bc
parentab1bd255939e23117706d79698b93f933fb114f4
[ARM] Fix crash in chained BFI combine due to incorrectly RAUW'ing a node.

For a bfi chain like:
a = bfi input, x, y
b = bfi a, x', y'

The previous code was RAUW'ing a with x, mutating the second 'b' bfi, and when
SelectionDAG's CSE code ended up deleting it unexpectedly, bad things happend.
There's no need to RAUW in this case because we can just return our newly
created replacement BFI node. It also looked incorrect because it didn't account
for other users of the 'a' bfi.

Since it seems that chains of more than 2 BFI nodes are hard/impossible to
produce without this combine kicking in at some point, I've removed that
functionality since it had no test coverage.

rdar://79095399

Differential Revision: https://reviews.llvm.org/D104868
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/test/CodeGen/ARM/bfi-chain-cse-crash.ll [new file with mode: 0644]