llvm-project
fb392aeb - [X86][APX] Fix segfault in foldMemoryOperandImpl for two-address NDD fold (#190562)

Commit
55 days ago
[X86][APX] Fix segfault in foldMemoryOperandImpl for two-address NDD fold (#190562) The NoNDDM code path in foldMemoryOperandImpl assumed NewMI->getOperand(1) is always a register. When IsTwoAddr is true, fuseTwoAddrInst replaces operands 0-4 with memory address components, so getOperand(1) is the immediate, not a register. Calling setReg() causes a segfault in removeOperandFromUseList. Skip the NoNDDM COPY block when IsTwoAddr is true, since the two-address fold already correctly handles the dest==src1 constraint. I believe the issue was introduced with #189222 , the 'NoNDDM' block calls 'NewMI->getOperand(1).setReg()', but after 'fuseTwoAddrInst', operand 1 is an immediate, not a register. Passes all APX regression tests. Unit test included in commit. Fixes issue #190557. First time submitting a PR to the LLVM project, please let me know if I need to fix something! Tagging @phoebewang and @RKSimon as potential review candidates.
Author
Parents
Loading