This is an archive of the discontinued LLVM Phabricator instance.

[RegisterCoalescer] Fix updating LiveIntervals in joinReservedPhysReg
ClosedPublic

Authored by foad on May 24 2023, 4:04 AM.

Details

Summary

Live intervals for physical registers are calculated lazily on demand.
In a case like this:

16B    %0:gpr32 = IMPLICIT_DEF
32B    $wzr = COPY %0

if the live interval for $wzr did not already exist then the update code
in joinReservedPhysReg would create it with a definition at 32B, which
would remain even after the COPY was deleted.

Diff Detail

Event Timeline

foad created this revision.May 24 2023, 4:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2023, 4:04 AM
foad requested review of this revision.May 24 2023, 4:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2023, 4:04 AM
foad added inline comments.
llvm/lib/CodeGen/RegisterCoalescer.cpp
2242

In the old code, if the live interval did not already exist, this would do nothing...

2245

... and this would create a new live interval including the dead def at 32B, which would not get removed when CopyMI was deleted.

llvm/test/CodeGen/AArch64/regcoal-physreg.mir
1–5

This is a hack to ensure that machine verification gets run after (the first run of) simple-register-coalescing. It will not be required after D129208 lands.

foad updated this revision to Diff 525104.May 24 2023, 4:09 AM

Blank line

arsenm accepted this revision.May 24 2023, 6:38 AM
arsenm added inline comments.
llvm/test/CodeGen/AArch64/regcoal-physreg.mir
1–5

Should add a comment here explaining this

This revision is now accepted and ready to land.May 24 2023, 6:38 AM
This revision was landed with ongoing or failed builds.May 24 2023, 7:21 AM
This revision was automatically updated to reflect the committed changes.