This is an archive of the discontinued LLVM Phabricator instance.

Cleanup register pressure calculation in MachineLICM
ClosedPublic

Authored by djasper on Mar 25 2015, 6:17 AM.

Details

Reviewers
qcolombet
Summary

There were four almost identical implementations of calculating/updating the register pressure for a certain MachineInstr. Cleanup to have a single implementation (well, actually two, as bool flag now controls whether or not RegSeen should be considered).

Not functional changes intended.

Diff Detail

Event Timeline

djasper updated this revision to Diff 22643.Mar 25 2015, 6:17 AM
djasper retitled this revision from to Cleanup register pressure calculation in MachineLICM.
djasper updated this object.
djasper edited the test plan for this revision. (Show Details)
djasper added a reviewer: qcolombet.
djasper added a subscriber: Unknown Object (MLST).
qcolombet added inline comments.Mar 30 2015, 3:30 PM
lib/CodeGen/MachineLICM.cpp
896

I believe you meant -=

905

I believe taking a DenseMap as argument would be more appropriate.

The small vector is usually not small (about 80 reg classes on X86 and 50 reg classes on AArch for instance IIRC).

1127

Keep the DenseMap signature here.

djasper added inline comments.Mar 31 2015, 2:32 AM
lib/CodeGen/MachineLICM.cpp
896

Yes, thanks for catching.. I am a little frightened that this didn't break a single test ..

905

Ah, I assumed there was only a handful of classes usually. I should have checked. Thanks for explaining.

1127

Done.

djasper updated this revision to Diff 22931.Mar 31 2015, 2:32 AM
qcolombet added inline comments.Apr 1 2015, 1:35 PM
lib/CodeGen/MachineLICM.cpp
896

Could you try a llvm test-suite run to see if anything changes and if yes, extract a small test-case to add in this commit.

905

I would prefer a reference on the DenseMap.
Copying it around may not be efficient.

1127

This part of the patch is unrelated to this change (i.e., constify + for-range).
Please commit that separately.

djasper added inline comments.Apr 3 2015, 9:24 AM
lib/CodeGen/MachineLICM.cpp
897

Turns out, the + was actually correct, but I need to compare against -ClassAndCost.second above.

905

I think this is exactly what RVO was designed for and think that the code is cleaner and nicer with it.

Even if RVO should fail one day (which I don't think it will), I doubt the performance difference could be measured.

1127

Yeah, this was actually change when I was using a SmallVector, now it is just cleanup. Submitted separately in r234018.

djasper updated this revision to Diff 23222.Apr 3 2015, 9:27 AM

Regression testing has revealed that there is actually one more distinction to be made to avoid functional changes in this refactoring: Whether to count unseen registers as defs. Now, there are no regressions in the LLVM test suite.

qcolombet accepted this revision.Apr 3 2015, 9:58 AM
qcolombet edited edge metadata.

Regression testing has revealed that there is actually one more distinction to be made to avoid functional changes in this refactoring: Whether to count unseen registers as defs. Now, there are no regressions in the LLVM test suite.

Could you add the related test to make check?
I like to improve our code coverage in make check when we get the chance :).

Other than that LGTM.

Thanks,
-Quentin

This revision is now accepted and ready to land.Apr 3 2015, 9:58 AM
djasper closed this revision.Apr 7 2015, 9:45 AM

Submitted as r234325.