[PATCH] D16439: [PlaceSafepoints] Introduce a -spp-no-statepoints flag

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 21 18:50:33 PST 2016


sanjoy created this revision.
sanjoy added reviewers: pgavlin, reames, JosephTremoulet.
sanjoy added a subscriber: llvm-commits.
Herald added subscribers: mcrosier, sanjoy.

This change adds a `-spp-no-statepoints` flag to PlaceSafepoints that
bypasses the code that wraps newly introduced polls and existing calls
in gc.statepoint.  With `-spp-no-statepoints` enabled, PlaceSafepoints
effectively becomes a safpeoint **poll** insertion pass.

The eventual goal is to "constant fold" this option, along with
`-rs4gc-use-deopt-bundles` to `true`, once clients using gc.statepoint
are okay doing so.

http://reviews.llvm.org/D16439

Files:
  lib/Transforms/Scalar/PlaceSafepoints.cpp
  test/Transforms/PlaceSafepoints/no-statepoints.ll

Index: test/Transforms/PlaceSafepoints/no-statepoints.ll
===================================================================
--- /dev/null
+++ test/Transforms/PlaceSafepoints/no-statepoints.ll
@@ -0,0 +1,21 @@
+; RUN: opt -spp-no-statepoints -S -place-safepoints < %s | FileCheck %s
+
+define void @test() gc "statepoint-example" {
+; CHECK-LABEL: test(
+entry:
+; CHECK: entry:
+; CHECK: call void @do_safepoint()
+  br label %other
+
+other:
+; CHECK: other:
+  call void undef() "gc-leaf-function"
+; CHECK: call void @do_safepoint()
+  br label %other
+}
+
+declare void @do_safepoint()
+define void @gc.safepoint_poll() {
+  call void @do_safepoint()
+  ret void
+}
Index: lib/Transforms/Scalar/PlaceSafepoints.cpp
===================================================================
--- lib/Transforms/Scalar/PlaceSafepoints.cpp
+++ lib/Transforms/Scalar/PlaceSafepoints.cpp
@@ -108,6 +108,11 @@
 static cl::opt<bool> SplitBackedge("spp-split-backedge", cl::Hidden,
                                    cl::init(false));
 
+// If true, don't wrap calls (the ones present in the IR, and the ones
+// introduced due to polls) in gc.statepoint.
+static cl::opt<bool> NoStatepoints("spp-no-statepoints", cl::Hidden,
+                                   cl::init(false));
+
 // Print tracing output
 static cl::opt<bool> TraceLSP("spp-trace", cl::Hidden, cl::init(false));
 
@@ -661,6 +666,12 @@
     ParsePointNeeded.insert(ParsePointNeeded.end(), RuntimeCalls.begin(),
                             RuntimeCalls.end());
   }
+
+  // If we've been asked to not wrap the calls with gc.statepoint, then we're
+  // done.
+  if (NoStatepoints)
+    return modified;
+
   PollsNeeded.clear(); // make sure we don't accidentally use
   // The dominator tree has been invalidated by the inlining performed in the
   // above loop.  TODO: Teach the inliner how to update the dom tree?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16439.45636.patch
Type: text/x-patch
Size: 1876 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160122/fc3ab0ba/attachment.bin>


More information about the llvm-commits mailing list