From a9b3303a8847e100ae23fa711f9b5b8963ebdaf9 Mon Sep 17 00:00:00 2001 From: Chen Zheng Date: Mon, 18 Jan 2021 21:33:31 -0500 Subject: [PATCH] Revert "[NFC] [TargetRegisterInfo] add one use check to lookThruCopyLike." This reverts commit 3bdf4507b66348ad78df4655a8e4f36c3fc10f3c. Post commit comments need to be addressed first. --- llvm/include/llvm/CodeGen/TargetRegisterInfo.h | 7 ++----- llvm/lib/CodeGen/TargetRegisterInfo.cpp | 19 +++++-------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h index e07779e..6f32729 100644 --- a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h +++ b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h @@ -410,13 +410,10 @@ public: /// Returns the original SrcReg unless it is the target of a copy-like /// operation, in which case we chain backwards through all such operations - /// to the ultimate source register. If a physical register is encountered, + /// to the ultimate source register. If a physical register is encountered, /// we stop the search. - /// If one definition in the copy chain has multiple uses, set \p - /// AllDefHaveOneUser to false, otherwise set it to true. virtual Register lookThruCopyLike(Register SrcReg, - const MachineRegisterInfo *MRI, - bool *AllDefHaveOneUser = nullptr) const; + const MachineRegisterInfo *MRI) const; /// Return a null-terminated list of all of the callee-saved registers on /// this target. The register should be in the order of desired callee-save diff --git a/llvm/lib/CodeGen/TargetRegisterInfo.cpp b/llvm/lib/CodeGen/TargetRegisterInfo.cpp index 09c7383..4a190c9 100644 --- a/llvm/lib/CodeGen/TargetRegisterInfo.cpp +++ b/llvm/lib/CodeGen/TargetRegisterInfo.cpp @@ -510,19 +510,13 @@ TargetRegisterInfo::getRegSizeInBits(Register Reg, return getRegSizeInBits(*RC); } -Register TargetRegisterInfo::lookThruCopyLike(Register SrcReg, - const MachineRegisterInfo *MRI, - bool *AllDefHaveOneUser) const { - if (AllDefHaveOneUser) - *AllDefHaveOneUser = true; - +Register +TargetRegisterInfo::lookThruCopyLike(Register SrcReg, + const MachineRegisterInfo *MRI) const { while (true) { const MachineInstr *MI = MRI->getVRegDef(SrcReg); - if (!MI->isCopyLike()) { - if (AllDefHaveOneUser && !MRI->hasOneNonDBGUse(SrcReg)) - *AllDefHaveOneUser = false; + if (!MI->isCopyLike()) return SrcReg; - } Register CopySrcReg; if (MI->isCopy()) @@ -532,11 +526,8 @@ Register TargetRegisterInfo::lookThruCopyLike(Register SrcReg, CopySrcReg = MI->getOperand(2).getReg(); } - if (!CopySrcReg.isVirtual()) { - if (AllDefHaveOneUser) - *AllDefHaveOneUser = false; + if (!CopySrcReg.isVirtual()) return CopySrcReg; - } SrcReg = CopySrcReg; } -- 2.7.4