[PATCH] D100747: [Greedy RA] Last Split point for invoke statepoint should be statepoint itself

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 19 02:49:52 PDT 2021


skatkov created this revision.
skatkov added reviewers: reames, rnk, void.
Herald added subscribers: pengfei, hiraditya.
skatkov requested review of this revision.
Herald added a project: LLVM.

If statepoint has a def it is a relocated gc pointer and it should be available in landing pad.
So we cannot split interval after statepoint at end of basic block.

The option -use-registers-for-gc-values-in-landing-pad which introduces invoke statepoint
with tied-def operands is off by default and we should switch it on to reproduce a verifier error.

After this fix "Register not marked live out of predecessor" verifier assert is fixed but Greedy RA
breaks tied-def property of statepoint instruction. This will be fixed by follow-up patches.


https://reviews.llvm.org/D100747

Files:
  llvm/lib/CodeGen/SplitKit.cpp
  llvm/test/CodeGen/X86/statepoint-invoke-ra1.ll


Index: llvm/test/CodeGen/X86/statepoint-invoke-ra1.ll
===================================================================
--- llvm/test/CodeGen/X86/statepoint-invoke-ra1.ll
+++ llvm/test/CodeGen/X86/statepoint-invoke-ra1.ll
@@ -4,7 +4,7 @@
 ; The test checks the verification catch the case when RA splits live interval in the
 ; way the def is located after invoke statepoint while use is in landing pad.
 
-; CHECK: *** Bad machine code: Register not marked live out of predecessor ***
+; CHECK: *** Bad machine code: Two-address instruction operands must be identical ***
 
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/lib/CodeGen/SplitKit.cpp
===================================================================
--- llvm/lib/CodeGen/SplitKit.cpp
+++ llvm/lib/CodeGen/SplitKit.cpp
@@ -118,6 +118,13 @@
   if (!VNI)
     return LIP.first;
 
+  // The def of statepoint instruction is a gc relocation and it should be alive
+  // in landing pad. So we cannot split interval after statepoint instruction.
+  if (SlotIndex::isSameInstr(VNI->def, LIP.second))
+    if (auto *I = LIS.getInstructionFromIndex(LIP.second))
+      if (I->getOpcode() == TargetOpcode::STATEPOINT)
+        return LIP.second;
+
   // If the value leaving MBB was defined after the call in MBB, it can't
   // really be live-in to the landing pad.  This can happen if the landing pad
   // has a PHI, and this register is undef on the exceptional edge.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100747.338457.patch
Type: text/x-patch
Size: 1554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210419/71b24c43/attachment.bin>


More information about the llvm-commits mailing list