This is an archive of the discontinued LLVM Phabricator instance.

Fix assertion failure in getMemOperandWithOffsetWidth
ClosedPublic

Authored by kristof.beyls on Dec 11 2019, 7:08 AM.

Details

Summary

This fixes an assertion failure that triggers inside
getMemOperandWithOffset when Machine Sinking calls it on a MachineInstr
that is not a memory operation.

Different backends implement getMemOperandWithOffset differently: some
return false on non-memory MachineInstrs, others assert.

The Machine Sinking pass in at least SinkingPreventsImplicitNullCheck
relies on getMemOperandWithOffset to return false on non-memory
MachineInstrs, instead of asserting.

This patch updates the documentation on getMemOperandWithOffset that it
should return false on any MachineInstr it cannot handle, instead of
asserting. It also adapts the in-tree backends accordingly where
necessary.

Diff Detail

Event Timeline

kristof.beyls created this revision.Dec 11 2019, 7:08 AM
bjope added a subscriber: bjope.Dec 11 2019, 11:41 PM
Jim added a subscriber: Jim.Dec 12 2019, 1:51 AM
Jim added a comment.Dec 12 2019, 2:00 AM

Could you remove "[PATCH]" from the title?

kristof.beyls retitled this revision from [PATCH] Fix assertion failure in getMemOperandWithOffsetWidth to Fix assertion failure in getMemOperandWithOffsetWidth.Dec 12 2019, 2:08 AM
sdesmalen added inline comments.Dec 12 2019, 2:40 AM
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
2031–2032

Should this return false as well, instead of asserting? And if so, is there a way to construct a test for that?

llvm/test/CodeGen/AArch64/machine-sink-getmemoperandwithoffset.mir
35

nit: Can you add a comment clarifying which instruction (that is not a load or store) would have caused the assert to fail?

nhaehnle removed a subscriber: nhaehnle.Dec 13 2019, 5:46 AM

Addressed Sander's comments.

kristof.beyls marked 4 inline comments as done.Dec 16 2019, 3:12 AM
kristof.beyls added inline comments.
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
2031–2032

Thanks - good catch!

llvm/test/CodeGen/AArch64/machine-sink-getmemoperandwithoffset.mir
35

I now added a comment that hopefully is useful for people reading this test in the future, see a few lines below.

sdesmalen accepted this revision.Dec 16 2019, 7:14 AM

LGTM, thanks @kristof.beyls!

llvm/test/CodeGen/AArch64/machine-sink-getmemoperandwithoffset.mir
35

Thanks, that comment seems useful to me.

This revision is now accepted and ready to land.Dec 16 2019, 7:14 AM
This revision was automatically updated to reflect the committed changes.
kristof.beyls marked 2 inline comments as done.