[PATCH] D61671: X86WinAllocaExpander: Drop code looking through register copies (PR41786)

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 03:06:32 PDT 2019


hans created this revision.
hans added reviewers: RKSimon, rnk.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

This code was never covered by tests, in PR41786 it was pointed out that the deletion part doesn't work, and in a full Chrome build I was never able to hit the code path that looks through copies. It seems the situation it's supposed to handle doesn't actually come up in practice.

Delete it to simplify the code.


https://reviews.llvm.org/D61671

Files:
  llvm/lib/Target/X86/X86WinAllocaExpander.cpp


Index: llvm/lib/Target/X86/X86WinAllocaExpander.cpp
===================================================================
--- llvm/lib/Target/X86/X86WinAllocaExpander.cpp
+++ llvm/lib/Target/X86/X86WinAllocaExpander.cpp
@@ -84,10 +84,6 @@
   unsigned AmountReg = MI->getOperand(0).getReg();
   MachineInstr *Def = MRI->getUniqueVRegDef(AmountReg);
 
-  // Look through copies.
-  while (Def && Def->isCopy() && Def->getOperand(1).isReg())
-    Def = MRI->getUniqueVRegDef(Def->getOperand(1).getReg());
-
   if (!Def ||
       (Def->getOpcode() != X86::MOV32ri && Def->getOpcode() != X86::MOV64ri) ||
       !Def->getOperand(1).isImm())
@@ -268,17 +264,10 @@
   unsigned AmountReg = MI->getOperand(0).getReg();
   MI->eraseFromParent();
 
-  // Delete the definition of AmountReg, possibly walking a chain of copies.
-  for (;;) {
-    if (!MRI->use_empty(AmountReg))
-      break;
+  // Delete the definition of AmountReg.
+  if (MRI->use_empty(AmountReg)) {
     MachineInstr *AmountDef = MRI->getUniqueVRegDef(AmountReg);
-    if (!AmountDef)
-      break;
-    if (AmountDef->isCopy() && AmountDef->getOperand(1).isReg())
-      AmountReg = AmountDef->getOperand(1).isReg();
     AmountDef->eraseFromParent();
-    break;
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61671.198613.patch
Type: text/x-patch
Size: 1233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190508/989b03d7/attachment.bin>


More information about the llvm-commits mailing list