[PATCH] D31127: [CodeGen] Make MI.isLabel() return true for LOCAL_ESCAPE.

Ahmed Bougacha via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 19 09:27:32 PDT 2017


ab created this revision.
Herald added subscribers: rengolin, aemerson.

Found by manual inspection: LOCAL_ESCAPE seems to have the same
properties as EH/GC labels: we can't remove it, and moving it is
constrained.  Make isLabel acknowledge that.

The only use of isLabel is isPosition.

isPosition causes isSafeToMove to return false, which IIUC is
conservative intra-block but seems correct across blocks.

That in turn prevents DeadMachineInstructionElim from removing the
instruction, without the need for a special case.

The other changed uses of isPosition all seem harmless at worst:

- AsmPrinter.cpp: doesn't count the label
- MachineBasicBlock.cpp: changes the PHI elimination insert pt
- MachineCSE.cpp: skips the label
- PeepholeOptimizer.cpp: skips the label
- TargetInstrInfo.cpp: scheduling boundary
- X86InstrInfo.cpp: blocks outlining


Repository:
  rL LLVM

https://reviews.llvm.org/D31127

Files:
  include/llvm/CodeGen/MachineInstr.h
  lib/CodeGen/DeadMachineInstructionElim.cpp


Index: lib/CodeGen/DeadMachineInstructionElim.cpp
===================================================================
--- lib/CodeGen/DeadMachineInstructionElim.cpp
+++ lib/CodeGen/DeadMachineInstructionElim.cpp
@@ -64,10 +64,6 @@
   if (MI->isInlineAsm())
     return false;
 
-  // Don't delete frame allocation labels.
-  if (MI->getOpcode() == TargetOpcode::LOCAL_ESCAPE)
-    return false;
-
   // Don't delete instructions with side effects.
   bool SawStore = false;
   if (!MI->isSafeToMove(nullptr, SawStore) && !MI->isPHI())
Index: include/llvm/CodeGen/MachineInstr.h
===================================================================
--- include/llvm/CodeGen/MachineInstr.h
+++ include/llvm/CodeGen/MachineInstr.h
@@ -764,9 +764,14 @@
 
   bool isEHLabel() const { return getOpcode() == TargetOpcode::EH_LABEL; }
   bool isGCLabel() const { return getOpcode() == TargetOpcode::GC_LABEL; }
+  bool isLocalEscape() const {
+    return getOpcode() == TargetOpcode::LOCAL_ESCAPE;
+  }
 
   /// Returns true if the MachineInstr represents a label.
-  bool isLabel() const { return isEHLabel() || isGCLabel(); }
+  bool isLabel() const {
+    return isEHLabel() || isGCLabel() || isLocalEscape();
+  }
   bool isCFIInstruction() const {
     return getOpcode() == TargetOpcode::CFI_INSTRUCTION;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31127.92282.patch
Type: text/x-patch
Size: 1306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170319/89a9926f/attachment.bin>


More information about the llvm-commits mailing list