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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 11 10:59:21 PDT 2019


Author: arsenm
Date: Wed Sep 11 10:59:21 2019
New Revision: 371640

URL: http://llvm.org/viewvc/llvm-project?rev=371640&view=rev
Log:
LiveIntervals: Split live intervals on multiple dead defs

If there are multiple dead defs of the same virtual register, these
are required to be split into multiple virtual registers with separate
live intervals to avoid a verifier error.

Added:
    llvm/trunk/test/CodeGen/AMDGPU/live-intervals-multiple-dead-defs.mir
Modified:
    llvm/trunk/lib/CodeGen/LiveIntervals.cpp

Modified: llvm/trunk/lib/CodeGen/LiveIntervals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervals.cpp?rev=371640&r1=371639&r2=371640&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervals.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervals.cpp Wed Sep 11 10:59:21 2019
@@ -196,7 +196,11 @@ void LiveIntervals::computeVirtRegInterv
   assert(LI.empty() && "Should only compute empty intervals.");
   LRCalc->reset(MF, getSlotIndexes(), DomTree, &getVNInfoAllocator());
   LRCalc->calculate(LI, MRI->shouldTrackSubRegLiveness(LI.reg));
-  computeDeadValues(LI, nullptr);
+
+  if (computeDeadValues(LI, nullptr)) {
+    SmallVector<LiveInterval *, 4> SplitIntervals;
+    splitSeparateComponents(LI, SplitIntervals);
+  }
 }
 
 void LiveIntervals::computeVirtRegs() {
@@ -500,6 +504,8 @@ bool LiveIntervals::shrinkToUses(LiveInt
 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 +536,10 @@ bool LiveIntervals::computeDeadValues(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);

Added: llvm/trunk/test/CodeGen/AMDGPU/live-intervals-multiple-dead-defs.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/live-intervals-multiple-dead-defs.mir?rev=371640&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/live-intervals-multiple-dead-defs.mir (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/live-intervals-multiple-dead-defs.mir Wed Sep 11 10:59:21 2019
@@ -0,0 +1,18 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx906 -verify-machineinstrs -run-pass=machine-scheduler -verify-misched -o - %s | FileCheck %s
+
+# There are multiple dead defs of the same virtual register. Make sure
+# the intervals are split during the initial live range computation.
+
+---
+name:            multiple_connected_components_dead
+tracksRegLiveness: true
+body:             |
+  bb.0:
+    ; CHECK-LABEL: name: multiple_connected_components_dead
+    ; CHECK: dead %1:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
+    ; CHECK: dead %0:vgpr_32 = V_MOV_B32_e32 1, implicit $exec
+    dead %0:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
+    dead %0:vgpr_32 = V_MOV_B32_e32 1, implicit $exec
+
+...




More information about the llvm-commits mailing list