[llvm] r235820 - Don't Place Entry Safepoints Before the llvm.frameescape() Intrinsic

Philip Reames listmail at philipreames.com
Sun Apr 26 12:41:24 PDT 2015


Author: reames
Date: Sun Apr 26 14:41:23 2015
New Revision: 235820

URL: http://llvm.org/viewvc/llvm-project?rev=235820&view=rev
Log:
Don't Place Entry Safepoints Before the llvm.frameescape() Intrinsic

llvm.frameescape() intrinsic is not a real call. The intrinsic can only exist in the entry block. Inserting a gc.statepoint() before llvm.frameescape() may split the entry block, and push the intrinsic out of the entry block.

Patch by: Swaroop.Sridhar at microsoft.com
Differential Revision: http://reviews.llvm.org/D8910



Added:
    llvm/trunk/test/Transforms/PlaceSafepoints/statepoint-frameescape.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=235820&r1=235819&r2=235820&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp Sun Apr 26 14:41:23 2015
@@ -430,6 +430,13 @@ static Instruction *findLocationForEntry
         if (II->getIntrinsicID() == Intrinsic::assume) {
           continue;
         }
+        // llvm.frameescape() intrinsic is not a real call. The intrinsic can 
+        // exist only in the entry block.
+        // Inserting a statepoint before llvm.frameescape() may split the 
+        // entry block, and push the intrinsic out of the entry block.
+        if (II->getIntrinsicID() == Intrinsic::frameescape) {
+          continue;
+        }
       }
       break;
     }

Added: llvm/trunk/test/Transforms/PlaceSafepoints/statepoint-frameescape.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PlaceSafepoints/statepoint-frameescape.ll?rev=235820&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/PlaceSafepoints/statepoint-frameescape.ll (added)
+++ llvm/trunk/test/Transforms/PlaceSafepoints/statepoint-frameescape.ll Sun Apr 26 14:41:23 2015
@@ -0,0 +1,29 @@
+; RUN: opt %s -S -place-safepoints | FileCheck %s
+
+declare void @llvm.frameescape(...)
+
+; Do we insert the entry safepoint after the frameescape intrinsic?
+define void @parent() gc "statepoint-example" {
+; CHECK-LABEL: @parent
+entry:
+; CHECK-LABEL: entry
+; CHECK-NEXT: alloca
+; CHECK-NEXT: frameescape
+; CHECK-NEXT: statepoint
+  %ptr = alloca i32
+  call void (...) @llvm.frameescape(i32* %ptr)
+  ret void
+}
+
+; This function is inlined when inserting a poll.  To avoid recursive 
+; issues, make sure we don't place safepoints in it.
+declare void @do_safepoint()
+define void @gc.safepoint_poll() {
+; CHECK-LABEL: gc.safepoint_poll
+; CHECK-LABEL: entry
+; CHECK-NEXT: do_safepoint
+; CHECK-NEXT: ret void 
+entry:
+  call void @do_safepoint()
+  ret void
+}





More information about the llvm-commits mailing list