[PATCH] D77036: [CodeGen] Fix isGCValue utility for statepoint lowering

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 29 23:25:36 PDT 2020


skatkov created this revision.
skatkov added reviewers: reames, dantrushin.
Herald added a subscriber: hiraditya.

isGCValue 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).

At the same time specification requires for all deopt values which
can be modified by GC to be listed in gc values.
So we can check whether deopt value is listed in gc values.


https://reviews.llvm.org/D77036

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
@@ -633,6 +633,22 @@
   ret void
 }
 
+; Demonstrate address of a function (w/ spilling due to it is gc value)
+define void @addr_func2() gc "statepoint-example" {
+; CHECK-LABEL: addr_func2:
+; 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:  Ltmp17:
+; CHECK-NEXT:    popq %rax
+; CHECK-NEXT:    retq
+entry:
+  %statepoint_token1 = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @bar, i32 0, i32 2, i64 0, i64 2, void ()* @bar, void ()* @bar, void ()* @bar)
+  ret void
+}
 
 ; CHECK: Ltmp0-_test1
 ; CHECK:      .byte	1
Index: llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -483,9 +483,7 @@
   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) { return is_contained(SI.GCArgs, V); };
 
   // Before we actually start lowering (and allocating spill slots for values),
   // reserve any stack slots which we judge to be profitable to reuse for a


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77036.253499.patch
Type: text/x-patch
Size: 1713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200330/2557302f/attachment-0001.bin>


More information about the llvm-commits mailing list