[llvm-commits] [llvm] r53058 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/CodeGen/TwoAddressInstructionPass.cpp lib/Target/ARM/ARMInstrInfo.cpp lib/Target/ARM/ARMInstrInfo.h lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrInfo.h

Evan Cheng evan.cheng at apple.com
Wed Jul 2 16:45:06 PDT 2008


On Jul 2, 2008, at 4:41 PM, Owen Anderson wrote:

> Author: resistor
> Date: Wed Jul  2 18:41:07 2008
> New Revision: 53058
>
> URL: http://llvm.org/viewvc/llvm-project?rev=53058&view=rev
> Log:
> Make LiveVariables even more optional, by making it optional in the  
> call to TargetInstrInfo::convertToThreeAddressInstruction
> Also, if LV isn't around, then TwoAddr doesn't need to be updating  
> flags, since they won't have been set in the first place.

Thanks. I was just about to ping you about this. You can't assume  
there aren't kill / dead markers on machineinstrs even if LV is not  
available. But commuteInstruction is supposed to copy the markers over.

Evan
>
>
> Modified:
>    llvm/trunk/include/llvm/Target/TargetInstrInfo.h
>    llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp
>    llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp
>    llvm/trunk/lib/Target/ARM/ARMInstrInfo.h
>    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
>    llvm/trunk/lib/Target/X86/X86InstrInfo.h
>
> Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=53058&r1=53057&r2=53058&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Wed Jul  2  
> 18:41:07 2008
> @@ -143,7 +143,7 @@
>   ///
>   virtual MachineInstr *
>   convertToThreeAddress(MachineFunction::iterator &MFI,
> -                   MachineBasicBlock::iterator &MBBI, LiveVariables  
> &LV) const {
> +                   MachineBasicBlock::iterator &MBBI, LiveVariables  
> *LV) const {
>     return 0;
>   }
>
>
> Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp?rev=53058&r1=53057&r2=53058&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original)
> +++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Wed Jul  2  
> 18:41:07 2008
> @@ -378,27 +378,6 @@
>                     if (LV) {
>                       // Update live variables
>                       LV->instructionChanged(mi, NewMI);
> -                    } else {
> -                      // Update flags manually
> -                      for (unsigned i = 0, e = mi->getNumOperands();
> -                           i != e; ++i) {
> -                        MachineOperand &MO = mi->getOperand(i);
> -                        if (MO.isRegister() && MO.getReg() &&
> -                           
> TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
> -                          unsigned Reg = MO.getReg();
> -                          if (MO.isDef()) {
> -                            if (MO.isDead()) {
> -                              MO.setIsDead(false);
> -                              NewMI->addRegisterDead(Reg, TRI);
> -                            }
> -                          }
> -
> -                          if (MO.isKill()) {
> -                            MO.setIsKill(false);
> -                            NewMI->addRegisterKilled(Reg, TRI);
> -                          }
> -                        }
> -                      }
>                     }
>
>                     mbbi->insert(mi, NewMI);           // Insert the  
> new inst
> @@ -424,7 +403,7 @@
>                 assert(TID.getOperandConstraint(i, TOI::TIED_TO) ==  
> -1);
> #endif
>
> -              MachineInstr *NewMI = TII- 
> >convertToThreeAddress(mbbi, mi, *LV);
> +              MachineInstr *NewMI = TII- 
> >convertToThreeAddress(mbbi, mi, LV);
>               if (NewMI) {
>                 DOUT << "2addr: CONVERTING 2-ADDR: " << *mi;
>                 DOUT << "2addr:         TO 3-ADDR: " << *NewMI;
> @@ -481,30 +460,6 @@
>
>             if (LV->removeVirtualRegisterDead(regB, mbbi, mi))
>               LV->addVirtualRegisterDead(regB, prevMi);
> -          } else {
> -            // Manually update kill/dead flags.
> -            bool RemovedKill = false;
> -            bool RemovedDead = false;
> -            for (unsigned i = 0, e = mi->getNumOperands(); i != e; + 
> +i) {
> -              MachineOperand &MO = mi->getOperand(i);
> -              if (MO.isRegister() && MO.isKill() && MO.getReg() ==  
> regB) {
> -                MO.setIsKill(false);
> -                RemovedKill = true;
> -                break;
> -              }
> -
> -              if (MO.isRegister() && MO.isDef() && MO.getReg() ==  
> regB) {
> -                MO.setIsDead(false);
> -                RemovedDead = true;
> -              }
> -
> -              if (RemovedKill && RemovedDead) break;
> -            }
> -
> -            if (RemovedKill)
> -              prevMi->addRegisterKilled(regB, TRI);
> -            if (RemovedDead)
> -              prevMi->addRegisterDead(regB, TRI);
>           }
>
>           // Replace all occurences of regB with regA.
>
> Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=53058&r1=53057&r2=53058&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Wed Jul  2 18:41:07  
> 2008
> @@ -191,7 +191,7 @@
> MachineInstr *
> ARMInstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI,
>                                     MachineBasicBlock::iterator &MBBI,
> -                                    LiveVariables &LV) const {
> +                                    LiveVariables *LV) const {
>   if (!EnableARM3Addr)
>     return NULL;
>
> @@ -300,22 +300,25 @@
>     if (MO.isRegister() && MO.getReg() &&
>         TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
>       unsigned Reg = MO.getReg();
> -      LiveVariables::VarInfo &VI = LV.getVarInfo(Reg);
> -      if (MO.isDef()) {
> -        MachineInstr *NewMI = (Reg == WBReg) ? UpdateMI : MemMI;
> -        if (MO.isDead())
> -          LV.addVirtualRegisterDead(Reg, NewMI);
> -      }
> -      if (MO.isUse() && MO.isKill()) {
> -        for (unsigned j = 0; j < 2; ++j) {
> -          // Look at the two new MI's in reverse order.
> -          MachineInstr *NewMI = NewMIs[j];
> -          if (!NewMI->readsRegister(Reg))
> -            continue;
> -          LV.addVirtualRegisterKilled(Reg, NewMI);
> -          if (VI.removeKill(MI))
> -            VI.Kills.push_back(NewMI);
> -          break;
> +
> +      if (LV) {
> +        LiveVariables::VarInfo &VI = LV->getVarInfo(Reg);
> +        if (MO.isDef()) {
> +          MachineInstr *NewMI = (Reg == WBReg) ? UpdateMI : MemMI;
> +          if (MO.isDead())
> +            LV->addVirtualRegisterDead(Reg, NewMI);
> +        }
> +        if (MO.isUse() && MO.isKill()) {
> +          for (unsigned j = 0; j < 2; ++j) {
> +            // Look at the two new MI's in reverse order.
> +            MachineInstr *NewMI = NewMIs[j];
> +            if (!NewMI->readsRegister(Reg))
> +              continue;
> +            LV->addVirtualRegisterKilled(Reg, NewMI);
> +            if (VI.removeKill(MI))
> +              VI.Kills.push_back(NewMI);
> +            break;
> +          }
>         }
>       }
>     }
>
> Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.h?rev=53058&r1=53057&r2=53058&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.h (original)
> +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.h Wed Jul  2 18:41:07 2008
> @@ -153,7 +153,7 @@
>
>   virtual MachineInstr  
> *convertToThreeAddress(MachineFunction::iterator &MFI,
>                                                
> MachineBasicBlock::iterator &MBBI,
> -                                              LiveVariables &LV)  
> const;
> +                                              LiveVariables *LV)  
> const;
>
>   // Branch analysis.
>   virtual bool AnalyzeBranch(MachineBasicBlock &MBB,  
> MachineBasicBlock *&TBB,
>
> Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=53058&r1=53057&r2=53058&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Wed Jul  2 18:41:07  
> 2008
> @@ -978,7 +978,7 @@
> MachineInstr *
> X86InstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI,
>                                     MachineBasicBlock::iterator &MBBI,
> -                                    LiveVariables &LV) const {
> +                                    LiveVariables *LV) const {
>   MachineInstr *MI = MBBI;
>   // All instructions input are two-addr instructions.  Get the  
> known operands.
>   unsigned Dest = MI->getOperand(0).getReg();
> @@ -1066,10 +1066,12 @@
>
>       MFI->insert(MBBI, Undef);
>       MFI->insert(MBBI, Ins);            // Insert the insert_subreg
> -      LV.instructionChanged(MI, NewMI);  // Update live variables
> -      LV.addVirtualRegisterKilled(leaInReg, NewMI);
> +      if (LV) {
> +        LV->instructionChanged(MI, NewMI);  // Update live variables
> +        LV->addVirtualRegisterKilled(leaInReg, NewMI);
> +      }
>       MFI->insert(MBBI, NewMI);          // Insert the new inst
> -      LV.addVirtualRegisterKilled(leaOutReg, Ext);
> +      if (LV) LV->addVirtualRegisterKilled(leaOutReg, Ext);
>       MFI->insert(MBBI, Ext);            // Insert the extract_subreg
>       return Ext;
>     } else {
> @@ -1180,7 +1182,7 @@
>   if (!NewMI) return 0;
>
>   NewMI->copyKillDeadInfo(MI);
> -  LV.instructionChanged(MI, NewMI);  // Update live variables
> +  if (LV) LV->instructionChanged(MI, NewMI);  // Update live  
> variables
>   MFI->insert(MBBI, NewMI);          // Insert the new inst
>   return NewMI;
> }
>
> Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=53058&r1=53057&r2=53058&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original)
> +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Wed Jul  2 18:41:07 2008
> @@ -295,7 +295,7 @@
>   ///
>   virtual MachineInstr  
> *convertToThreeAddress(MachineFunction::iterator &MFI,
>                                                
> MachineBasicBlock::iterator &MBBI,
> -                                              LiveVariables &LV)  
> const;
> +                                              LiveVariables *LV)  
> const;
>
>   /// commuteInstruction - We have a few instructions that must be  
> hacked on to
>   /// commute them.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list