diff options
author | Chris Lattner <sabre@nondot.org> | 2008-02-21 04:55:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-02-21 04:55:52 +0000 |
commit | bd0818be2be161868702925c005843212596be59 (patch) | |
tree | ecadd35d333d99053d8c8191802004f74ad77b8b /lib | |
parent | dbcfb92ace78ecb95e5bb03bb7153b8f629fccc1 (diff) | |
download | external_llvm-bd0818be2be161868702925c005843212596be59.zip external_llvm-bd0818be2be161868702925c005843212596be59.tar.gz external_llvm-bd0818be2be161868702925c005843212596be59.tar.bz2 |
Fix a (harmless) but where vregs were added to the used reg lists for
inline asms.
Fix PR2078 by marking aliases of registers used when a register is
marked used. This prevents EAX from being allocated when AX is listed
in the clobber set for the asm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index b5e39a1..f36a120 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -3347,12 +3347,29 @@ struct AsmOperandInfo : public InlineAsm::ConstraintInfo { /// busy in OutputRegs/InputRegs. void MarkAllocatedRegs(bool isOutReg, bool isInReg, std::set<unsigned> &OutputRegs, - std::set<unsigned> &InputRegs) const { - if (isOutReg) - OutputRegs.insert(AssignedRegs.Regs.begin(), AssignedRegs.Regs.end()); - if (isInReg) - InputRegs.insert(AssignedRegs.Regs.begin(), AssignedRegs.Regs.end()); - } + std::set<unsigned> &InputRegs, + const TargetRegisterInfo &TRI) const { + if (isOutReg) { + for (unsigned i = 0, e = AssignedRegs.Regs.size(); i != e; ++i) + MarkRegAndAliases(AssignedRegs.Regs[i], OutputRegs, TRI); + } + if (isInReg) { + for (unsigned i = 0, e = AssignedRegs.Regs.size(); i != e; ++i) + MarkRegAndAliases(AssignedRegs.Regs[i], InputRegs, TRI); + } + } + +private: + /// MarkRegAndAliases - Mark the specified register and all aliases in the + /// specified set. + static void MarkRegAndAliases(unsigned Reg, std::set<unsigned> &Regs, + const TargetRegisterInfo &TRI) { + assert(TargetRegisterInfo::isPhysicalRegister(Reg) && "Isn't a physreg"); + Regs.insert(Reg); + if (const unsigned *Aliases = TRI.getAliasSet(Reg)) + for (; *Aliases; ++Aliases) + Regs.insert(*Aliases); + } }; } // end anon namespace. @@ -3491,7 +3508,8 @@ GetRegistersForValue(AsmOperandInfo &OpInfo, bool HasEarlyClobber, } } OpInfo.AssignedRegs = RegsForValue(Regs, RegVT, ValueVT); - OpInfo.MarkAllocatedRegs(isOutReg, isInReg, OutputRegs, InputRegs); + const TargetRegisterInfo *TRI = DAG.getTarget().getRegisterInfo(); + OpInfo.MarkAllocatedRegs(isOutReg, isInReg, OutputRegs, InputRegs, *TRI); return; } @@ -3519,7 +3537,6 @@ GetRegistersForValue(AsmOperandInfo &OpInfo, bool HasEarlyClobber, Regs.push_back(RegInfo.createVirtualRegister(PhysReg.second)); OpInfo.AssignedRegs = RegsForValue(Regs, RegVT, ValueVT); - OpInfo.MarkAllocatedRegs(isOutReg, isInReg, OutputRegs, InputRegs); return; } @@ -3571,7 +3588,7 @@ GetRegistersForValue(AsmOperandInfo &OpInfo, bool HasEarlyClobber, OpInfo.AssignedRegs = RegsForValue(Regs, *RC->vt_begin(), OpInfo.ConstraintVT); - OpInfo.MarkAllocatedRegs(isOutReg, isInReg, OutputRegs, InputRegs); + OpInfo.MarkAllocatedRegs(isOutReg, isInReg, OutputRegs, InputRegs, *TRI); return; } } |