[GlobalISel] Fix crash in applyShiftOfShiftedLogic caused by CSEMIRBuilder reuse...
authorchenglin.bi <chenglin.bi@linaro.org>
Sat, 19 Nov 2022 01:11:47 +0000 (09:11 +0800)
committerchenglin.bi <chenglin.bi@linaro.org>
Sat, 19 Nov 2022 01:13:44 +0000 (09:13 +0800)
commitfe07eeb8254021fafe3dc0e88cc59862c1215f40
tree02f327b10e5ab76a0a7e91cf4407fb80805f7153
parent00be3578e0841dd9abe408e5b4946180de0bf46b
[GlobalISel] Fix crash in applyShiftOfShiftedLogic caused by CSEMIRBuilder reuse instruction

If LogicNonShiftReg is the same to Shift1Base, and shift1 const is the same to MatchInfo.Shift2 const, CSEMIRBuilder will reuse the old shift1 when build shift2.
So, if we erase MatchInfo.Shift2 at the end, actually we remove old shift1. And it will cause crash later.

Solution for this issue is just erase it earlier to avoid the crash.

Fix #58423

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D138187
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/test/CodeGen/AArch64/GlobalISel/pr58423.ll [new file with mode: 0644]