[PATCH] D35985: Skip live range segment verification for reserved physregs

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 3 02:57:44 PST 2017


bjope added a comment.

In https://reviews.llvm.org/D35985#832657, @MatzeB wrote:

> I would expect the live ranges of register units that are reserved to be empty and therefore naturally pass verification. Do you know why you end up having non-empty information in those live ranges? We should identify the cause for that and fix it.


Not at all sure if this is involved in the problems seen here, but isn't this a fault (in case there should be no dead reserved registers). The code is from LivePhysRegs.cpp (and it is used by the IfConverter):

  void llvm::recomputeLivenessFlags(MachineBasicBlock &MBB) {
    const MachineFunction &MF = *MBB.getParent();
    const MachineRegisterInfo &MRI = MF.getRegInfo();
    const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo();
  
    // We walk through the block backwards and start with the live outs.
    LivePhysRegs LiveRegs;
    LiveRegs.init(TRI);
    LiveRegs.addLiveOutsNoPristines(MBB);
  
    for (MachineInstr &MI : make_range(MBB.rbegin(), MBB.rend())) {
      // Recompute dead flags.
      for (MIBundleOperands MO(MI); MO.isValid(); ++MO) {
        if (!MO->isReg() || !MO->isDef() || MO->isDebug())
          continue;
  
        unsigned Reg = MO->getReg();
        if (Reg == 0)
          continue;
        assert(TargetRegisterInfo::isPhysicalRegister(Reg));
  
        bool IsNotLive = LiveRegs.available(MRI, Reg);
        MO->setIsDead(IsNotLive);
      }
  
     ...

The code above will set "dead" on reserved register defs since LivePhysRegs::available returns false for reserved regs, according to:

  bool LivePhysRegs::available(const MachineRegisterInfo &MRI,
                               unsigned Reg) const {
    if (LiveRegs.count(Reg))
      return false;
    if (MRI.isReserved(Reg))
      return false;
    for (MCRegAliasIterator R(Reg, TRI, false); R.isValid(); ++R) {
      if (LiveRegs.count(*R))
        return false;
    }
    return true;
  }

PS. llvm::recomputeLivenessFlags is also setting "kill" on reserved register uses. I assume that is incorrect as well.


https://reviews.llvm.org/D35985





More information about the llvm-commits mailing list