[llvm] 43144ff - LiveIntervals: Split live intervals on multiple dead defs

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 30 06:51:06 PDT 2019


Author: Krzysztof Parzyszek
Date: 2019-10-30T08:50:46-05:00
New Revision: 43144ffa91a2c250cab453b6abd2d1913db3e4d4

URL: https://github.com/llvm/llvm-project/commit/43144ffa91a2c250cab453b6abd2d1913db3e4d4
DIFF: https://github.com/llvm/llvm-project/commit/43144ffa91a2c250cab453b6abd2d1913db3e4d4.diff

LOG: LiveIntervals: Split live intervals on multiple dead defs

This is a follow-up to D67448.

Split live intervals with multiple dead defs during the initial
execution of the live interval analysis, but do it outside of the
function createAndComputeVirtRegInterval.

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

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/LiveIntervals.h
    llvm/lib/CodeGen/LiveIntervals.cpp
    llvm/test/DebugInfo/WebAssembly/dbg-value-move-reg-stackify.mir
    llvm/test/DebugInfo/X86/live-debug-vars-discard-invalid.mir

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/LiveIntervals.h b/llvm/include/llvm/CodeGen/LiveIntervals.h
index 888d72b87bd1..2bfc99624937 100644
--- a/llvm/include/llvm/CodeGen/LiveIntervals.h
+++ b/llvm/include/llvm/CodeGen/LiveIntervals.h
@@ -469,7 +469,7 @@ class VirtRegMap;
 
     void computeLiveInRegUnits();
     void computeRegUnitRange(LiveRange&, unsigned Unit);
-    void computeVirtRegInterval(LiveInterval&);
+    bool computeVirtRegInterval(LiveInterval&);
 
     using ShrinkToUsesWorkList = SmallVector<std::pair<SlotIndex, VNInfo*>, 16>;
     void extendSegmentsToUses(LiveRange &Segments,

diff  --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp
index 2989930ad093..600e7880c702 100644
--- a/llvm/lib/CodeGen/LiveIntervals.cpp
+++ b/llvm/lib/CodeGen/LiveIntervals.cpp
@@ -191,12 +191,12 @@ LiveInterval* LiveIntervals::createInterval(unsigned reg) {
 }
 
 /// Compute the live interval of a virtual register, based on defs and uses.
-void LiveIntervals::computeVirtRegInterval(LiveInterval &LI) {
+bool LiveIntervals::computeVirtRegInterval(LiveInterval &LI) {
   assert(LRCalc && "LRCalc not initialized.");
   assert(LI.empty() && "Should only compute empty intervals.");
   LRCalc->reset(MF, getSlotIndexes(), DomTree, &getVNInfoAllocator());
   LRCalc->calculate(LI, MRI->shouldTrackSubRegLiveness(LI.reg));
-  computeDeadValues(LI, nullptr);
+  return computeDeadValues(LI, nullptr);
 }
 
 void LiveIntervals::computeVirtRegs() {
@@ -204,7 +204,12 @@ void LiveIntervals::computeVirtRegs() {
     unsigned Reg = Register::index2VirtReg(i);
     if (MRI->reg_nodbg_empty(Reg))
       continue;
-    createAndComputeVirtRegInterval(Reg);
+    LiveInterval &LI = createEmptyInterval(Reg);
+    bool NeedSplit = computeVirtRegInterval(LI);
+    if (NeedSplit) {
+      SmallVector<LiveInterval*, 8> SplitLIs;
+      splitSeparateComponents(LI, SplitLIs);
+    }
   }
 }
 
@@ -500,6 +505,8 @@ bool LiveIntervals::shrinkToUses(LiveInterval *li,
 bool LiveIntervals::computeDeadValues(LiveInterval &LI,
                                       SmallVectorImpl<MachineInstr*> *dead) {
   bool MayHaveSplitComponents = false;
+  bool HaveDeadDef = false;
+
   for (VNInfo *VNI : LI.valnos) {
     if (VNI->isUnused())
       continue;
@@ -530,6 +537,10 @@ bool LiveIntervals::computeDeadValues(LiveInterval &LI,
       MachineInstr *MI = getInstructionFromIndex(Def);
       assert(MI && "No instruction defining live value");
       MI->addRegisterDead(LI.reg, TRI);
+      if (HaveDeadDef)
+        MayHaveSplitComponents = true;
+      HaveDeadDef = true;
+
       if (dead && MI->allDefsAreDead()) {
         LLVM_DEBUG(dbgs() << "All defs dead: " << Def << '\t' << *MI);
         dead->push_back(MI);

diff  --git a/llvm/test/DebugInfo/WebAssembly/dbg-value-move-reg-stackify.mir b/llvm/test/DebugInfo/WebAssembly/dbg-value-move-reg-stackify.mir
index af36dc12d2e2..bba9140bd968 100644
--- a/llvm/test/DebugInfo/WebAssembly/dbg-value-move-reg-stackify.mir
+++ b/llvm/test/DebugInfo/WebAssembly/dbg-value-move-reg-stackify.mir
@@ -1,10 +1,10 @@
 # RUN: llc < %s -run-pass=wasm-reg-stackify -x=mir 2>&1 | FileCheck %s
 
 # CHECK: body:
-# CHECK: %1:i32 = I32_WRAP_I64 %0,
-# CHECK-NEXT: DBG_VALUE %1,
-# CHECK-NEXT: %1:i32 = CALL_i32 @bar,
-# CHECK-NEXT: DBG_VALUE %1,
+# CHECK: dead %3:i32 = I32_WRAP_I64 %0,
+# CHECK-NEXT: DBG_VALUE %1:i32
+# CHECK-NEXT: dead %2:i32 = CALL_i32 @bar,
+# CHECK-NEXT: DBG_VALUE %1:i32,
 # CHECK-NEXT: %[[NEWREG:.*]]:i32 = CALL_i32 @bar,
 # CHECK-NEXT: DBG_VALUE %[[NEWREG]],
 # CHECK-NEXT: CALL_VOID @foo, %[[NEWREG]],

diff  --git a/llvm/test/DebugInfo/X86/live-debug-vars-discard-invalid.mir b/llvm/test/DebugInfo/X86/live-debug-vars-discard-invalid.mir
index 4588192a437c..ea56872b3cb0 100644
--- a/llvm/test/DebugInfo/X86/live-debug-vars-discard-invalid.mir
+++ b/llvm/test/DebugInfo/X86/live-debug-vars-discard-invalid.mir
@@ -1,5 +1,4 @@
-# FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR39481.
-# RUN: llc -mtriple=x86_64-linux-gnu -start-before greedy -stop-after virtregrewriter -o - -verify-machineinstrs=0 %s | FileCheck %s
+# RUN: llc -mtriple=x86_64-linux-gnu -start-before greedy -stop-after virtregrewriter -o - -verify-machineinstrs %s | FileCheck %s
 
 --- |
   ; ModuleID = '<stdin>'
@@ -115,7 +114,7 @@ body:             |
 # CHECK-NEXT:   dead renamable $rcx = IMPLICIT_DEF
 # CHECK-NEXT:   dead renamable $rcx = IMPLICIT_DEF
 # CHECK-NEXT:   dead renamable $rcx = IMPLICIT_DEF
-# CHECK-NEXT:   DBG_VALUE $rcx, $noreg, !18, !DIExpression()
+# CHECK-NEXT:   DBG_VALUE $noreg, $noreg, !18, !DIExpression()
 
 # CHECK-LABEL: bb.3:
 # CHECK:        dead renamable $rcx = IMPLICIT_DEF


        


More information about the llvm-commits mailing list