File tree Expand file tree Collapse file tree 5 files changed +8
-27
lines changed Expand file tree Collapse file tree 5 files changed +8
-27
lines changed Original file line number Diff line number Diff line change @@ -442,10 +442,7 @@ class MachineRegisterInfo {
442442 // / Return true if there is exactly one operand defining the specified
443443 // / register.
444444 bool hasOneDef (Register RegNo) const {
445- def_iterator DI = def_begin (RegNo);
446- if (DI == def_end ())
447- return false ;
448- return ++DI == def_end ();
445+ return hasSingleElement (def_operands (RegNo));
449446 }
450447
451448 // / Returns the defining operand if there is exactly one operand defining the
@@ -511,10 +508,7 @@ class MachineRegisterInfo {
511508 // / hasOneUse - Return true if there is exactly one instruction using the
512509 // / specified register.
513510 bool hasOneUse (Register RegNo) const {
514- use_iterator UI = use_begin (RegNo);
515- if (UI == use_end ())
516- return false ;
517- return ++UI == use_end ();
511+ return hasSingleElement (use_operands (RegNo));
518512 }
519513
520514 // / use_nodbg_iterator/use_nodbg_begin/use_nodbg_end - Walk all uses of the
Original file line number Diff line number Diff line change @@ -689,9 +689,7 @@ END_TWO_BYTE_PACK()
689689 bool use_empty () const { return UseList == nullptr ; }
690690
691691 // / Return true if there is exactly one use of this node.
692- bool hasOneUse () const {
693- return !use_empty () && std::next (use_begin ()) == use_end ();
694- }
692+ bool hasOneUse () const { return hasSingleElement (uses ()); }
695693
696694 // / Return the number of uses of this node. This method takes
697695 // / time proportional to the number of uses.
Original file line number Diff line number Diff line change @@ -434,11 +434,7 @@ class Value {
434434 // /
435435 // / This is specialized because it is a common request and does not require
436436 // / traversing the whole use list.
437- bool hasOneUse () const {
438- const_use_iterator I = use_begin (), E = use_end ();
439- if (I == E) return false ;
440- return ++I == E;
441- }
437+ bool hasOneUse () const { return hasSingleElement (uses ()); }
442438
443439 // / Return true if this Value has exactly N uses.
444440 bool hasNUses (unsigned N) const ;
Original file line number Diff line number Diff line change @@ -417,17 +417,11 @@ MachineInstr *MachineRegisterInfo::getUniqueVRegDef(Register Reg) const {
417417}
418418
419419bool MachineRegisterInfo::hasOneNonDBGUse (Register RegNo) const {
420- use_nodbg_iterator UI = use_nodbg_begin (RegNo);
421- if (UI == use_nodbg_end ())
422- return false ;
423- return ++UI == use_nodbg_end ();
420+ return hasSingleElement (use_nodbg_operands (RegNo));
424421}
425422
426423bool MachineRegisterInfo::hasOneNonDBGUser (Register RegNo) const {
427- use_instr_nodbg_iterator UI = use_instr_nodbg_begin (RegNo);
428- if (UI == use_instr_nodbg_end ())
429- return false ;
430- return ++UI == use_instr_nodbg_end ();
424+ return hasSingleElement (use_nodbg_instructions (RegNo));
431425}
432426
433427// / clearKillFlags - Iterate over all the uses of the given register and
Original file line number Diff line number Diff line change @@ -194,13 +194,12 @@ Optional<object::SectionedAddress>
194194DWARFUnit::getAddrOffsetSectionItem (uint32_t Index) const {
195195 if (IsDWO) {
196196 auto R = Context.info_section_units ();
197- auto I = R.begin ();
198197 // Surprising if a DWO file has more than one skeleton unit in it - this
199198 // probably shouldn't be valid, but if a use case is found, here's where to
200199 // support it (probably have to linearly search for the matching skeleton CU
201200 // here)
202- if (I != R. end () && std::next (I) == R. end ( ))
203- return (*I )->getAddrOffsetSectionItem (Index);
201+ if (hasSingleElement (R ))
202+ return (*R. begin () )->getAddrOffsetSectionItem (Index);
204203 }
205204 if (!AddrOffsetSectionBase)
206205 return None;
You can’t perform that action at this time.
0 commit comments