Make the peephole optimizer clear kill flags on a vreg if it's about to add new
authorLang Hames <lhames@gmail.com>
Sat, 25 Feb 2012 02:01:00 +0000 (02:01 +0000)
committerLang Hames <lhames@gmail.com>
Sat, 25 Feb 2012 02:01:00 +0000 (02:01 +0000)
uses of the vreg, since the old kills may no longer be valid.  This was causing
-verify-machineinstrs to complain about uses after kills, and could potentially
have been causing subtle register allocation issues, but I haven't come across a
test case yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151425 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/PeepholeOptimizer.cpp

index 203f2bffb7bcbb7bcae15629d37c509741383b7d..9c5c029000c06136b910c8dc27b774db3fe1d952 100644 (file)
@@ -237,6 +237,10 @@ OptimizeExtInstr(MachineInstr *MI, MachineBasicBlock *MBB,
       if (PHIBBs.count(UseMBB))
         continue;
 
+      // About to add uses of DstReg, clear DstReg's kill flags.
+      if (!Changed)
+        MRI->clearKillFlags(DstReg);
+
       unsigned NewVR = MRI->createVirtualRegister(RC);
       BuildMI(*UseMBB, UseMI, UseMI->getDebugLoc(),
               TII->get(TargetOpcode::COPY), NewVR)