This is an archive of the discontinued LLVM Phabricator instance.

[AVR] Fix incorrect flags of livein registers when spilling them
ClosedPublic

Authored by benshi001 on Feb 24 2023, 4:10 AM.

Details

Summary

In AVRFrameLowering::spillCalleeSavedRegisters(), when a 16-bit
livein register is spilled, two PUSH instructions are generated
for the higher and lower 8-bit registers. But these two 8-bit
registers are marked as killed in the two PUSH instructions, so
any future use of them will lead to a crash.

This patch fixes the above issue by adding the two 8-bit sub
registers to the livein list.

Fixes https://github.com/llvm/llvm-project/issues/56423

Diff Detail

Event Timeline

benshi001 created this revision.Feb 24 2023, 4:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2023, 4:10 AM
benshi001 requested review of this revision.Feb 24 2023, 4:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2023, 4:10 AM
benshi001 edited the summary of this revision. (Show Details)Feb 24 2023, 4:13 AM
benshi001 updated this revision to Diff 500531.Feb 26 2023, 2:46 AM
benshi001 edited the summary of this revision. (Show Details)
jacquesguan added inline comments.Feb 27 2023, 12:35 AM
llvm/lib/Target/AVR/AVRFrameLowering.cpp
264

livein should be capital.

268

Could we use isSubRegister to check if it is a subreg?

benshi001 updated this revision to Diff 500736.Feb 27 2023, 4:22 AM
benshi001 marked 2 inline comments as done.
benshi001 added inline comments.
llvm/lib/Target/AVR/AVRFrameLowering.cpp
268

Thanks. This isSubRegister really make code more clear.

benshi001 marked an inline comment as done.Feb 27 2023, 4:23 AM
benshi001 updated this revision to Diff 500985.Feb 27 2023, 5:30 PM
This revision is now accepted and ready to land.Feb 27 2023, 7:05 PM