[PATCH] [Transforms] Write basic -place-safepoints test, fix bug

Ramkumar Ramachandra artagnon at gmail.com
Mon Feb 9 13:25:16 PST 2015


As requested by reames, shrink the original submission to be just the
bugfix. Other changes will come as later patches.


http://reviews.llvm.org/D7456

Files:
  lib/Transforms/Scalar/PlaceSafepoints.cpp
  test/Transforms/Safepoint/place.ll

Index: lib/Transforms/Scalar/PlaceSafepoints.cpp
===================================================================
--- lib/Transforms/Scalar/PlaceSafepoints.cpp
+++ lib/Transforms/Scalar/PlaceSafepoints.cpp
@@ -861,18 +861,22 @@
   IRBuilder<> Builder(insertBefore);
   // First, create the statepoint (with all live ptrs as arguments).
   std::vector<llvm::Value *> args;
-  // target, #args, unused, args
+  // target, #args, unused, ... args, #deopt args, ... deopt args, ... gc
+  // paramters
   Value *Target = CS.getCalledValue();
   args.push_back(Target);
   int callArgSize = CS.arg_size();
   args.push_back(
       ConstantInt::get(Type::getInt32Ty(M->getContext()), callArgSize));
-  // TODO: add a 'Needs GC-rewrite' later flag
+  // unused
   args.push_back(ConstantInt::get(Type::getInt32Ty(M->getContext()), 0));
 
   // Copy all the arguments of the original call
   args.insert(args.end(), CS.arg_begin(), CS.arg_end());
 
+  // deopt
+  args.push_back(ConstantInt::get(Type::getInt32Ty(M->getContext()), 0));
+
   // Create the statepoint given all the arguments
   Instruction *token = nullptr;
   AttributeSet return_attributes;
Index: test/Transforms/Safepoint/place.ll
===================================================================
--- /dev/null
+++ test/Transforms/Safepoint/place.ll
@@ -0,0 +1,33 @@
+; RUN: opt %s -place-safepoints -S | FileCheck %s
+
+declare zeroext i1 @void_return_i1()
+declare zeroext i1 @i1_return_i1(i1)
+
+define void @gc.safepoint_poll() {
+  ret void
+}
+
+define i1 @test_basic() gc "statepoint-example" {
+; CHECK-LABEL: test_basic
+; This is checking that a statepoint_poll + statepoint + result is
+; inserted for a function that doesn't take arguments.
+; CHECK: gc.statepoint.p0f_isVoidf
+; CHECK: gc.statepoint.p0f_i1f
+; CHECK: gc.result.int.i1
+entry:
+  %call1 = tail call i1 ()* @void_return_i1()
+  ret i1 %call1
+}
+
+define i1 @test_argument() gc "statepoint-example" {
+; CHECK-LABEL: test_argument
+; This is checking that a statepoint_poll + statepoint + result is
+; inserted for a function that takes 1 argument.
+; CHECK: gc.statepoint.p0f_isVoidf
+; CHECK: gc.statepoint.p0f_i1i1f
+; CHECK: (i1 (i1)* @i1_return_i1, i32 1, i32 0, i1 false, i32 0)
+; CHECK: gc.result.int.i1
+entry:
+  %call1 = tail call i1 (i1)* @i1_return_i1(i1 false)
+  ret i1 %call1
+}
\ No newline at end of file

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7456.19607.patch
Type: text/x-patch
Size: 2367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150209/f48eced0/attachment.bin>


More information about the llvm-commits mailing list