This is an archive of the discontinued LLVM Phabricator instance.

[RDA] Track implicit-defs
ClosedPublic

Authored by samparker on Feb 26 2020, 8:20 AM.

Details

Summary

Ensure that we're recording implicit defs, as well as visiting implicit uses and implicit defs when we're walking through operands. This requires a change to ARMLowOverheadLoops because RDA now knows that t2LoopEnd is set to define the CPSR.

Diff Detail

Event Timeline

samparker created this revision.Feb 26 2020, 8:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 26 2020, 8:20 AM
samparker updated this revision to Diff 246894.Feb 27 2020, 1:47 AM

Rebased for new test case.

SjoerdMeijer added inline comments.Feb 27 2020, 5:30 AM
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
129

I am thinking if it is time for a MO helper function that tests this, because I see a lot of the same/similar checks:

if (!MO.isReg() || !MO.isUse() || MO.getReg() != PhysReg)
if (!MO.isReg() || !MO.isUse() || MO.getReg() != PhysReg)
if (MO.isReg() && MO.isDef() && MO.getReg() == PhysReg)
if (MO.isReg() && MO.isDef() && MO.getReg() == PhysReg)
if (!MO.isReg() || MO.isUndef() || !MO.getReg())
if (MO.isReg() && MO.getReg() && Defs.count(MO.getReg()))
if (!MO.isReg() || MO.isUse() || MO.getReg() == 0)
if (!MO.isReg() || MO.getReg() == 0 || !MO.isKill())
if (MO.isReg() && MO.isDef() && MO.getReg() == PhysReg)

Perhaps a local static helper function(s) is easiest to increase readability?

samparker updated this revision to Diff 246932.Feb 27 2020, 6:48 AM

Adding a few helpers for use/defs.

Thanks for that! That greatly helps readability!

Where in this patch stack do we expect test changes?

samparker updated this revision to Diff 246946.Feb 27 2020, 7:52 AM

Rebased after reverting to show the test changes that we want.

SjoerdMeijer added inline comments.Feb 28 2020, 1:56 AM
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
820

Do we need to start looking again for t2LoopEnd? Is that not saved to End, do we have access to that?

samparker marked an inline comment as done.Feb 28 2020, 2:29 AM
samparker added inline comments.
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
820

We still need this because t2LoopEnd isn't actually the last instruction, there's almost certainly an unconditional branch as the terminator, so this code was originally not doing what is was supposed to! Now that we're correctly tracking implicit-defs, RDA will pick up that !isSafeToDefRegAt because t2LoopEnd has an implicit CPSR def and we definitely want to ignore it.

SjoerdMeijer accepted this revision.Feb 28 2020, 2:49 AM

Thanks, LGTM

This revision is now accepted and ready to land.Feb 28 2020, 2:49 AM
This revision was automatically updated to reflect the committed changes.