This is an archive of the discontinued LLVM Phabricator instance.

PowerPC: Avoid implicit iterator conversions, NFC
ClosedPublic

Authored by dexonsmith on Jul 8 2016, 12:25 PM.

Details

Summary

Avoid implicit conversions from MachineInstrBundleIterator to
MachineInstr* in the PowerPC backend, mainly by preferring MachineInstr&
over MachineInstr* when a pointer isn't nullable and using range-based
for loops.

There was one piece of questionable code in PPCInstrInfo::AnalyzeBranch,
where a condition checked a pointer converted from an iterator for
nullptr. Since this case is impossible (moreover, the code above
guarantees that the iterator is valid), I removed the check when I
changed the pointer to a reference.

Despite that case, there should be no functionality change here.

Diff Detail

Event Timeline

dexonsmith updated this revision to Diff 63291.Jul 8 2016, 12:25 PM
dexonsmith retitled this revision from to PowerPC: Avoid implicit iterator conversions, NFC.
dexonsmith updated this object.
dexonsmith added a subscriber: llvm-commits.

For what it's worth, this passes double bootstrap with all tests (lnt and unit tests) on a PPC64LE machine.

dexonsmith updated this object.Jul 8 2016, 2:30 PM

Fast ping, since this and the X86 patch are the only remaining blockers to removing the implicit MachineInstrBundleIterator::operator MachineInstr*(), and I'd like to prevent bitrot in the rest of the backend.

Note that I don't necessarily need PowerPC or even backend expertise for this review; I'd just appreciate someone double-checking that I didn't dereference an end-iterator somewhere or something like that. Is anyone willing to give this a quick read?

mehdi_amini accepted this revision.Jul 25 2016, 3:34 PM
mehdi_amini added a reviewer: mehdi_amini.
mehdi_amini added a subscriber: mehdi_amini.

This is very mechanical (and passed bootstrap testing already apparently). LGTM.

lib/Target/PowerPC/PPCVSXCopy.cpp
120

You're changing nothing but the formatting on this line, aren't you?

This revision is now accepted and ready to land.Jul 25 2016, 3:34 PM
dexonsmith closed this revision.Jul 27 2016, 6:35 AM

As mentioned on the review thread already (but adding to Phab since somehow it didn't make it here), this was r276864.