https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/135024
Only one of ByOperand, ByInstr, or ByBundle should be true. Replace ByBundle with !ByInstr, and assert that both are not used. >From 751b2ad5ef572948a57cc0162a4dafc56f9f7d72 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <matthew.arsena...@amd.com> Date: Wed, 9 Apr 2025 12:20:48 +0800 Subject: [PATCH] CodeGen: Trim redundant template argument from defusechain_iterator Only one of ByOperand, ByInstr, or ByBundle should be true. Replace ByBundle with !ByInstr, and assert that both are not used. --- .../llvm/CodeGen/MachineRegisterInfo.h | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h index 1d4bcbb8cab9e..8e288cf212360 100644 --- a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h +++ b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h @@ -277,21 +277,18 @@ class MachineRegisterInfo { /// reg_begin/reg_end - Provide iteration support to walk over all definitions /// and uses of a register within the MachineFunction that corresponds to this /// MachineRegisterInfo object. - template<bool Uses, bool Defs, bool SkipDebug, - bool ByOperand, bool ByInstr, bool ByBundle> + template <bool Uses, bool Defs, bool SkipDebug, bool ByOperand, bool ByInstr> class defusechain_iterator; template <bool Uses, bool Defs, bool SkipDebug, bool ByInstr> class defusechain_instr_iterator; // Make it a friend so it can access getNextOperandForReg(). - template<bool, bool, bool, bool, bool, bool> - friend class defusechain_iterator; + template <bool, bool, bool, bool, bool> friend class defusechain_iterator; template <bool, bool, bool, bool> friend class defusechain_instr_iterator; /// reg_iterator/reg_begin/reg_end - Walk all defs and uses of the specified /// register. - using reg_iterator = - defusechain_iterator<true, true, false, true, false, false>; + using reg_iterator = defusechain_iterator<true, true, false, true, false>; reg_iterator reg_begin(Register RegNo) const { return reg_iterator(getRegUseDefListHead(RegNo)); } @@ -339,7 +336,7 @@ class MachineRegisterInfo { /// reg_nodbg_iterator/reg_nodbg_begin/reg_nodbg_end - Walk all defs and uses /// of the specified register, skipping those marked as Debug. using reg_nodbg_iterator = - defusechain_iterator<true, true, true, true, false, false>; + defusechain_iterator<true, true, true, true, false>; reg_nodbg_iterator reg_nodbg_begin(Register RegNo) const { return reg_nodbg_iterator(getRegUseDefListHead(RegNo)); } @@ -393,8 +390,7 @@ class MachineRegisterInfo { } /// def_iterator/def_begin/def_end - Walk all defs of the specified register. - using def_iterator = - defusechain_iterator<false, true, false, true, false, false>; + using def_iterator = defusechain_iterator<false, true, false, true, false>; def_iterator def_begin(Register RegNo) const { return def_iterator(getRegUseDefListHead(RegNo)); } @@ -473,8 +469,7 @@ class MachineRegisterInfo { } /// use_iterator/use_begin/use_end - Walk all uses of the specified register. - using use_iterator = - defusechain_iterator<true, false, false, true, false, false>; + using use_iterator = defusechain_iterator<true, false, false, true, false>; use_iterator use_begin(Register RegNo) const { return use_iterator(getRegUseDefListHead(RegNo)); } @@ -528,7 +523,7 @@ class MachineRegisterInfo { /// use_nodbg_iterator/use_nodbg_begin/use_nodbg_end - Walk all uses of the /// specified register, skipping those marked as Debug. using use_nodbg_iterator = - defusechain_iterator<true, false, true, true, false, false>; + defusechain_iterator<true, false, true, true, false>; use_nodbg_iterator use_nodbg_begin(Register RegNo) const { return use_nodbg_iterator(getRegUseDefListHead(RegNo)); } @@ -1045,9 +1040,11 @@ class MachineRegisterInfo { /// returns end(). If SkipDebug is true it skips uses marked Debug /// when incrementing. template <bool ReturnUses, bool ReturnDefs, bool SkipDebug, bool ByOperand, - bool ByInstr, bool ByBundle> + bool ByInstr> class defusechain_iterator { friend class MachineRegisterInfo; + static_assert(!ByOperand || !ByInstr, + "ByOperand and ByInstr are mutually exclusive"); public: using iterator_category = std::forward_iterator_tag; @@ -1110,7 +1107,7 @@ class MachineRegisterInfo { do { advance(); } while (Op && Op->getParent() == P); - } else if (ByBundle) { + } else { MachineBasicBlock::instr_iterator P = getBundleStart(Op->getParent()->getIterator()); do { _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits