[PATCH] D77130: [DAG] Change isGCValue detection for statepoint lowering

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 03:51:58 PDT 2020


skatkov created this revision.
skatkov added reviewers: reames, dantrushin.
Herald added a subscriber: hiraditya.
skatkov added a parent revision: D77122: [DOC] Remove too strong restriction for ‘llvm.experimental.gc.statepoint’ Intrinsic.

sGCValue should detect whether the deopt value is a GC pointer.
Currently it checks by finding the value in SI.Bases and SI.Ptrs.
However these dsata structures contains only those values which
has corresponding gc.relocate call. So we can miss GC value is it
does not have gc.relocate call (dead after the call).

This change conservatively consider any pointer as GC one.


https://reviews.llvm.org/D77130

Files:
  llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
  llvm/test/CodeGen/X86/statepoint-live-in.ll


Index: llvm/test/CodeGen/X86/statepoint-live-in.ll
===================================================================
--- llvm/test/CodeGen/X86/statepoint-live-in.ll
+++ llvm/test/CodeGen/X86/statepoint-live-in.ll
@@ -583,13 +583,14 @@
   ret i64 %addz
 }
 
-; Demonstrate address of a function (w/o spilling)
+; Demonstrate address of a function (w/ spilling)
 define void @addr_func() gc "statepoint-example" {
 ; CHECK-LABEL: addr_func:
 ; CHECK:       ## %bb.0: ## %entry
 ; CHECK-NEXT:    pushq %rax
 ; CHECK-NEXT:    .cfi_def_cfa_offset 16
 ; CHECK-NEXT:    movq _bar@{{.*}}(%rip), %rax
+; CHECK-NEXT:    movq %rax, (%rsp)
 ; CHECK-NEXT:    callq _bar
 ; CHECK-NEXT:  Ltmp14:
 ; CHECK-NEXT:    popq %rax
@@ -599,7 +600,7 @@
   ret void
 }
 
-; Demonstrate address of a global (w/o spilling)
+; Demonstrate address of a global (w/ spilling)
 @G = external global i32
 define void @addr_global() gc "statepoint-example" {
 ; CHECK-LABEL: addr_global:
@@ -607,6 +608,7 @@
 ; CHECK-NEXT:    pushq %rax
 ; CHECK-NEXT:    .cfi_def_cfa_offset 16
 ; CHECK-NEXT:    movq _G@{{.*}}(%rip), %rax
+; CHECK-NEXT:    movq %rax, (%rsp)
 ; CHECK-NEXT:    callq _bar
 ; CHECK-NEXT:  Ltmp15:
 ; CHECK-NEXT:    popq %rax
Index: llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -482,8 +482,9 @@
   const bool LiveInDeopt =
     SI.StatepointFlags & (uint64_t)StatepointFlags::DeoptLiveIn;
 
-  auto isGCValue =[&](const Value *V) {
-    return is_contained(SI.Ptrs, V) || is_contained(SI.Bases, V);
+  auto isGCValue = [&](const Value *V) {
+    // Conservatively suggest hat any pointer is GC one.
+    return V->getType()->isPtrOrPtrVectorTy();
   };
 
   // Before we actually start lowering (and allocating spill slots for values),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77130.253827.patch
Type: text/x-patch
Size: 1911 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200331/3bb42d85/attachment-0001.bin>


More information about the llvm-commits mailing list