Adjust how we avoid poll insertion inside the poll function (NFC)
authorPhilip Reames <listmail@philipreames.com>
Tue, 10 Feb 2015 00:04:53 +0000 (00:04 +0000)
committerPhilip Reames <listmail@philipreames.com>
Tue, 10 Feb 2015 00:04:53 +0000 (00:04 +0000)
I realized that my early fix for this was overly complicated.  Rather than scatter checks around in a bunch of places, just exit early when we visit the poll function itself.

Thinking about it a bit, the whole inlining mechanism used with gc.safepoint_poll could probably be cleaned up a bit.  Originally, poll insertion was fused with gc relocation rewriting.  It might be worth going back to see if we can simplify the chain of events now that these two are seperated.  As one thought, maybe it makes sense to rewrite calls inside the helper function before inlining it to the many callers.  This would require us to visit the poll function before any other functions though..

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228634 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/PlaceSafepoints.cpp

index 7b10d543736dcdf7b443c9e7ae5fa2c91623b208..593e1a0d45684067b2bd08fcd9f4c4da14a8f7ca 100644 (file)
@@ -509,6 +509,13 @@ bool PlaceSafepoints::runOnFunction(Function &F) {
     return false;
   }
 
+  if (isGCSafepointPoll(F)) {
+    // Given we're inlining this inside of safepoint poll insertion, this
+    // doesn't make any sense.  Note that we do make any contained calls
+    // parseable after we inline a poll.  
+    return false;
+  }
+
   bool modified = false;
 
   // In various bits below, we rely on the fact that uses are reachable from
@@ -527,14 +534,13 @@ bool PlaceSafepoints::runOnFunction(Function &F) {
 
   std::vector<CallSite> ParsePointNeeded;
 
-  if (EnableBackedgeSafepoints && !isGCSafepointPoll(F)) {
+  if (EnableBackedgeSafepoints) {
     // Construct a pass manager to run the LoopPass backedge logic.  We
     // need the pass manager to handle scheduling all the loop passes
     // appropriately.  Doing this by hand is painful and just not worth messing
     // with for the moment.
     FunctionPassManager FPM(F.getParent());
-    bool CanAssumeCallSafepoints = EnableCallSafepoints &&
-      !isGCSafepointPoll(F);
+    bool CanAssumeCallSafepoints = EnableCallSafepoints;
     PlaceBackedgeSafepointsImpl *PBS =
       new PlaceBackedgeSafepointsImpl(CanAssumeCallSafepoints);
     FPM.add(PBS);
@@ -601,7 +607,7 @@ bool PlaceSafepoints::runOnFunction(Function &F) {
     }
   }
 
-  if (EnableEntrySafepoints && !isGCSafepointPoll(F)) {
+  if (EnableEntrySafepoints) {
     DT.recalculate(F);
     Instruction *term = findLocationForEntrySafepoint(F, DT);
     if (!term) {
@@ -616,7 +622,7 @@ bool PlaceSafepoints::runOnFunction(Function &F) {
     }
   }
 
-  if (EnableCallSafepoints && !isGCSafepointPoll(F)) {
+  if (EnableCallSafepoints) {
     DT.recalculate(F);
     std::vector<CallSite> Calls;
     findCallSafepoints(F, Calls);