This is an archive of the discontinued LLVM Phabricator instance.

[M68k] Fix the crash of fast register allocator
ClosedPublic

Authored by 0x59616e on Sep 9 2022, 11:49 PM.

Details

Summary

MOVEM is used to spill the register, which will cause problem with 1 byte data, since it only supports word (2 bytes) and long (4 bytes) size.

We change to use the normal move instruction to spill 1 byte data.

Fixes #57660

Diff Detail

Event Timeline

0x59616e created this revision.Sep 9 2022, 11:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2022, 11:49 PM
0x59616e requested review of this revision.Sep 9 2022, 11:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2022, 11:49 PM
0x59616e edited the summary of this revision. (Show Details)Sep 9 2022, 11:49 PM
RKSimon added inline comments.Sep 10 2022, 3:25 AM
llvm/test/CodeGen/M68k/fast-regalloc.ll
4 ↗(On Diff #459266)

Please can you reference PR57660 in a comment or test name to speed up any triage when people look at this test file in the future.

0x59616e updated this revision to Diff 459278.Sep 10 2022, 3:33 AM

Add comment to refer to the issue.

0x59616e marked an inline comment as done.Sep 10 2022, 3:33 AM
RKSimon added inline comments.Sep 10 2022, 5:17 AM
llvm/lib/Target/M68k/M68kRegisterInfo.td
95 ↗(On Diff #459278)

does i16 need fixing as well?

myhsu added a comment.Sep 10 2022, 1:37 PM

Thank you for fixing this bug!
As I mentioned in #57660, I feel like we should fix the assertion instead

0x59616e planned changes to this revision.Sep 11 2022, 7:31 PM
0x59616e updated this revision to Diff 459395.Sep 11 2022, 8:02 PM
0x59616e edited the summary of this revision. (Show Details)

Fix the assertion in M68kInstrInfo::storeRegToStackSlot and M68kInstrInfo::loadRegFromStackSlot

myhsu added inline comments.Sep 12 2022, 10:21 PM
llvm/lib/Target/M68k/M68kInstrInfo.cpp
705

Oh I didn't notice this, thanks for spotting

748

Instead of remove these assertions completely, can we check if the object size matches the spill size of the given register class (like what X86 is doing). Ditto for loadRegFromStackSlot.

0x59616e updated this revision to Diff 459703.Sep 13 2022, 3:28 AM
0x59616e marked 2 inline comments as done.

Add assertion to check the size of the stack slot matches the size of register class

myhsu accepted this revision.Sep 14 2022, 8:08 AM

LGTM, thanks

This revision is now accepted and ready to land.Sep 14 2022, 8:08 AM
This revision was landed with ongoing or failed builds.Sep 14 2022, 6:24 PM
This revision was automatically updated to reflect the committed changes.