[llvm] r322584 - [CodeGen] Skip some instructions that shouldn't affect shrink-wrapping

Francis Visoiu Mistrih via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 10:55:27 PST 2018


Author: thegameg
Date: Tue Jan 16 10:55:26 2018
New Revision: 322584

URL: http://llvm.org/viewvc/llvm-project?rev=322584&view=rev
Log:
[CodeGen] Skip some instructions that shouldn't affect shrink-wrapping

r320606 checked for MI.isMetaInstruction which skips all DBG_VALUEs.

This also skips IMPLICIT_DEFs and other instructions that may def / read
a register.

Differential Revision: https://reviews.llvm.org/D42119

Modified:
    llvm/trunk/lib/CodeGen/ShrinkWrap.cpp

Modified: llvm/trunk/lib/CodeGen/ShrinkWrap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ShrinkWrap.cpp?rev=322584&r1=322583&r2=322584&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ShrinkWrap.cpp (original)
+++ llvm/trunk/lib/CodeGen/ShrinkWrap.cpp Tue Jan 16 10:55:26 2018
@@ -240,10 +240,6 @@ INITIALIZE_PASS_END(ShrinkWrap, DEBUG_TY
 
 bool ShrinkWrap::useOrDefCSROrFI(const MachineInstr &MI,
                                  RegScavenger *RS) const {
-  // Ignore DBG_VALUE and other meta instructions that must not affect codegen.
-  if (MI.isMetaInstruction())
-    return false;
-
   if (MI.getOpcode() == FrameSetupOpcode ||
       MI.getOpcode() == FrameDestroyOpcode) {
     DEBUG(dbgs() << "Frame instruction: " << MI << '\n');
@@ -252,6 +248,9 @@ bool ShrinkWrap::useOrDefCSROrFI(const M
   for (const MachineOperand &MO : MI.operands()) {
     bool UseOrDefCSR = false;
     if (MO.isReg()) {
+      // Ignore instructions like DBG_VALUE which don't read/def the register.
+      if (!MO.isDef() && !MO.readsReg())
+        continue;
       unsigned PhysReg = MO.getReg();
       if (!PhysReg)
         continue;
@@ -267,7 +266,8 @@ bool ShrinkWrap::useOrDefCSROrFI(const M
         }
       }
     }
-    if (UseOrDefCSR || MO.isFI()) {
+    // Skip FrameIndex operands in DBG_VALUE instructions.
+    if (UseOrDefCSR || (MO.isFI() && !MI.isDebugValue())) {
       DEBUG(dbgs() << "Use or define CSR(" << UseOrDefCSR << ") or FI("
                    << MO.isFI() << "): " << MI << '\n');
       return true;




More information about the llvm-commits mailing list