[PATCH] [Transforms] Write basic -place-safepoints test, fix bug
Ramkumar Ramachandra
artagnon at gmail.com
Thu Feb 5 20:06:11 PST 2015
Hi reames,
Start out by documenting the minmum example of -place-safepoints
working. While doing this, improve a couple of assert errors from
PlaceSafepoints and fix a bug: deopt arguments was not accounted for,
causing a verify-failure.
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
@@ -738,7 +738,8 @@
// different type inserted previously
Function *F =
dyn_cast<Function>(M->getOrInsertFunction("gc.safepoint_poll", ftype));
- assert(F && !F->empty() && "definition must exist");
+ assert(F && "void @gc.safepoint_poll() must be defined");
+ assert(!F->empty() && "gc.safepoint_poll must be a non-empty function");
CallInst *poll = CallInst::Create(F, "", term);
// Record some information about the call site we're replacing
@@ -861,14 +862,16 @@
IRBuilder<> Builder(insertBefore);
// First, create the statepoint (with all live ptrs as arguments).
std::vector<llvm::Value *> args;
- // target, #args, unused, args
+ // target, #call args, unused, call parameters, #deopt args, deopt parameters
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
args.push_back(ConstantInt::get(Type::getInt32Ty(M->getContext()), 0));
+ // deopt: 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());
Index: test/Transforms/Safepoint/place.ll
===================================================================
--- /dev/null
+++ test/Transforms/Safepoint/place.ll
@@ -0,0 +1,17 @@
+; RUN: opt %s -place-safepoints -S | FileCheck %s
+
+declare zeroext i1 @return_i1()
+
+define void @gc.safepoint_poll() {
+ ret void
+}
+
+define i1 @test_basic() gc "statepoint-example" {
+; CHECK-LABEL: test_basic
+; This is just checking that a statepoint is inserted
+; CHECK: gc.statepoint.p0f_isVoidf
+; CHECK: gc.statepoint.p0f_i1f
+entry:
+ %call1 = tail call i1 ()* @return_i1()
+ ret i1 %call1
+}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7456.19455.patch
Type: text/x-patch
Size: 2075 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150206/b76a043e/attachment.bin>
More information about the llvm-commits
mailing list