We should check for same instruction class before checking whether they
have the same base address, else we might iterate out of bounds of a
MachineInstr operands list. The InstClass check is also cheaper.
This was introduced in SVN r373630.
Differential D68690
AMDGPU/SILoadStoreOptimizer: fix a likely bug introduced recently nhaehnle on Oct 9 2019, 3:56 AM. Authored by
Details We should check for same instruction class before checking whether they This was introduced in SVN r373630.
Diff Detail
Event TimelineComment Actions I didn't really have the bandwidth to think deeply about how to trigger this. It's more of a drive-by observation. Comment Actions Ping On the issue of a test case: I don't think it's practically possible to hit the crash I was worried about right now, because AddrIdx[0] happens to be small enough in all cases that it will be a valid operand index in all cases, and then hasSameBaseAddress will bail out for machine instructions of a different class because the register comparison of the first index will fail. However, that's just an artifact of how machine operand indices happen to be laid out today. I still maintain that the change itself is the right way to do things. |