This is an archive of the discontinued LLVM Phabricator instance.

[MachineDCE] Move machine DCE into using LivePhysRegs infrastructure
AcceptedPublic

Authored by kariddi on Apr 14 2020, 3:02 PM.

Details

Summary

MachineDCE adds to the live physical registers the live in registers
of the successor blocks, but it doesn't really add the subregisters
of those, which are also live, causing potentially instructions subregs
only to be deleted.
Changing MachineDCE into using LivePhysRegs that does the same thing
the pass is doing manually while at the same time not having the same bug
described above.

Diff Detail

Event Timeline

kariddi created this revision.Apr 14 2020, 3:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2020, 3:02 PM
kariddi added a reviewer: hgreving.
arsenm added inline comments.Apr 14 2020, 3:49 PM
llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
123–124

RegAliasIterator? also need the super regs?

arsenm added inline comments.Apr 14 2020, 3:57 PM
llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
123–124

Wait, actually why is this code here at all? There is already a LivePhysRegs class which is what I initially assumed this was

kariddi marked an inline comment as done.Apr 14 2020, 6:23 PM
kariddi added inline comments.
llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
123–124
  1. I don't think the all the aliases should be considered "live". I think that if a register is not in the "live" list then it means that as a unit it is not considered live. Like, the subregisters here, if they are not in the list it means that they are not used as subregisters themselves in the block (until they are defined themselves potentially in the block). They can be live though as part of the a bigger entity
  1. Yeah, this code doesn't use that. I just fixed the problems here, but its a good point, maybe we should port this code to use LivePhysReg. I'll take a stab at that.
kariddi updated this revision to Diff 257593.Apr 14 2020, 9:04 PM

Moving to LivePhysReg

kariddi updated this revision to Diff 257613.Apr 15 2020, 12:28 AM

use addLiveOuts()

kariddi retitled this revision from [MachineDCE] Make sure MachineDCE considers subregs when adding liveins. to [MachineDCE] Move machine DCE into using LivePhysRegs infrastructure.Apr 16 2020, 7:25 PM
kariddi edited the summary of this revision. (Show Details)
arsenm accepted this revision.Jun 5 2020, 6:15 AM

LGTM

This revision is now accepted and ready to land.Jun 5 2020, 6:15 AM

D124168 should replace this

Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2022, 9:26 AM