From 6ebc207703607521b4cab5b211332a2a86757538 Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Tue, 5 May 2015 18:31:36 +0000 Subject: Fix IfConverter to handle regmask machine operands. A regmask (typically seen on a call) clobbers the set of registers it lists. The IfConverter, in UpdatePredRedefs, was handling register defs, but not regmasks. These are slightly different to a def in that we need to add both an implicit use and def to appease the machine verifier. Otherwise, uses after the if converted call could think they are reading an undefined register. Reviewed by Matthias Braun and Quentin Colombet. llvm-svn: 236515 --- llvm/lib/CodeGen/IfConversion.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp index 938c9cf6039..4bad70925d7 100644 --- a/llvm/lib/CodeGen/IfConversion.cpp +++ b/llvm/lib/CodeGen/IfConversion.cpp @@ -985,6 +985,20 @@ static void UpdatePredRedefs(MachineInstr *MI, LivePhysRegs &Redefs) { // take a mutable instruction instead of const. MachineInstr *OpMI = const_cast(Op.getParent()); MachineInstrBuilder MIB(*OpMI->getParent()->getParent(), OpMI); + + if (Op.isRegMask()) { + // First handle regmasks. They clobber any entries in the mask which + // means that we need a def for those registers. + MIB.addReg(Reg.first, RegState::Implicit | RegState::Undef); + + // We also need to add an implicit def of this register for the later + // use to read from. + // For the register allocator to have allocated a register clobbered + // by the call which is used later, it must be the case that + // the call doesn't return. + MIB.addReg(Reg.first, RegState::Implicit | RegState::Define); + continue; + } assert(Op.isReg() && "Register operand required"); MIB.addReg(Reg.first, RegState::Implicit | RegState::Undef); } -- cgit v1.2.3