diff options
author | Philip Reames <listmail@philipreames.com> | 2015-02-09 21:48:05 +0000 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2015-02-09 21:48:05 +0000 |
commit | b1ed02f7280d9646853460fd279f19052fc32939 (patch) | |
tree | 0a038faa501026f24771c49b3ea053b1ea55834b /llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp | |
parent | ac3ed7afc988e581318ab1b656bdb6274edfb602 (diff) | |
download | bcm5719-llvm-b1ed02f7280d9646853460fd279f19052fc32939.tar.gz bcm5719-llvm-b1ed02f7280d9646853460fd279f19052fc32939.zip |
Add basic tests for PlaceSafepoints
This is just adding really simple tests which should have been part of the original submission. When doing so, I discovered that I'd mistakenly removed required pieces when preparing the patch for upstream submission. I fixed two such bugs in this submission.
llvm-svn: 228610
Diffstat (limited to 'llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp index 8315d322689..7e018db050b 100644 --- a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp +++ b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp @@ -501,6 +501,12 @@ template <typename T> static void unique_unsorted(std::vector<T> &vec) { } } +static std::string GCSafepointPollName("gc.safepoint_poll"); + +static bool isGCSafepointPoll(Function &F) { + return F.getName().equals(GCSafepointPollName); +} + bool PlaceSafepoints::runOnFunction(Function &F) { if (F.isDeclaration() || F.empty()) { // This is a declaration, nothing to do. Must exit early to avoid crash in @@ -526,14 +532,16 @@ bool PlaceSafepoints::runOnFunction(Function &F) { std::vector<CallSite> ParsePointNeeded; - if (EnableBackedgeSafepoints) { + if (EnableBackedgeSafepoints && !isGCSafepointPoll(F)) { // 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); PlaceBackedgeSafepointsImpl *PBS = - new PlaceBackedgeSafepointsImpl(EnableCallSafepoints); + new PlaceBackedgeSafepointsImpl(CanAssumeCallSafepoints); FPM.add(PBS); // Note: While the analysis pass itself won't modify the IR, LoopSimplify // (which it depends on) may. i.e. analysis must be recalculated after run @@ -598,7 +606,7 @@ bool PlaceSafepoints::runOnFunction(Function &F) { } } - if (EnableEntrySafepoints) { + if (EnableEntrySafepoints && !isGCSafepointPoll(F)) { DT.recalculate(F); Instruction *term = findLocationForEntrySafepoint(F, DT); if (!term) { @@ -613,7 +621,7 @@ bool PlaceSafepoints::runOnFunction(Function &F) { } } - if (EnableCallSafepoints) { + if (EnableCallSafepoints && !isGCSafepointPoll(F)) { DT.recalculate(F); std::vector<CallSite> Calls; findCallSafepoints(F, Calls); @@ -861,7 +869,7 @@ static Value *ReplaceWithStatepoint(const CallSite &CS, /* to replace */ 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 args..., #deopt args, deopt args..., gc args... Value *Target = CS.getCalledValue(); args.push_back(Target); int callArgSize = CS.arg_size(); @@ -873,6 +881,14 @@ static Value *ReplaceWithStatepoint(const CallSite &CS, /* to replace */ // Copy all the arguments of the original call args.insert(args.end(), CS.arg_begin(), CS.arg_end()); + // # of deopt arguments: this pass currently does not support the + // identification of deopt arguments. If this is interesting to you, + // please ask on llvm-dev. + args.push_back(ConstantInt::get(Type::getInt32Ty(M->getContext()), 0)); + + // Note: The gc args are not filled in at this time, that's handled by + // RewriteStatepointsForGC (which is currently under review). + // Create the statepoint given all the arguments Instruction *token = nullptr; AttributeSet return_attributes; |