[PATCH] D88535: CodeGen: Fix livein calculation in MachineBasicBlock splitAt

Carl Ritson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 00:44:54 PDT 2020


critson created this revision.
critson added reviewers: qcolombet, arsenm, nhaehnle.
Herald added subscribers: llvm-commits, kerbowa, hiraditya, jvesely.
Herald added a project: LLVM.
critson requested review of this revision.
Herald added a subscriber: wdng.

Fix and simplify computation of liveins for new block.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88535

Files:
  llvm/lib/CodeGen/MachineBasicBlock.cpp
  llvm/test/CodeGen/AMDGPU/si-lower-control-flow.mir


Index: llvm/test/CodeGen/AMDGPU/si-lower-control-flow.mir
===================================================================
--- llvm/test/CodeGen/AMDGPU/si-lower-control-flow.mir
+++ llvm/test/CodeGen/AMDGPU/si-lower-control-flow.mir
@@ -233,7 +233,6 @@
   ; GCN:   $exec = S_OR_B64_term $exec, [[COPY3]], implicit-def $scc
   ; GCN: bb.3:
   ; GCN:   successors: %bb.2(0x80000000)
-  ; GCN:   liveins: $vgpr3
   ; GCN:   $vgpr3 = V_MOV_B32_e32 0, implicit $exec
   ; GCN:   $sgpr4_sgpr5 = S_MOV_B64 32
   ; GCN: bb.2:
Index: llvm/lib/CodeGen/MachineBasicBlock.cpp
===================================================================
--- llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -956,17 +956,6 @@
   }
 
   MachineFunction *MF = getParent();
-
-  LivePhysRegs LiveRegs;
-  if (UpdateLiveIns) {
-    // Make sure we add any physregs we define in the block as liveins to the
-    // new block.
-    LiveRegs.init(*MF->getSubtarget().getRegisterInfo());
-    LiveRegs.addLiveOuts(*this);
-    for (auto I = rbegin(), E = SplitPoint.getReverse(); I != E; ++I)
-      LiveRegs.stepBackward(*I);
-  }
-
   MachineBasicBlock *SplitBB = MF->CreateMachineBasicBlock(getBasicBlock());
 
   MF->insert(++MachineFunction::iterator(this), SplitBB);
@@ -975,8 +964,10 @@
   SplitBB->transferSuccessorsAndUpdatePHIs(this);
   addSuccessor(SplitBB);
 
-  if (UpdateLiveIns)
-    addLiveIns(*SplitBB, LiveRegs);
+  if (UpdateLiveIns) {
+    LivePhysRegs LiveRegs;
+    computeAndAddLiveIns(LiveRegs, *SplitBB);
+  }
 
   if (LIS)
     LIS->insertMBBInMaps(SplitBB, &MI);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88535.295190.patch
Type: text/x-patch
Size: 1599 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200930/1e516602/attachment.bin>


More information about the llvm-commits mailing list