[LLVMdev] Possible Remat Bug

David Greene dag at cray.com
Wed Nov 16 09:15:46 PST 2011


I'm working on some enhancements to rematerialization that I hope to
contribute.  It's mostly working but I am running into one problem.  It
boils down to having spilled a register used by the remat candidate.

I thought this is what getReMatImplicitUse is supposed to handle but
it looks inconsistent to me.  The comment says this:

/// getReMatImplicitUse - If the remat definition MI has one (for now, we only
/// allow one) virtual register operand, then its uses are implicitly using
/// the register. Returns the virtual register.
unsigned LiveIntervals::getReMatImplicitUse(const LiveInterval &li,
                                            MachineInstr *MI) const {

But down in the code we have this:

    if (TargetRegisterInfo::isPhysicalRegister(Reg) &&
        !allocatableRegs_[Reg])
      continue;
    // FIXME: For now, only remat MI with at most one register operand.
    assert(!RegOp &&
           "Can't rematerialize instruction with multiple register operand!");
    RegOp = MO.getReg();
#ifndef NDEBUG
    break;
#endif

So if Reg is an allocatable physical register, it gets returned as an
implicit use.  This directly contradicts the comment when talks about
virtual registers exclusively.

So who's right here?

                            -Dave



More information about the llvm-dev mailing list