This is an archive of the discontinued LLVM Phabricator instance.

NVPTX: Avoid implicit iterator conversions, NFC
ClosedPublic

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

Details

Reviewers
jlebar
Summary

Avoid implicit conversions from MachineInstrBundleInstr to MachineInstr*
in the MSP430 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
NVPTXInstrInfo::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 63287.Jul 8 2016, 12:21 PM
dexonsmith retitled this revision from to NVPTX: Avoid implicit iterator conversions, NFC.
dexonsmith updated this object.
dexonsmith added a subscriber: llvm-commits.
jlebar added a subscriber: jlebar.Jul 8 2016, 1:42 PM

in the MSP430 backend

Wrong commit message?

from MachineInstrBundleInstr

MachineInstrBundleIterator?

Otherwise looks good to me. This is a simplification, so I like it on face, but do you also expect this change (when made everywhere in llvm) to have performance implications?

jlebar accepted this revision.Jul 8 2016, 1:43 PM
jlebar added a reviewer: jlebar.
This revision is now accepted and ready to land.Jul 8 2016, 1:43 PM

Thanks for the review! Committed in r274931. (Answers to your questions below, inline.)

dexonsmith closed this revision.Jul 8 2016, 2:19 PM