[llvm] 3d4730a - Revert "[AMDGPU] SIFoldOperands: eagerly erase dead REG_SEQUENCEs"

Mitch Phillips via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 9 15:48:03 PDT 2021


Author: Mitch Phillips
Date: 2021-04-09T15:47:44-07:00
New Revision: 3d4730a73fd1db6e28edeb9dac16e8e081529e3a

URL: https://github.com/llvm/llvm-project/commit/3d4730a73fd1db6e28edeb9dac16e8e081529e3a
DIFF: https://github.com/llvm/llvm-project/commit/3d4730a73fd1db6e28edeb9dac16e8e081529e3a.diff

LOG: Revert "[AMDGPU] SIFoldOperands: eagerly erase dead REG_SEQUENCEs"

This reverts commit d19a42eba98fe853dd52f7dc89d8cd2727c7fc1c.

Reason: Broke the ASan buildbots. See the original phabricator review
for more details: https://reviews.llvm.org/D100188

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/SIFoldOperands.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index 138666182613c..35594ecbde160 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -1596,10 +1596,6 @@ bool SIFoldOperands::tryFoldRegSequence(MachineInstr &MI) {
 
   LLVM_DEBUG(dbgs() << "Folded " << *RS << " into " << *UseMI);
 
-  // Erase the REG_SEQUENCE eagerly, unless we followed a chain of COPY users,
-  // in which case we can erase them all later in runOnMachineFunction.
-  if (MRI->use_nodbg_empty(MI.getOperand(0).getReg()))
-    MI.eraseFromParentAndMarkDBGValuesForRemoval();
   return true;
 }
 
@@ -1790,23 +1786,8 @@ bool SIFoldOperands::runOnMachineFunction(MachineFunction &MF) {
 
       // If we managed to fold all uses of this copy then we might as well
       // delete it now.
-      // The only reason we need to follow chains of copies here is that
-      // tryFoldRegSequence looks forward through copies before folding a
-      // REG_SEQUENCE into its eventual users.
-      auto *InstToErase = &MI;
-      while (MRI->use_nodbg_empty(InstToErase->getOperand(0).getReg())) {
-        auto &SrcOp = InstToErase->getOperand(1);
-        auto SrcReg = SrcOp.isReg() ? SrcOp.getReg() : Register();
-        InstToErase->eraseFromParentAndMarkDBGValuesForRemoval();
-        if (!SrcReg || SrcReg.isPhysical())
-          break;
-        InstToErase = MRI->getVRegDef(SrcReg);
-        if (!InstToErase || !TII->isFoldableCopy(*InstToErase))
-          break;
-      }
-      if (InstToErase && InstToErase->isRegSequence() &&
-          MRI->use_nodbg_empty(InstToErase->getOperand(0).getReg()))
-        InstToErase->eraseFromParentAndMarkDBGValuesForRemoval();
+      if (MRI->use_nodbg_empty(MI.getOperand(0).getReg()))
+        MI.eraseFromParentAndMarkDBGValuesForRemoval();
     }
   }
   return true;


        


More information about the llvm-commits mailing list