This is an archive of the discontinued LLVM Phabricator instance.

Fix the value_type of defusechain_iterator to match its operator*()
ClosedPublic

Authored by nlguillemot on Feb 25 2021, 7:03 PM.

Details

Summary

defusechain_iterator has an operator*() and operator->() that return
references to a MachineOperand, but its "reference" and "pointer"
typedefs are set as if the iterator returns a MachineInstr reference.
This causes compilation errors when defusechain_iterator is used in
generic code that uses the "reference" and "pointer" typedefs.
This patch fixes this by updating the typedefs to use MachineOperand
instead of MachineInstr.

Diff Detail

Event Timeline

nlguillemot requested review of this revision.Feb 25 2021, 7:03 PM
nlguillemot created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2021, 7:03 PM
nlguillemot added inline comments.Feb 25 2021, 7:09 PM
llvm/include/llvm/CodeGen/MachineRegisterInfo.h
974

There's another use here that needs to be updated.

By the way, I think this bug was introduced because defusechain_instr_iterator was copy/pasted make defusechain_iterator. Then maybe nobody ever tried to run a std algorithm with this iterator in a way that requires the typedefs to be correct.

Also fixed the wrong type in the base class.

mkitzan added a subscriber: mkitzan.

Will take a look at this one on Monday (March 1)

mkitzan accepted this revision.Mar 1 2021, 9:40 AM

Good catch!

This revision is now accepted and ready to land.Mar 1 2021, 9:40 AM