[llvm] r258551 - [PlaceSafepoints] Introduce a -spp-no-statepoints flag

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 22 13:02:56 PST 2016


Author: sanjoy
Date: Fri Jan 22 15:02:55 2016
New Revision: 258551

URL: http://llvm.org/viewvc/llvm-project?rev=258551&view=rev
Log:
[PlaceSafepoints] Introduce a -spp-no-statepoints flag

Summary:
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.

Reviewers: pgavlin, reames, JosephTremoulet

Subscribers: sanjoy, mcrosier, llvm-commits

Differential Revision: http://reviews.llvm.org/D16439

Added:
    llvm/trunk/test/Transforms/PlaceSafepoints/no-statepoints.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp?rev=258551&r1=258550&r2=258551&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp Fri Jan 22 15:02:55 2016
@@ -108,6 +108,11 @@ static cl::opt<int> CountedLoopTripWidth
 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,15 @@ bool PlaceSafepoints::runOnFunction(Func
     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.  In the near future, this option will be "constant folded" to true,
+  // and the code below that deals with insert gc.statepoint calls will be
+  // removed.  Wrapping potentially safepointing calls in gc.statepoint will
+  // then become the responsibility of the RewriteStatepointsForGC pass.
+  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?

Added: llvm/trunk/test/Transforms/PlaceSafepoints/no-statepoints.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PlaceSafepoints/no-statepoints.ll?rev=258551&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/PlaceSafepoints/no-statepoints.ll (added)
+++ llvm/trunk/test/Transforms/PlaceSafepoints/no-statepoints.ll Fri Jan 22 15:02:55 2016
@@ -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
+}




More information about the llvm-commits mailing list