From f75f4d65730cef5646ac7472354e71f7df528df7 Mon Sep 17 00:00:00 2001 From: Tony Jiang Date: Mon, 20 Nov 2017 16:55:07 +0000 Subject: [MachineCSE] Add new callback for is caller preserved or constant physregs The instructions addis,addi, bl are used to calculate the address of TLS thread local variables. These TLS access code sequences are generated repeatedly every time the thread local variable is accessed. By communicating to Machine CSE that X2 is guaranteed to have the same value within the same function call (so called Caller Preserved Physical Register), the redundant TLS access code sequences are cleaned up. Differential Revision: https://reviews.llvm.org/D39173 llvm-svn: 318661 --- llvm/lib/CodeGen/MachineCSE.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'llvm/lib/CodeGen/MachineCSE.cpp') diff --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp index 32e57a9f938..aaac6ad9336 100644 --- a/llvm/lib/CodeGen/MachineCSE.cpp +++ b/llvm/lib/CodeGen/MachineCSE.cpp @@ -250,8 +250,8 @@ bool MachineCSE::hasLivePhysRegDefUses(const MachineInstr *MI, continue; if (TargetRegisterInfo::isVirtualRegister(Reg)) continue; - // Reading constant physregs is ok. - if (!MRI->isConstantPhysReg(Reg)) + // Reading either caller preserved or constant physregs is ok. + if (!MRI->isCallerPreservedOrConstPhysReg(Reg)) for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) PhysRefs.insert(*AI); } -- cgit v1.2.3